Interface ProductBatchAdminSession
- All Superinterfaces:
AutoCloseable, Closeable, OsidSession, OsidSession, ProductAdminSession
This session creates, updates, and deletes Products in bulk.
The data for create and update is provided by the consumer via the form
object. OsidForms are requested for each create or update and may
not be reused.
Create and update operations differ in their usage. To create a
Product , a ProductForm is requested using
getProductFormsForCreate() specifying the desired record Types or
none if no record Types are needed. Each of the returned
ProductForms will indicate that it is to be used with a create operation
and can be used to examine metdata or validate data prior to creation.
Once a ProductForm is submiited to a create operation, it cannot
be reused with another create operation unless the first operation was
unsuccessful. Each ProductForm corresponds to an attempted
transaction.
The ProductForms returned from
getProductFormsForCreate() may be linked to the originating request
through the peer Ids of the ProductForm . In the case
where there may be duplicates, any ProductForm of the same peer
Ids may be used for a create operation.
Once a batch of ProductForms are submitted for create, a
CreateResponse is returned for each ProductForm , although
the ordering is not defined. Only errors that pertain to the entire create
operation are returned from createProducts() , errors specific to
an individual ProductForm are indicated in the corresponding
CreateResponse . CreateResponses may be linked to the
originating ProductForm through the ProductForm Id
.
For updates, ProductForms are requested to the Product
Id that is to be updated using getProductFormsForUpdate()
where the reference Id in the ProductForm may be used to
link the request. Similarly, the ProductForm has metadata about
the data that can be updated and it can perform validation before
submitting the update. The ProductForm can only be used once for a
successful update and cannot be reused.
Once a batch of ProductForms are submitted for update, an
UpdateResponse is returned for each ProductForm , although
the ordering is not defined. Only errors that pertain to the entire update
operation are returned from updateProducts() , errors specific to
an individual ProductForm are indicated in the corresponding
UpdateResponse . UpdateResponses may be linked to the
originating ProductForm through the ProductForm Id
.
The delete operations delete Products in bulk. To unmap a
Product from the current Store , the
ProductStoreAssignmentSession should be used. These delete operations
attempt to remove the Product itself thus removing it from all
known Store catalogs. Bulk delete operations return the results in
DeleteResponses .
-
Method Summary
Modifier and TypeMethodDescriptionaliasProducts(AliasRequestList aliasRequests) Adds anIdto aProductfor the purpose of creating compatibility.createProducts(ProductBatchFormList productForms) Creates a new set ofProducts.Deletes allProductsin thisStore.deleteProducts(IdList productIds) Deletes products for the givenIds.getProductFormsForCreate(long number, Type[] productRecordTypes) Gets the product forms for creating a bunch of new productsgetProductFormsForUpdate(IdList productIds) Gets the product forms for updating an existing set of products.updateProducts(ProductBatchFormList productForms) Updates existing products.Methods inherited from interface OsidSession
closeMethods inherited from interface OsidSession
getAuthenticatedAgent, getAuthenticatedAgentId, getClockRate, getDate, getEffectiveAgent, getEffectiveAgentId, getFormatType, getLocale, isAuthenticated, startTransaction, supportsTransactionsModifier and TypeMethodDescriptionGets the agent authenticated to this session.Gets theIdof the agent authenticated to this session.Gets the rate of the service clock.getDate()Gets the service date which may be the current date or the effective date in which this session exists.Gets the effective agent in use by this session.Gets theIdof the effective agent in use by this session.Gets theDisplayTextformatTypepreference in effect for this session.Gets the locale indicating the localization preferences in effect for this session.booleanTests if an agent is authenticated to this session.Starts a new transaction for this sesson.booleanTests for the availability of transactions.Methods inherited from interface ProductAdminSession
aliasProduct, canCreateProducts, canCreateProductWithRecordTypes, canDeleteProducts, canManageProductAliases, canUpdateProducts, createProduct, deleteProduct, getProductFormForCreate, getProductFormForUpdate, getStore, getStoreId, updateProductModifier and TypeMethodDescriptionvoidaliasProduct(Id productId, Id aliasId) Adds anIdto aProductfor the purpose of creating compatibility.booleanTests if this user can createProducts.booleancanCreateProductWithRecordTypes(Type[] productRecordTypes) Tests if this user can create a singleProductusing the desired record types.booleanTests if this user can deleteProductsA return of true does not guarantee successful authorization.booleanTests if this user can manageIdaliases forProducts.booleanTests if this user can updateProducts.createProduct(ProductForm productForm) Creates a newProduct.voiddeleteProduct(Id productId) Deletes aProduct.getProductFormForCreate(Type[] productRecordTypes) Gets the product form for creating new products.getProductFormForUpdate(Id productId) Gets the product form for updating an existing product.getStore()Gets theStoreassociated with this session.Gets theStoreIdassociated with this session.voidupdateProduct(ProductForm productForm) Updates an existing product.
-
Method Details
-
getProductFormsForCreate
ProductBatchFormList getProductFormsForCreate(long number, Type[] productRecordTypes) throws OperationFailedException, PermissionDeniedException Gets the product forms for creating a bunch of new products- Parameters:
number- the number of forms to retrieveproductRecordTypes- array of product record types to be included in each create operation or an empty list if none- Returns:
- the product forms
- Throws:
NullArgumentException-productRecordTypesisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException- unable to request forms with given record types- Compliance:
mandatory- This method must be implemented.
-
createProducts
CreateResponseList createProducts(ProductBatchFormList productForms) throws OperationFailedException, PermissionDeniedException Creates a new set ofProducts. This method returns an error if the entire operation fails. Otherwise, the status of an individual create operation is indicated in theBatchCreateResponse.- Parameters:
productForms- the product forms- Returns:
- the create responses
- Throws:
NullArgumentException-productFormsisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
getProductFormsForUpdate
ProductBatchFormList getProductFormsForUpdate(IdList productIds) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets the product forms for updating an existing set of products. A new product form should be requested for each update transaction.- Parameters:
productIds- theIdsof theProduct- Returns:
- the product form
- Throws:
NotFoundException- aproductIdis not foundNullArgumentException-productIdsisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
updateProducts
UpdateResponseList updateProducts(ProductBatchFormList productForms) throws OperationFailedException, PermissionDeniedException Updates existing products. This method returns an error if the entire operation fails. Otherwise, the status of an individual update operation is indicated in theBatchCreateResponse.- Parameters:
productForms- the form containing the elements to be updated- Returns:
- the update responses
- Throws:
NullArgumentException-productFormsisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
deleteAllProducts
Deletes allProductsin thisStore.- Returns:
- the delete responses
- Throws:
OperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
deleteProducts
DeleteResponseList deleteProducts(IdList productIds) throws OperationFailedException, PermissionDeniedException Deletes products for the givenIds.- Parameters:
productIds- theIdsof the products to delete- Returns:
- the delete responses
- Throws:
NullArgumentException-productIdsisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
aliasProducts
AliasResponseList aliasProducts(AliasRequestList aliasRequests) throws OperationFailedException, PermissionDeniedException Adds anIdto aProductfor the purpose of creating compatibility. The primaryIdof theProductis determined by the provider. The newIdis an alias to the primaryId. If the alias is a pointer to another product, it is reassigned to the given productId.- Parameters:
aliasRequests- the alias requests- Returns:
- the alias responses
- Throws:
NullArgumentException-aliasRequestsisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-