Search in sources :

Example 1 with CatalogService

use of com.emc.storageos.db.client.model.uimodels.CatalogService in project coprhd-controller by CoprHD.

the class ServiceRunner method createService.

private static CatalogService createService(String name) {
    CatalogService service = new CatalogService();
    service.setLabel(name);
    service.setTitle(name);
    service.setBaseService(name);
    return save(service);
}
Also used : CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService)

Example 2 with CatalogService

use of com.emc.storageos.db.client.model.uimodels.CatalogService in project coprhd-controller by CoprHD.

the class ServiceRunner method dumpOrder.

public static void dumpOrder(Order order) {
    print("Order: %s", order.getId());
    print("  Status: %s", order.getOrderStatus());
    print("  Message: %s", order.getMessage());
    CatalogService service = load(order.getCatalogServiceId(), CatalogService.class);
    print("  Service: %s (%s)", service.getLabel(), service.getBaseService());
    ExecutionState state = load(order.getExecutionStateId(), ExecutionState.class);
    print("  Time: %s -> %s (%.1f s)", state.getStartDate(), state.getEndDate(), (state.getEndDate().getTime() - state.getStartDate().getTime()) / 1000.0);
    List<ExecutionLog> logs = load(state.getLogIds(), ExecutionLog.class);
    Collections.sort(logs, LOG_COMPARATOR);
    if (!logs.isEmpty()) {
        print("  Logs");
        for (ExecutionLog log : logs) {
            print("    - %s\t%s\t%s", log.getDate(), log.getLevel(), log.getMessage());
        }
    }
    List<ExecutionTaskLog> taskLogs = load(state.getTaskLogIds(), ExecutionTaskLog.class);
    Collections.sort(taskLogs, LOG_COMPARATOR);
    if (!taskLogs.isEmpty()) {
        print("  Task Logs");
        for (ExecutionTaskLog log : taskLogs) {
            print("    - %s\t%s\t%s\t%s", log.getDate(), log.getLevel(), log.getMessage(), log.getDetail());
        }
    }
}
Also used : ExecutionState(com.emc.storageos.db.client.model.uimodels.ExecutionState) ExecutionLog(com.emc.storageos.db.client.model.uimodels.ExecutionLog) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) ExecutionTaskLog(com.emc.storageos.db.client.model.uimodels.ExecutionTaskLog)

Example 3 with CatalogService

use of com.emc.storageos.db.client.model.uimodels.CatalogService in project coprhd-controller by CoprHD.

the class CatalogCategoryService method filterServicesByACLs.

/**
 * filter out the services which user don't have access to
 *
 * @param services
 * @return
 */
private List<CatalogService> filterServicesByACLs(List<CatalogService> services) {
    List<CatalogService> filteredCatalogServices = Lists.newArrayList();
    StorageOSUser storageOSUser = getUserFromContext();
    String username = storageOSUser.getName();
    if (isAdministrator(storageOSUser)) {
        log.debug(username + " has SystemAdmin or TenantAdmin Role, can view all categories.");
        filteredCatalogServices.addAll(services);
        return filteredCatalogServices;
    }
    for (CatalogService service : services) {
        if (hasAccess(storageOSUser, service)) {
            filteredCatalogServices.add(service);
        }
    }
    return filteredCatalogServices;
}
Also used : StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService)

Example 4 with CatalogService

use of com.emc.storageos.db.client.model.uimodels.CatalogService in project coprhd-controller by CoprHD.

the class CatalogServiceService method createCatalogService.

/**
 * Creates a new catalog service
 *
 * @param createParam
 *            the parameter to create a new catalog service
 * @prereq none
 * @brief Create Catalog Service
 * @return none
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN })
@Path("")
public CatalogServiceRestRep createCatalogService(CatalogServiceCreateParam createParam) {
    StorageOSUser user = getUserFromContext();
    CatalogCategory parentCatalogCategory = catalogCategoryManager.getCatalogCategoryById(createParam.getCatalogCategory());
    verifyAuthorizedInTenantOrg(uri(parentCatalogCategory.getTenant()), user);
    validateParam(createParam, null);
    CatalogService catalogService = createNewObject(createParam, parentCatalogCategory);
    List<CatalogServiceField> catalogServiceFields = createNewObjectList(catalogService, createParam.getCatalogServiceFields());
    catalogServiceManager.createCatalogService(catalogService, catalogServiceFields);
    auditOpSuccess(OperationTypeEnum.CREATE_CATALOG_SERVICE, catalogService.auditParameters());
    // Refresh Objects
    catalogService = catalogServiceManager.getCatalogServiceById(catalogService.getId());
    catalogServiceFields = catalogServiceManager.getCatalogServiceFields(catalogService.getId());
    ServiceDescriptor serviceDescriptor = getServiceDescriptor(catalogService);
    return map(catalogService, serviceDescriptor, catalogServiceFields);
}
Also used : CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) WorkflowServiceDescriptor(com.emc.sa.catalog.WorkflowServiceDescriptor) ServiceDescriptor(com.emc.sa.descriptor.ServiceDescriptor) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 5 with CatalogService

use of com.emc.storageos.db.client.model.uimodels.CatalogService in project coprhd-controller by CoprHD.

the class CatalogServiceService method getTenantOwner.

@Override
protected URI getTenantOwner(URI id) {
    CatalogService catalogService = queryResource(id);
    CatalogCategory parentCatalogCategory = catalogCategoryManager.getCatalogCategoryById(catalogService.getCatalogCategoryId().getURI());
    return uri(parentCatalogCategory.getTenant());
}
Also used : CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory)

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