use of com.emc.storageos.db.client.model.uimodels.CatalogService in project coprhd-controller by CoprHD.
the class CatalogServiceFinder method findByBaseService.
public List<CatalogService> findByBaseService(final String baseServiceName) {
log.debug("Finding catalog services for base service {}", baseServiceName);
final List<CatalogService> results = Lists.newArrayList();
if (null != baseServiceName) {
final List<URI> ids = client.findAllIds(clazz);
if (null != ids) {
final List<CatalogService> allCatalogServices = findByIds(ids);
for (CatalogService cs : allCatalogServices) {
if (baseServiceName.equals(cs.getBaseService())) {
log.debug("Found service: {}", cs.getId());
results.add(cs);
}
}
}
}
return results;
}
use of com.emc.storageos.db.client.model.uimodels.CatalogService in project coprhd-controller by CoprHD.
the class CatalogServiceTest method testFindByCatalogCategory.
@Test
public void testFindByCatalogCategory() {
_logger.info("Starting FindByCatalogCategory test");
ModelClient modelClient = getModelClient();
CatalogCategory root = createCategoryWithLabel("rooty");
modelClient.save(root);
CatalogService s1 = createWithLabel("s1");
s1.setCatalogCategoryId(new NamedURI(root.getId(), root.getLabel()));
modelClient.save(s1);
CatalogCategory c1 = createCategoryWithLabel("asdf");
c1.setCatalogCategoryId(new NamedURI(root.getId(), root.getLabel()));
modelClient.save(c1);
CatalogService s2 = createWithLabel("s2");
s2.setCatalogCategoryId(new NamedURI(c1.getId(), c1.getLabel()));
modelClient.save(s2);
CatalogService s3 = createWithLabel("s3");
s3.setCatalogCategoryId(new NamedURI(c1.getId(), c1.getLabel()));
modelClient.save(s3);
CatalogCategory c2 = createCategoryWithLabel("asdf2");
c2.setCatalogCategoryId(new NamedURI(root.getId(), root.getLabel()));
modelClient.save(c2);
CatalogService s4 = createWithLabel("s4");
s4.setCatalogCategoryId(new NamedURI(c2.getId(), c2.getLabel()));
modelClient.save(s4);
CatalogService s5 = createWithLabel("s5");
s5.setCatalogCategoryId(new NamedURI(c2.getId(), c2.getLabel()));
modelClient.save(s5);
CatalogService s6 = createWithLabel("s6");
s6.setCatalogCategoryId(new NamedURI(c2.getId(), c2.getLabel()));
modelClient.save(s6);
List<CatalogService> results = modelClient.catalogServices().findByCatalogCategory(root.getId());
Assert.assertNotNull(results);
Assert.assertEquals(1, results.size());
results = modelClient.catalogServices().findByCatalogCategory(c1.getId());
Assert.assertNotNull(results);
Assert.assertEquals(2, results.size());
results = modelClient.catalogServices().findByCatalogCategory(c2.getId());
Assert.assertNotNull(results);
Assert.assertEquals(3, results.size());
}
use of com.emc.storageos.db.client.model.uimodels.CatalogService in project coprhd-controller by CoprHD.
the class BasePermissionsHelper method checkForActiveCatalogServiceAclsUsingUserGroup.
/**
* Checks whether the given the user group is present the any of the
* catalog service acls or not
*
* @param label to check if any tenants role-assignments uses user group or not.
* @return set of URI's catalog services that uses the user group.
*/
public Set<URI> checkForActiveCatalogServiceAclsUsingUserGroup(String label) {
Set<URI> catalogServiceUsingUserGroup = null;
// Find all the configured Catalog service IDs based on the type.
List<URI> catalogServiceURIList = _dbClient.queryByType(CatalogService.class, true);
if (catalogServiceURIList == null || !catalogServiceURIList.iterator().hasNext()) {
_log.warn("There are no catalog service configured.");
return catalogServiceUsingUserGroup;
}
// Find all the configured Catalog service objects based on the given list of IDs.
List<CatalogService> catalogServices = _dbClient.queryObject(CatalogService.class, catalogServiceURIList);
if (CollectionUtils.isEmpty(catalogServices)) {
_log.error("Could not find the Catalog service objects for the Ids {}", catalogServiceURIList.toString());
return catalogServiceUsingUserGroup;
}
catalogServiceUsingUserGroup = new HashSet<URI>();
for (CatalogService catalogService : catalogServices) {
if (catalogService == null) {
_log.info("Invalid catalog service");
continue;
}
if (CollectionUtils.isEmpty(catalogService.getAcls())) {
_log.debug("ACLs not configured for Catalog service {}", catalogService.getLabel());
continue;
}
Set<String> aclKeys = catalogService.getAcls().keySet();
if (checkUserGroupWithPermissionKeys(label, aclKeys)) {
catalogServiceUsingUserGroup.add(catalogService.getId());
}
}
return catalogServiceUsingUserGroup;
}
use of com.emc.storageos.db.client.model.uimodels.CatalogService in project coprhd-controller by CoprHD.
the class AllowRecurringSchedulerMigration method enableScheduler.
protected void enableScheduler(List<String> allowedCatalogServices) {
List<URI> catalogServiceIds = dbClient.queryByType(CatalogService.class, true);
int cnt = 0;
for (URI catalogServiceId : catalogServiceIds) {
CatalogService catalogService = dbClient.queryObject(CatalogService.class, catalogServiceId);
String baseService = catalogService.getBaseService();
if (allowedCatalogServices.contains(baseService)) {
log.info("Allow recurring for catalog service {}", catalogService.getTitle());
catalogService.setRecurringAllowed(true);
dbClient.updateObject(catalogService);
cnt++;
}
}
log.info("Completed updating recurringAllowed flag for catalog services - {}", cnt);
}
use of com.emc.storageos.db.client.model.uimodels.CatalogService in project coprhd-controller by CoprHD.
the class CatalogServiceService method deactivateCatalogService.
/**
* Deactivates the catalog service
*
* @param id the URN of an catalog service to be deactivated
* @brief Deactivate Catalog Service
* @return OK if deactivation completed successfully
* @throws DatabaseException when a DB error occurs
*/
@POST
@Path("/{id}/deactivate")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
public Response deactivateCatalogService(@PathParam("id") URI id) throws DatabaseException {
CatalogService catalogService = queryResource(id);
ArgValidator.checkEntity(catalogService, id, true);
catalogServiceManager.deleteCatalogService(catalogService);
auditOpSuccess(OperationTypeEnum.DELETE_CATALOG_SERVICE, catalogService.auditParameters());
return Response.ok().build();
}
Aggregations