Search in sources :

Example 11 with CustomServicesWorkflow

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

the class CatalogServiceManagerImpl method getCatalogServiceById.

public CatalogService getCatalogServiceById(URI id) {
    if (id == null) {
        return null;
    }
    CatalogService catalogService = client.catalogServices().findById(id);
    // For "Test Workflow" CustomServiceWorkflow ID is set as CatalogService.
    if (null == catalogService && id.toString().startsWith(CustomServicesWorkflow.ID_PREFIX)) {
        final CustomServicesWorkflow customServicesWorkflow = customServicesWorkflowManager.getById(id);
        if (customServicesWorkflow == null) {
            log.debug(String.format("Unable to get Catalog Service by Id [%s]. Workflow may have been deleted.", id));
            throw new IllegalStateException("Unable to get Catalog Service by Id" + id + "Workflow may have been deleted.");
        }
        catalogService = new CatalogService();
        catalogService.setId(id);
        catalogService.setTitle(customServicesWorkflow.getLabel());
        catalogService.setDescription(customServicesWorkflow.getLabel());
        catalogService.setImage("icon_orchestration.png");
        catalogService.setBaseService(URIUtil.asString(id));
    }
    return catalogService;
}
Also used : CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) CustomServicesWorkflow(com.emc.storageos.db.client.model.uimodels.CustomServicesWorkflow)

Example 12 with CustomServicesWorkflow

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

the class CustomServicesWorkflowManagerImpl method getByNameOrId.

@Override
public List<CustomServicesWorkflow> getByNameOrId(final String name) {
    if (null == name) {
        return null;
    }
    final List<CustomServicesWorkflow> workflowList = Lists.newArrayList();
    try {
        // first check if id is passed
        if (URIUtil.isValid(new URI(name))) {
            CustomServicesWorkflow csWF = client.customServicesWorkflows().findById(URIUtil.uri(name));
            if (csWF != null) {
                workflowList.add(csWF);
                return workflowList;
            }
        }
    } catch (final URISyntaxException e) {
        // the passed value is not id.
        log.debug("URISyntaxException : uri passed is " + name);
        log.debug("Moving on to get by label");
    }
    final List<NamedElement> workflows = client.findByLabel(CustomServicesWorkflow.class, name);
    final ImmutableList.Builder<URI> ids = ImmutableList.<URI>builder();
    for (final NamedElement workflow : workflows) {
        if (workflow.getName().equals(name)) {
            ids.add(workflow.getId());
        }
    }
    return client.findByIds(CustomServicesWorkflow.class, ids.build());
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) CustomServicesWorkflow(com.emc.storageos.db.client.model.uimodels.CustomServicesWorkflow) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)

Example 13 with CustomServicesWorkflow

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

the class DefaultExecutionServiceFactory method createService.

@Override
public ExecutionService createService(Order order, CatalogService catalogService) throws ServiceNotFoundException {
    String serviceName;
    if (null == catalogService) {
        // This is case of "Test Orders".
        // Getting service name from workflow (as there is no catalog service)
        final CustomServicesWorkflow customServicesWorkflow = customServicesWorkflowManager.getById(order.getCatalogServiceId());
        serviceName = customServicesWorkflow.getLabel();
    } else {
        serviceName = catalogService.getBaseService();
    }
    Class<? extends ExecutionService> serviceClass = services.get(serviceName);
    if (serviceClass == null) {
        // For these services there is only one executor - CustomServicesService
        if (isWorkflowService(serviceName)) {
            serviceClass = services.get("CustomServicesService");
        } else {
            throw new ServiceNotFoundException(String.format("Service '%s' not found", serviceName));
        }
    }
    return newInstance(serviceClass, serviceName);
}
Also used : CustomServicesWorkflow(com.emc.storageos.db.client.model.uimodels.CustomServicesWorkflow)

Example 14 with CustomServicesWorkflow

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

the class WorkflowHelper method create.

/**
 * Create a workflow definition
 *
 * @throws IOException
 * @throws JsonMappingException
 * @throws JsonGenerationException
 */
public static CustomServicesWorkflow create(final CustomServicesWorkflowDocument document) throws JsonGenerationException, JsonMappingException, IOException {
    final CustomServicesWorkflow workflow = new CustomServicesWorkflow();
    workflow.setId(URIUtil.createId(CustomServicesWorkflow.class));
    if (StringUtils.isNotBlank(document.getName())) {
        workflow.setLabel(document.getName().trim());
    } else {
        throw APIException.badRequests.requiredParameterMissingOrEmpty("name");
    }
    workflow.setDescription(document.getDescription());
    workflow.setSteps(toStepsJson(document.getSteps()));
    workflow.setPrimitives(getPrimitives(document));
    return workflow;
}
Also used : CustomServicesWorkflow(com.emc.storageos.db.client.model.uimodels.CustomServicesWorkflow)

Example 15 with CustomServicesWorkflow

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

the class WorkflowHelper method importWorkflow.

/**
 * @param client
 * @param wfDirectory
 * @param value
 * @throws IOException
 * @throws JsonMappingException
 * @throws JsonGenerationException
 */
private static void importWorkflow(final CustomServicesWorkflowRestRep workflow, final ModelClient client, final WFDirectory wfDirectory) throws JsonGenerationException, JsonMappingException, IOException {
    final CustomServicesWorkflow dbWorkflow = new CustomServicesWorkflow();
    dbWorkflow.setId(workflow.getId());
    dbWorkflow.setLabel(findImportName(workflow.getName(), client));
    dbWorkflow.setInactive(false);
    dbWorkflow.setDescription(workflow.getDocument().getDescription());
    dbWorkflow.setSteps(toStepsJson(workflow.getDocument().getSteps()));
    dbWorkflow.setPrimitives(getPrimitives(workflow.getDocument()));
    client.save(dbWorkflow);
    if (null != wfDirectory.getId()) {
        wfDirectory.addWorkflows(Collections.singleton(workflow.getId()));
        client.save(wfDirectory);
    }
}
Also used : CustomServicesWorkflow(com.emc.storageos.db.client.model.uimodels.CustomServicesWorkflow)

Aggregations

CustomServicesWorkflow (com.emc.storageos.db.client.model.uimodels.CustomServicesWorkflow)18 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)6 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 IOException (java.io.IOException)4 POST (javax.ws.rs.POST)4 NamedElement (com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)3 URI (java.net.URI)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)2 CustomServicesWorkflowDocument (com.emc.storageos.model.customservices.CustomServicesWorkflowDocument)2 Step (com.emc.storageos.model.customservices.CustomServicesWorkflowDocument.Step)2 CustomServicesWorkflowRestRep (com.emc.storageos.model.customservices.CustomServicesWorkflowRestRep)2 ArrayList (java.util.ArrayList)2 ServiceDescriptor (com.emc.sa.descriptor.ServiceDescriptor)1 ResourcePackage (com.emc.sa.workflow.CustomServicesWorkflowPackage.ResourcePackage)1 ValidationHelper (com.emc.sa.workflow.ValidationHelper)1 CatalogService (com.emc.storageos.db.client.model.uimodels.CatalogService)1 CustomServicesPrimitiveResourceRestRep (com.emc.storageos.model.customservices.CustomServicesPrimitiveResourceRestRep)1 CustomServicesPrimitiveRestRep (com.emc.storageos.model.customservices.CustomServicesPrimitiveRestRep)1 CustomServicesValidationResponse (com.emc.storageos.model.customservices.CustomServicesValidationResponse)1