@Override public ResourceResponse<Document> apply() throws DocumentClientException { DocumentServiceRequest request = getCreateDocumentRequest(documentCollectionLink, documentLocal, optionsLocal, disableAutomaticIdGenerationLocal, OperationType.Upsert); return new ResourceResponse<Document>(doUpsert(request), Document.class); } };
@Override public ResourceResponse<Document> apply() throws DocumentClientException { DocumentServiceRequest request = getCreateDocumentRequest(documentCollectionLink, documentLocal, optionsLocal, disableAutomaticIdGenerationLocal, OperationType.Create); return new ResourceResponse<Document>(doCreate(request), Document.class); } };
@Override public ResourceResponse<Document> apply() throws DocumentClientException { return new ResourceResponse<Document>(doReplace(request), Document.class); } };
public static <T extends Resource> ResourceResponse<T> toResourceResponse(DocumentServiceResponse response, Class<T> cls) { return new ResourceResponse<T>(response, cls); }
/** * Creates an attachment. * * @param documentLink the document link. * @param mediaStream the media stream for creating the attachment. * @param options the media options. * @return the resource response with the created attachment. * @throws DocumentClientException the document client exception. */ public ResourceResponse<Attachment> createAttachment(String documentLink, InputStream mediaStream, MediaOptions options) throws DocumentClientException { logger.debug("Creating a Attachment. attachmentLink [{}]", documentLink); DocumentServiceRequest request = getAttachmentRequest(documentLink, mediaStream, options, OperationType.Create); return new ResourceResponse<Attachment>(this.doCreate(request), Attachment.class); }
/** * Reads an offer. * * @param offerLink the offer link. * @return the resource response with the read offer. * @throws DocumentClientException the document client exception. */ public ResourceResponse<Offer> readOffer(String offerLink) throws DocumentClientException { if (StringUtils.isEmpty(offerLink)) { throw new IllegalArgumentException("offerLink"); } logger.debug("Reading an Offer. offerLink [{}]", offerLink); String path = Utils.joinPath(offerLink, null); DocumentServiceRequest request = DocumentServiceRequest.create(OperationType.Read, ResourceType.Offer, path, null); return new ResourceResponse<Offer>(this.doRead(request), Offer.class); }
/** * Upserts a trigger. * * @param collectionLink the collection link. * @param trigger the trigger to upsert. * @param options the request options. * @return the resource response with the upserted trigger. * @throws DocumentClientException the document client exception. */ public ResourceResponse<Trigger> upsertTrigger(String collectionLink, Trigger trigger, RequestOptions options) throws DocumentClientException { logger.debug("Upserting a Trigger. collectionLink [{}], trigger id [{}]", collectionLink, trigger.getId()); DocumentServiceRequest request = getTriggerRequest(collectionLink, trigger, options, OperationType.Upsert); return new ResourceResponse<Trigger>(this.doUpsert(request), Trigger.class); }
/** * Upserts a user. * * @param databaseLink the database link. * @param user the user to upsert. * @param options the request options. * @return the resource response with the upserted user. * @throws DocumentClientException the document client exception. */ public ResourceResponse<User> upsertUser(String databaseLink, User user, RequestOptions options) throws DocumentClientException { logger.debug("Upserting a User. databaseLink [{}], user id [{}]", databaseLink, user.getId()); DocumentServiceRequest request = getUserRequest(databaseLink, user, options, OperationType.Upsert); return new ResourceResponse<User>(this.doUpsert(request), User.class); }
/** * Creates a permission. * * @param userLink the user link. * @param permission the permission to create. * @param options the request options. * @return the resource response with the created permission. * @throws DocumentClientException the document client exception. */ public ResourceResponse<Permission> createPermission(String userLink, Permission permission, RequestOptions options) throws DocumentClientException { logger.debug("Creating a Permission. userLink [{}], permission id [{}]", userLink, permission.getId()); DocumentServiceRequest request = getPermissionRequest(userLink, permission, options, OperationType.Create); return new ResourceResponse<Permission>(this.doCreate(request), Permission.class); }
/** * Reads a trigger by the trigger link. * * @param triggerLink the trigger link. * @param options the request options. * @return the resource response with the read trigger. * @throws DocumentClientException the document client exception. */ public ResourceResponse<Trigger> readTrigger(String triggerLink, RequestOptions options) throws DocumentClientException { if (StringUtils.isEmpty(triggerLink)) { throw new IllegalArgumentException("triggerLink"); } logger.debug("Reading a Trigger. triggerLink [{}]", triggerLink); String path = Utils.joinPath(triggerLink, null); Map<String, String> requestHeaders = getRequestHeaders(options); DocumentServiceRequest request = DocumentServiceRequest.create(OperationType.Read, ResourceType.Trigger, path, requestHeaders); return new ResourceResponse<Trigger>(this.doRead(request), Trigger.class); }
/** * Reads a permission. * * @param permissionLink the permission link. * @param options the request options. * @return the resource response with the read permission. * @throws DocumentClientException the document client exception. */ public ResourceResponse<Permission> readPermission(String permissionLink, RequestOptions options) throws DocumentClientException { if (StringUtils.isEmpty(permissionLink)) { throw new IllegalArgumentException("permissionLink"); } logger.debug("Reading a Permission. permissionLink [{}]", permissionLink); String path = Utils.joinPath(permissionLink, null); Map<String, String> requestHeaders = getRequestHeaders(options); DocumentServiceRequest request = DocumentServiceRequest.create(OperationType.Read, ResourceType.Permission, path, requestHeaders); return new ResourceResponse<Permission>(this.doRead(request), Permission.class); }
/** * Creates a user. * * @param databaseLink the database link. * @param user the user to create. * @param options the request options. * @return the resource response with the created user. * @throws DocumentClientException the document client exception. */ public ResourceResponse<User> createUser(String databaseLink, User user, RequestOptions options) throws DocumentClientException { logger.debug("Creating a User. databaseLink [{}], user id [{}]", databaseLink, user.getId()); DocumentServiceRequest request = getUserRequest(databaseLink, user, options, OperationType.Create); return new ResourceResponse<User>(this.doCreate(request), User.class); }
/** * Upserts a permission. * * @param userLink the user link. * @param permission the permission to upsert. * @param options the request options. * @return the resource response with the upserted permission. * @throws DocumentClientException the document client exception. */ public ResourceResponse<Permission> upsertPermission(String userLink, Permission permission, RequestOptions options) throws DocumentClientException { logger.debug("Upserting a Permission. userLink [{}], permission id [{}]", userLink, permission.getId()); DocumentServiceRequest request = getPermissionRequest(userLink, permission, options, OperationType.Upsert); return new ResourceResponse<Permission>(this.doUpsert(request), Permission.class); }
/** * Creates a stored procedure. * * @param collectionLink the collection link. * @param storedProcedure the stored procedure to create. * @param options the request options. * @return the resource response with the created stored procedure. * @throws DocumentClientException the document client exception. */ public ResourceResponse<StoredProcedure> createStoredProcedure(String collectionLink, StoredProcedure storedProcedure, RequestOptions options) throws DocumentClientException { logger.debug("Creating a StoredProcedure. collectionLink: [{}], storedProcedure id [{}]", collectionLink, storedProcedure.getId()); DocumentServiceRequest request = getStoredProcedureRequest(collectionLink, storedProcedure, options, OperationType.Create); return new ResourceResponse<StoredProcedure>(this.doCreate(request), StoredProcedure.class); }
/** * Creates a trigger. * * @param collectionLink the collection link. * @param trigger the trigger. * @param options the request options. * @return the resource response with the created trigger. * @throws DocumentClientException the document client exception. */ public ResourceResponse<Trigger> createTrigger(String collectionLink, Trigger trigger, RequestOptions options) throws DocumentClientException { logger.debug("Creating a Trigger. collectionLink [{}], trigger id [{}]", collectionLink, trigger.getId()); DocumentServiceRequest request = getTriggerRequest(collectionLink, trigger, options, OperationType.Create); return new ResourceResponse<Trigger>(this.doCreate(request), Trigger.class); }
/** * Deletes a user. * * @param userLink the user link. * @param options the request options. * @return the resource response. * @throws DocumentClientException the document client exception. */ public ResourceResponse<User> deleteUser(String userLink, RequestOptions options) throws DocumentClientException { if (StringUtils.isEmpty(userLink)) { throw new IllegalArgumentException("userLink"); } logger.debug("Deleting a User. userLink [{}]", userLink); String path = Utils.joinPath(userLink, null); Map<String, String> requestHeaders = getRequestHeaders(options); DocumentServiceRequest request = DocumentServiceRequest.create(OperationType.Delete, ResourceType.User, path, requestHeaders); return new ResourceResponse<User>(this.doDelete(request), User.class); }
/** * Creates an attachment. * * @param documentLink the document link. * @param attachment the attachment to create. * @param options the request options. * @return the resource response with the created attachment. * @throws DocumentClientException the document client exception. */ public ResourceResponse<Attachment> createAttachment(String documentLink, Attachment attachment, RequestOptions options) throws DocumentClientException { logger.debug("Creating a Attachment. documentLink [{}], attachment id [{}]", documentLink, attachment.getId()); DocumentServiceRequest request = getAttachmentRequest(documentLink, attachment, options, OperationType.Create); return new ResourceResponse<Attachment>(this.doCreate(request), Attachment.class); }
/** * Upserts an attachment. * * @param documentLink the document link. * @param attachment the attachment to upsert. * @param options the request options. * @return the resource response with the upserted attachment. * @throws DocumentClientException the document client exception. */ public ResourceResponse<Attachment> upsertAttachment(String documentLink, Attachment attachment, RequestOptions options) throws DocumentClientException { logger.debug("Upserting a Attachment. documentLink [{}], attachment id [{}]", documentLink, attachment.getId()); DocumentServiceRequest request = getAttachmentRequest(documentLink, attachment, options, OperationType.Upsert); return new ResourceResponse<Attachment>(this.doUpsert(request), Attachment.class); }
/** * Creates a user defined function. * * @param collectionLink the collection link. * @param udf the user defined function. * @param options the request options. * @return the resource response with the created user defined function. * @throws DocumentClientException the document client exception. */ public ResourceResponse<UserDefinedFunction> createUserDefinedFunction( String collectionLink, UserDefinedFunction udf, RequestOptions options) throws DocumentClientException { logger.debug("Creating a UserDefinedFunction. collectionLink [{}], udf id [{}]", collectionLink, udf.getId()); DocumentServiceRequest request = getUserDefinedFunctionRequest(collectionLink, udf, options, OperationType.Create); return new ResourceResponse<UserDefinedFunction>(this.doCreate(request), UserDefinedFunction.class); }
/** * Deletes a conflict. * * @param conflictLink the conflict link. * @param options the request options. * @return the resource response. * @throws DocumentClientException the document client exception. */ public ResourceResponse<Conflict> deleteConflict(String conflictLink, RequestOptions options) throws DocumentClientException { if (StringUtils.isEmpty(conflictLink)) { throw new IllegalArgumentException("conflictLink"); } logger.debug("Deleting a Conflicts. conflictLink [{}]", conflictLink); String path = Utils.joinPath(conflictLink, null); Map<String, String> requestHeaders = getRequestHeaders(options); DocumentServiceRequest request = DocumentServiceRequest.create(OperationType.Delete, ResourceType.Conflict, path, requestHeaders); this.addPartitionKeyInformation(request, null, options); return new ResourceResponse<Conflict>(this.doDelete(request), Conflict.class); }