Search in sources :

Example 16 with CatalogService

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;
}
Also used : CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) URI(java.net.URI)

Example 17 with CatalogService

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());
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) ModelClient(com.emc.sa.model.dao.ModelClient) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) BaseModelTest(com.emc.sa.model.BaseModelTest) Test(org.junit.Test)

Example 18 with CatalogService

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;
}
Also used : CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 19 with CatalogService

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);
}
Also used : CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) URI(java.net.URI)

Example 20 with CatalogService

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();
}
Also used : CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

CatalogService (com.emc.storageos.db.client.model.uimodels.CatalogService)34 ServiceDescriptor (com.emc.sa.descriptor.ServiceDescriptor)8 URI (java.net.URI)8 NamedURI (com.emc.storageos.db.client.model.NamedURI)7 CatalogCategory (com.emc.storageos.db.client.model.uimodels.CatalogCategory)7 CatalogServiceField (com.emc.storageos.db.client.model.uimodels.CatalogServiceField)6 Path (javax.ws.rs.Path)6 WorkflowServiceDescriptor (com.emc.sa.catalog.WorkflowServiceDescriptor)5 Produces (javax.ws.rs.Produces)5 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 Test (org.junit.Test)4 BaseModelTest (com.emc.sa.model.BaseModelTest)3 ExecutionState (com.emc.storageos.db.client.model.uimodels.ExecutionState)3 Order (com.emc.storageos.db.client.model.uimodels.Order)3 OrderParameter (com.emc.storageos.db.client.model.uimodels.OrderParameter)3 Consumes (javax.ws.rs.Consumes)3 ModelClient (com.emc.sa.model.dao.ModelClient)2 CatalogServiceAndFields (com.emc.storageos.db.client.model.uimodels.CatalogServiceAndFields)2 ArrayList (java.util.ArrayList)2