Interface ProductAdminSession
- All Superinterfaces:
AutoCloseable, Closeable, OsidSession, OsidSession
- All Known Subinterfaces:
ProductBatchAdminSession
This session creates, updates, and deletes Products . 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
getProductFormForCreate() specifying the desired record Types or
none if no record Types are needed. The returned
ProductForm 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 the 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.
For updates, ProductForms are requested to the Product
Id that is to be updated using getProductFormForUpdate() .
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.
The delete operations delete Products . 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.
This session includes an Id aliasing mechanism to assign an
external Id to an internally assigned Id.
-
Method Summary
Modifier 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.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.
-
Method Details
-
getStoreId
Id getStoreId()Gets theStoreIdassociated with this session.- Returns:
- the
Store Idassociated with this session - Compliance:
mandatory- This method must be implemented.
-
getStore
Gets theStoreassociated with this session.- Returns:
- the store
- Throws:
OperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
canCreateProducts
boolean canCreateProducts()Tests if this user can createProducts. A return of true does not guarantee successful authorization. A return of false indicates that it is known creating aProductwill result in aPERMISSION_DENIED. This is intended as a hint to an application that may not wish to offer create operations to unauthorized users.- Returns:
falseifProductcreation is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
canCreateProductWithRecordTypes
Tests if this user can create a singleProductusing the desired record types. WhileOrderingManager.getProductRecordTypes()can be used to examine which records are supported, this method tests which record(s) are required for creating a specificProduct. Providing an empty array tests if aProductcan be created with no records.- Parameters:
productRecordTypes- array of product record types- Returns:
trueifProductcreation using the specified recordTypesis supported,falseotherwise- Throws:
NullArgumentException-productRecordTypesisnull- Compliance:
mandatory- This method must be implemented.
-
getProductFormForCreate
ProductForm getProductFormForCreate(Type[] productRecordTypes) throws OperationFailedException, PermissionDeniedException Gets the product form for creating new products. A new form should be requested for each create transaction.- Parameters:
productRecordTypes- array of product record types- Returns:
- the product form
- Throws:
NullArgumentException-productRecordTypesisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException- unable to get form for requested record types- Compliance:
mandatory- This method must be implemented.
-
createProduct
Product createProduct(ProductForm productForm) throws OperationFailedException, PermissionDeniedException Creates a newProduct.- Parameters:
productForm- the form for thisProduct- Returns:
- the new
Product - Throws:
IllegalStateException-productFormalready used in a create transactionInvalidArgumentException- one or more of the form elements is invalidNullArgumentException-productFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-productFormdid not originate fromgetProductFormForCreate()- Compliance:
mandatory- This method must be implemented.
-
canUpdateProducts
boolean canUpdateProducts()Tests if this user can updateProducts. A return of true does not guarantee successful authorization. A return of false indicates that it is known updating aProductwill result in aPERMISSION_DENIED. This is intended as a hint to an application that may not wish to offer update operations to unauthorized users.- Returns:
falseifProductmodification is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
getProductFormForUpdate
ProductForm getProductFormForUpdate(Id productId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets the product form for updating an existing product. A new product form should be requested for each update transaction.- Parameters:
productId- theIdof theProduct- Returns:
- the product form
- Throws:
NotFoundException-productIdis not foundNullArgumentException-productIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
updateProduct
void updateProduct(ProductForm productForm) throws OperationFailedException, PermissionDeniedException Updates an existing product.- Parameters:
productForm- the form containing the elements to be updated- Throws:
IllegalStateException-productFormalready used in an update transactionInvalidArgumentException- the form contains an invalid valueNullArgumentException-productFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-productFormdid not originate fromgetProductFormForUpdate()- Compliance:
mandatory- This method must be implemented.
-
canDeleteProducts
boolean canDeleteProducts()Tests if this user can deleteProductsA return of true does not guarantee successful authorization. A return of false indicates that it is known deleting aProductwill result in aPERMISSION_DENIED. This is intended as a hint to an application that may not wish to offer delete operations to unauthorized users.- Returns:
falseifProductdeletion is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
deleteProduct
void deleteProduct(Id productId) throws NotFoundException, OperationFailedException, PermissionDeniedException Deletes aProduct.- Parameters:
productId- theIdof theProductto remove- Throws:
NotFoundException-productIdnot foundNullArgumentException-productIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
canManageProductAliases
boolean canManageProductAliases()Tests if this user can manageIdaliases forProducts. A return of true does not guarantee successful authorization. A return of false indicates that it is known changing an alias will result in aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer alias operations to an unauthorized user.- Returns:
falseifProductaliasing is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
aliasProduct
void aliasProduct(Id productId, Id aliasId) throws AlreadyExistsException, NotFoundException, OperationFailedException, PermissionDeniedException Adds anIdto aProductfor the purpose of creating compatibility. The primaryIdof theProductis determined by the provider. The newIdperforms as an alias to the primaryId. If the alias is a pointer to another product, it is reassigned to the given productId.- Parameters:
productId- theIdof aProductaliasId- the aliasId- Throws:
AlreadyExistsException-aliasIdis already assignedNotFoundException-productIdnot foundNullArgumentException-productIdoraliasIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-