Class SoftwareManagerService
- java.lang.Object
-
- org.neotropic.kuwaiba.modules.commercial.softman.SoftwareManagerService
-
@Service public class SoftwareManagerService extends Object
The class providing the business logic for this module.- Author:
- Charles Edward Bedon Cortazar <charles.bedon@kuwaiba.org>
-
-
Field Summary
Fields Modifier and Type Field Description static String
RELATIONSHIP_LICENSEHAS
Relationship between the object and the license.
-
Constructor Summary
Constructors Constructor Description SoftwareManagerService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
createLicense(String poolId, String licenseClass, String licenseName, String licenseProduct, String userName)
Creates a license.String
createLicensePool(String poolName, String poolDescription, String poolClass, String userName)
Creates a license pool.void
deleteLicense(String licenseClassName, String licenseId, String userName)
Deletes a license and delete its association with the related inventory objects.These objects will remain untouched.void
deleteLicensePool(String poolId, String poolClass, String userName)
Deletes a license pool.List<BusinessObjectLight>
getAllLicenses()
Retrieves the licenses list.List<ClassMetadataLight>
getAllLicenseTypes()
Gets all available license type, which are basically the non-abstract subclasses ofGenericSoftwareAsset
.List<BusinessObjectLight>
getAllProducts()
Gets all available products.BusinessObject
getLicense(String licenseClass, String licenseId)
Get license properties.InventoryObjectPool
getLicensePool(String poolId, String poolClass)
Gets the license pool properties.List<InventoryObjectPool>
getLicensePools()
Retrieves the license pools list.List<BusinessObjectLight>
getLicensesInPool(String poolId, int limit)
Gets the licenses inside a license pool.void
relateObjectToLicense(String licenseClass, String licenseId, String objectClass, String objectId)
Relates an object or a set of objects to an existing software or hardware license.void
releaseLicense(String licenseClassName, String licenseId)
Releases all the relationships with the given names associated to the license provided.void
releaseRelationship(String sourceObjectClass, String sourceObjectId, String targetObjectId)
Releases an object from another object whose relationship is "licenseHas".
-
-
-
Field Detail
-
RELATIONSHIP_LICENSEHAS
public static String RELATIONSHIP_LICENSEHAS
Relationship between the object and the license.
-
-
Method Detail
-
relateObjectToLicense
public void relateObjectToLicense(String licenseClass, String licenseId, String objectClass, String objectId) throws InvalidArgumentException, MetadataObjectNotFoundException, BusinessObjectNotFoundException
Relates an object or a set of objects to an existing software or hardware license.- Parameters:
licenseClass
- The class of the license to be created (temporarily).licenseId
- The id of the license.objectClass
- The class of the object.objectId
- The id of the object.- Throws:
InvalidArgumentException
- IflicenseClass
is not a subclass of GenericSoftwareAsset.MetadataObjectNotFoundException
- If any of the classes provided do not exist.BusinessObjectNotFoundException
- If the business object provided does not exist.
-
getAllLicenseTypes
public List<ClassMetadataLight> getAllLicenseTypes() throws MetadataObjectNotFoundException
Gets all available license type, which are basically the non-abstract subclasses ofGenericSoftwareAsset
.- Returns:
- The list of available license types.
- Throws:
MetadataObjectNotFoundException
- If the classGenericSoftwareAsset
has not been defined.
-
getAllProducts
public List<BusinessObjectLight> getAllProducts() throws MetadataObjectNotFoundException
Gets all available products.- Returns:
- The list of available products.
- Throws:
MetadataObjectNotFoundException
- If the classSoftwareType
has not been defined.
-
getAllLicenses
public List<BusinessObjectLight> getAllLicenses() throws MetadataObjectNotFoundException
Retrieves the licenses list.- Returns:
- The available licenses.
- Throws:
MetadataObjectNotFoundException
- If the classGenericSoftwareAsset
has not been defined.
-
getLicensesInPool
public List<BusinessObjectLight> getLicensesInPool(String poolId, int limit) throws ApplicationObjectNotFoundException, InvalidArgumentException
Gets the licenses inside a license pool.- Parameters:
poolId
- The pool id.limit
- The results limit per page. Use -1 to retrieve all.- Returns:
- The licenses list.
- Throws:
ApplicationObjectNotFoundException
- If the pool can't be found.InvalidArgumentException
- If the pool id is null or the result pool does not have uuid.
-
createLicense
public String createLicense(String poolId, String licenseClass, String licenseName, String licenseProduct, String userName) throws MetadataObjectNotFoundException, InvalidArgumentException, ApplicationObjectNotFoundException
Creates a license.- Parameters:
poolId
- The parent pool id.licenseClass
- The class name of the license to be created (temporarily).licenseName
- The license name.licenseProduct
- The license product.userName
- The user name of the session.- Returns:
- The id of the newly created license.
- Throws:
MetadataObjectNotFoundException
- IflicenseClass
is not a subclass of GenericSoftwareAsset.InvalidArgumentException
- If the pool id is null or the result pool does not have uuid.ApplicationObjectNotFoundException
- If the parent pool can't be found.
-
deleteLicense
public void deleteLicense(String licenseClassName, String licenseId, String userName) throws ApplicationObjectNotFoundException, BusinessObjectNotFoundException, MetadataObjectNotFoundException, OperationNotPermittedException, InvalidArgumentException
Deletes a license and delete its association with the related inventory objects.These objects will remain untouched.- Parameters:
licenseClassName
- The license class name.licenseId
- The license id.userName
- The user name of the session.- Throws:
ApplicationObjectNotFoundException
- If the license activity log could not be found.BusinessObjectNotFoundException
- If the license could not be found.MetadataObjectNotFoundException
- If the license class could not be found.OperationNotPermittedException
- If the object could not be deleted because there's some business rules that avoids it or it has incoming relationships.InvalidArgumentException
- If the id is null.
-
releaseLicense
public void releaseLicense(String licenseClassName, String licenseId) throws MetadataObjectNotFoundException, BusinessObjectNotFoundException, InvalidArgumentException
Releases all the relationships with the given names associated to the license provided.- Parameters:
licenseClassName
- The license class name.licenseId
- The license id.- Throws:
MetadataObjectNotFoundException
- If the license class name could not be found.BusinessObjectNotFoundException
- If the license id could not be found.InvalidArgumentException
- If any of the relationships is now allowed according to the defined data model.
-
releaseRelationship
public void releaseRelationship(String sourceObjectClass, String sourceObjectId, String targetObjectId) throws BusinessObjectNotFoundException, MetadataObjectNotFoundException, InvalidArgumentException
Releases an object from another object whose relationship is "licenseHas".- Parameters:
sourceObjectClass
- The source object class.sourceObjectId
- The source object id.targetObjectId
- The target object id. The object we want to be released from.- Throws:
MetadataObjectNotFoundException
- If the object class provided can't be found.InvalidArgumentException
- If sourceObjectId or targetObjectId are null.BusinessObjectNotFoundException
- If any of the objects can't be found.
-
getLicense
public BusinessObject getLicense(String licenseClass, String licenseId) throws MetadataObjectNotFoundException, InvalidArgumentException, BusinessObjectNotFoundException
Get license properties.- Parameters:
licenseClass
- The license class. Must be subclass of GenericSoftwareAsset.licenseId
- The license id.- Returns:
- The license properties.
- Throws:
MetadataObjectNotFoundException
- If the license class can't be found.InvalidArgumentException
- If the license id can't be found.BusinessObjectNotFoundException
- If the requested license can't be found.
-
createLicensePool
public String createLicensePool(String poolName, String poolDescription, String poolClass, String userName) throws MetadataObjectNotFoundException, ApplicationObjectNotFoundException
Creates a license pool.- Parameters:
poolName
- The pool name.poolDescription
- The pool description.poolClass
- The pool class. What kind of objects can this pool contain? Must be subclass of GenericSoftwareAsset.userName
- The user name of the session.- Returns:
- The id of the newly created license pool.
- Throws:
MetadataObjectNotFoundException
- If poolClass is not a valid subclass of GenericSoftwareAsset.ApplicationObjectNotFoundException
- If the pool activity log can't be found.
-
deleteLicensePool
public void deleteLicensePool(String poolId, String poolClass, String userName) throws ApplicationObjectNotFoundException, OperationNotPermittedException, MetadataObjectNotFoundException, InvalidArgumentException
Deletes a license pool.- Parameters:
poolId
- The pool id.poolClass
- The pool class.userName
- The user name of the session.- Throws:
ApplicationObjectNotFoundException
- If the pool can't be found.OperationNotPermittedException
- If any of the objects in the pool can't be deleted because it's not a business related instance (it's more a security restriction).MetadataObjectNotFoundException
- If poolClass is not a valid subclass of GenericSoftwareAsset.InvalidArgumentException
- If the pool id is null or the result pool does not have uuid.
-
getLicensePool
public InventoryObjectPool getLicensePool(String poolId, String poolClass) throws ApplicationObjectNotFoundException, InvalidArgumentException, MetadataObjectNotFoundException
Gets the license pool properties.- Parameters:
poolId
- The pool id.poolClass
- The pool class.- Returns:
- The pool properties.
- Throws:
ApplicationObjectNotFoundException
- If the pool can't be found.InvalidArgumentException
- If the pool id is null or the result pool does not have uuid.MetadataObjectNotFoundException
- If poolClass is not a valid subclass of GenericSoftwareAsset.
-
getLicensePools
public List<InventoryObjectPool> getLicensePools() throws InvalidArgumentException
Retrieves the license pools list.- Returns:
- The available license pools.
- Throws:
InvalidArgumentException
- If the pool id is null or the result pool does not have uuid.
-
-