Search in sources :

Example 11 with CatalogService

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

the class ExecutionEngineImplTest method testErrorCreatingService.

@Test
public void testErrorCreatingService() {
    ExecutionEngineImpl engine = new ExecutionEngineImpl();
    engine.setModelClient(modelClient);
    engine.setServiceFactory(new ExecutionServiceFactory() {

        @Override
        public ExecutionService createService(Order order, CatalogService catalogService) throws ServiceNotFoundException {
            throw new RuntimeException("Unexpected error");
        }
    });
    Order order = executeOrder(engine, createOrder("ErrorCreatingService"));
    Assert.assertEquals(OrderStatus.ERROR.name(), order.getOrderStatus());
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) ExecutionServiceFactory(com.emc.sa.engine.service.ExecutionServiceFactory) ServiceNotFoundException(com.emc.sa.engine.service.ServiceNotFoundException) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) ExecutionService(com.emc.sa.engine.service.ExecutionService) AbstractExecutionService(com.emc.sa.engine.service.AbstractExecutionService) Test(org.junit.Test)

Example 12 with CatalogService

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

the class CatalogCategoryManagerImpl method updateMatchingServices.

private void updateMatchingServices(CatalogCategory currentCategory, List<CatalogService> services, ServiceDef newService) {
    int pristineService = 0;
    for (CatalogService service : services) {
        if (isMatch(service, newService)) {
            if (pristineService == 0) {
                log.info(String.format("Updating Existing Matching Service %s: for tenant: %s", service.getLabel(), currentCategory.getTenant()));
                ServiceDescriptor descriptor = serviceDescriptors.getDescriptor(Locale.getDefault(), newService.baseService);
                if (descriptor != null) {
                    service.setLabel(StringUtils.deleteWhitespace(StringUtils.defaultString(getMessage(getLabel(newService)), descriptor.getTitle())));
                    service.setTitle(StringUtils.defaultString(getMessage(newService.title), descriptor.getTitle()));
                    service.setDescription(StringUtils.defaultString(getMessage(newService.description), descriptor.getDescription()));
                }
                service.setImage(newService.image);
                catalogServiceManager.updateCatalogService(service, catalogServiceManager.getCatalogServiceFields(service.getId()));
                pristineService++;
            } else {
                log.info(String.format("Removing Duplicate Service %s: for tenant: %s", service.getLabel(), currentCategory.getTenant()));
                catalogServiceManager.deleteCatalogService(service);
            }
        }
    }
}
Also used : ServiceDescriptor(com.emc.sa.descriptor.ServiceDescriptor) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService)

Example 13 with CatalogService

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

the class CatalogServiceManagerImpl method getRecentCatalogServices.

@Deprecated
public List<CatalogService> getRecentCatalogServices(StorageOSUser user) {
    List<CatalogService> catalogServices = Lists.newArrayList();
    List<RecentService> recentServices = getRecentServices(user.getUserName());
    for (RecentService recentService : recentServices) {
        CatalogService catalogService = client.catalogServices().findById(recentService.getCatalogServiceId());
        if (catalogService != null) {
            catalogServices.add(catalogService);
        }
    }
    SortedIndexUtils.sort(catalogServices);
    return catalogServices;
}
Also used : CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) RecentService(com.emc.storageos.db.client.model.uimodels.RecentService)

Example 14 with CatalogService

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

the class CatalogServiceManagerImpl method createCatalogService.

public CatalogService createCatalogService(ServiceDef serviceDef, CatalogCategory parentCategory) {
    CatalogBuilder builder = new CatalogBuilder(client, serviceDescriptors);
    NamedURI namedUri = new NamedURI(parentCategory.getId(), parentCategory.getLabel());
    CatalogService newService = builder.createService(serviceDef, namedUri);
    newService.setSortedIndex(null);
    client.save(newService);
    return newService;
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService)

Example 15 with CatalogService

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

the class CatalogServiceManagerImpl method getCatalogServicesWithFields.

public List<CatalogServiceAndFields> getCatalogServicesWithFields(List<URI> ids) {
    List<CatalogServiceAndFields> catalogServicesWithFields = new ArrayList<CatalogServiceAndFields>();
    if (ids == null) {
        return null;
    }
    for (URI id : ids) {
        CatalogService catalogService = client.catalogServices().findById(id);
        if (catalogService != null) {
            List<CatalogServiceField> fields = getCatalogServiceFields(catalogService.getId());
            SortedIndexUtils.sort(fields);
            CatalogServiceAndFields catalogServiceWithFields = new CatalogServiceAndFields();
            catalogServiceWithFields.setCatalogService(catalogService);
            catalogServiceWithFields.setCatalogServiceFields(fields);
            catalogServicesWithFields.add(catalogServiceWithFields);
        }
    }
    return catalogServicesWithFields;
}
Also used : CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) ArrayList(java.util.ArrayList) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) CatalogServiceAndFields(com.emc.storageos.db.client.model.uimodels.CatalogServiceAndFields)

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