use of com.emc.storageos.db.client.model.uimodels.CustomServicesDBPrimitive in project coprhd-controller by CoprHD.
the class CustomServicesPrimitiveManagerImpl method deactivate.
@Override
public <T extends CustomServicesDBPrimitive> void deactivate(final Class<T> clazz, final URI id) {
final CustomServicesDBPrimitive primitive = findById(clazz, id);
if (null == primitive) {
throw APIException.notFound.unableToFindEntityInURL(id);
}
List<NamedElement> workflows = client.customServicesWorkflows().getByPrimitive(id);
if (null != workflows && !workflows.isEmpty()) {
throw APIException.badRequests.resourceHasActiveReferencesWithType(primitive.getClass().getSimpleName(), id, CustomServicesWorkflow.class.getSimpleName());
}
client.delete(primitive);
}
use of com.emc.storageos.db.client.model.uimodels.CustomServicesDBPrimitive in project coprhd-controller by CoprHD.
the class CustomServicesDBHelper method deactivate.
/**
* Deactivate primitive with the given ID
*
* @param clazz The database column family class
* @param primitiveManager The database access component
* @param client The model client
* @param id The ID of the primitive to deactivate
*/
public static void deactivate(final Class<? extends CustomServicesDBPrimitive> clazz, final CustomServicesPrimitiveManager primitiveManager, final ModelClient client, final URI id, final Class<? extends CustomServicesDBResource> resourceType, final Class<? extends CustomServicesDBResource> referencedByresourceType) {
final CustomServicesDBPrimitive primitive = primitiveManager.findById(clazz, id);
if (null == primitive) {
throw APIException.notFound.unableToFindEntityInURL(id);
}
checkNotInUse(client, id, primitive);
client.delete(primitive);
if (!resourceType.isAssignableFrom(CustomServicesDBNoResource.class)) {
final CustomServicesDBResource resource = primitiveManager.findResource(resourceType, primitive.getResource().getURI());
if (null == resource) {
throw APIException.notFound.unableToFindEntityInURL(primitive.getResource().getURI());
}
// check that the resource is not referenced by other primitives
if (null != resource && null == checkResourceNotReferenced(clazz, CustomServicesDBPrimitive.RESOURCE, client, primitive.getResource().getURI(), resource)) {
// Find all the associated inventory files if exist for the DB model and delete the associated inventory files if exist, for
// the resource DB model
deleteReferencedInventoryResources(primitive.getResource().getURI(), primitiveManager, client, referencedByresourceType);
// then delete the resource
client.delete(resource);
}
}
}
Aggregations