Search in sources :

Example 1 with ServiceDescriptor

use of com.emc.sa.descriptor.ServiceDescriptor 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 2 with ServiceDescriptor

use of com.emc.sa.descriptor.ServiceDescriptor in project coprhd-controller by CoprHD.

the class CatalogServiceService method queryBulkResourceReps.

private CatalogServiceBulkRep queryBulkResourceReps(List<URI> ids, CatalogServiceFilter filter) {
    List<CatalogServiceRestRep> catalogServiceRestReps = new ArrayList<CatalogServiceRestRep>();
    List<CatalogServiceAndFields> catalogServicesWithFields = catalogServiceManager.getCatalogServicesWithFields(ids);
    Map<String, ServiceDescriptor> descriptors = getServiceDescriptors();
    for (CatalogServiceAndFields catalogServiceAndField : catalogServicesWithFields) {
        if ((filter == null) || filter.isAccessible(catalogServiceAndField.getCatalogService())) {
            CatalogService service = catalogServiceAndField.getCatalogService();
            ServiceDescriptor descriptor = descriptors.get(service.getBaseService());
            List<CatalogServiceField> serviceFields = catalogServiceAndField.getCatalogServiceFields();
            catalogServiceRestReps.add(map(service, descriptor, serviceFields));
        }
    }
    catalogServiceRestReps = SortedIndexUtils.createSortedList(catalogServiceRestReps.iterator());
    return new CatalogServiceBulkRep(catalogServiceRestReps);
}
Also used : CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) WorkflowServiceDescriptor(com.emc.sa.catalog.WorkflowServiceDescriptor) ServiceDescriptor(com.emc.sa.descriptor.ServiceDescriptor) CatalogServiceBulkRep(com.emc.vipr.model.catalog.CatalogServiceBulkRep) ArrayList(java.util.ArrayList) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) CatalogServiceAndFields(com.emc.storageos.db.client.model.uimodels.CatalogServiceAndFields)

Example 3 with ServiceDescriptor

use of com.emc.sa.descriptor.ServiceDescriptor in project coprhd-controller by CoprHD.

the class OrderService method createNewOrder.

public Order createNewOrder(StorageOSUser user, URI tenantId, OrderCreateParam createParam) {
    ArgValidator.checkFieldNotNull(createParam.getCatalogService(), "catalogService");
    CatalogService service = catalogServiceManager.getCatalogServiceById(createParam.getCatalogService());
    if (service == null) {
        throw APIException.badRequests.orderServiceNotFound(asString(createParam.getCatalogService()));
    }
    final ServiceDescriptor descriptor = ServiceDescriptorUtil.getServiceDescriptorByName(serviceDescriptors, workflowServiceDescriptor, service.getBaseService());
    if (descriptor == null) {
        throw APIException.badRequests.orderServiceDescriptorNotFound(service.getBaseService());
    }
    // Getting and setting workflow document (if its workflow service)
    if (null != descriptor.getWorkflowId()) {
        final String workflowDocument = catalogServiceManager.getWorkflowDocument(service.getBaseService());
        if (null == workflowDocument) {
            throw APIException.badRequests.workflowNotFound(service.getBaseService());
        }
        createParam.setWorkflowDocument(workflowDocument);
    }
    Order order = createNewObject(tenantId, createParam);
    addLockedFields(service.getId(), descriptor, createParam);
    validateParameters(descriptor, createParam.getParameters(), service.getMaxSize());
    List<OrderParameter> orderParams = createOrderParameters(order, createParam, encryptionProvider);
    orderManager.createOrder(order, orderParams, user);
    return order;
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) ServiceDescriptor(com.emc.sa.descriptor.ServiceDescriptor) WorkflowServiceDescriptor(com.emc.sa.catalog.WorkflowServiceDescriptor) OrderParameter(com.emc.storageos.db.client.model.uimodels.OrderParameter) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) URIUtil.asString(com.emc.storageos.db.client.URIUtil.asString)

