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);
}
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);
}
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;
}
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;
}
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());
}
Aggregations