Example 4 with ServiceDescriptor

use of com.emc.sa.descriptor.ServiceDescriptor in project coprhd-controller by CoprHD.

the class ServiceDescriptorService method getServiceDescriptors.

/**
 * List service descriptors
 *
 * @prereq none
 * @brief List service descriptors
 * @return List of service descriptors
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("")
public ServiceDescriptorList getServiceDescriptors() {
    Collection<ServiceDescriptor> descriptors = this.serviceDescriptors.listDescriptors(Locale.getDefault());
    descriptors.addAll(workflowServiceDescriptor.listDescriptors());
    List<ServiceDescriptorRestRep> serviceDescriptors = Lists.newArrayList();
    for (ServiceDescriptor descriptor : descriptors) {
        serviceDescriptors.add(map(descriptor));
    }
    ServiceDescriptorList serviceDescriptorList = new ServiceDescriptorList(serviceDescriptors);
    return serviceDescriptorList;
}
Also used : ServiceDescriptorRestRep(com.emc.vipr.model.catalog.ServiceDescriptorRestRep) WorkflowServiceDescriptor(com.emc.sa.catalog.WorkflowServiceDescriptor) ServiceDescriptor(com.emc.sa.descriptor.ServiceDescriptor) ServiceDescriptorList(com.emc.vipr.model.catalog.ServiceDescriptorList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with ServiceDescriptor

use of com.emc.sa.descriptor.ServiceDescriptor in project coprhd-controller by CoprHD.

the class ServiceDescriptorTests method testLoadingAndRetrieving.

@Test
public void testLoadingAndRetrieving() throws Exception {
    ZkServiceDescriptors serviceDescriptors = new ZkServiceDescriptors();
    serviceDescriptors.setCoordinatorClient(coordinatorService.getCoordinatorClient());
    serviceDescriptors.start();
    List<ServiceDefinition> services = ServiceDefinitionLoader.load(ServiceDescriptorTests.class.getClassLoader());
    Assert.assertEquals(1, services.size());
    serviceDescriptors.addServices(services);
    ServiceDescriptor descriptor = serviceDescriptors.getDescriptor(Locale.getDefault(), "TestService");
    Assert.assertNotNull(descriptor);
    Assert.assertEquals("TestService", descriptor.getServiceId());
    List<ServiceField> fields = descriptor.getFieldList();
    Assert.assertEquals(3, fields.size());
    Assert.assertEquals("project", fields.get(0).getName());
    Assert.assertEquals("Project", fields.get(0).getLabel());
}
Also used : ServiceDescriptor(com.emc.sa.descriptor.ServiceDescriptor) ServiceField(com.emc.sa.descriptor.ServiceField) ServiceDefinition(com.emc.sa.descriptor.ServiceDefinition)

Aggregations

ServiceDescriptor (com.emc.sa.descriptor.ServiceDescriptor)14 CatalogService (com.emc.storageos.db.client.model.uimodels.CatalogService)8 WorkflowServiceDescriptor (com.emc.sa.catalog.WorkflowServiceDescriptor)7 CatalogServiceField (com.emc.storageos.db.client.model.uimodels.CatalogServiceField)6 ServiceField (com.emc.sa.descriptor.ServiceField)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 ArrayList (java.util.ArrayList)3 CatalogCategory (com.emc.storageos.db.client.model.uimodels.CatalogCategory)2 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 Map (java.util.Map)2 Consumes (javax.ws.rs.Consumes)2 GET (javax.ws.rs.GET)2 ServiceDefinition (com.emc.sa.descriptor.ServiceDefinition)1 ServiceFieldTable (com.emc.sa.descriptor.ServiceFieldTable)1 URIUtil.asString (com.emc.storageos.db.client.URIUtil.asString)1 NamedElement (com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 CatalogServiceAndFields (com.emc.storageos.db.client.model.uimodels.CatalogServiceAndFields)1