Search in sources :

Example 16 with CustomServicesWorkflow

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

the class CustomServicesWorkflowFinder method prepareNamedElementFromURI.

private List<NamedElement> prepareNamedElementFromURI(final List<URI> ids) {
    final Iterator<CustomServicesWorkflow> it = client.findAllFields(clazz, ids, ImmutableList.<String>builder().add("label").build());
    final List<NamedElement> results = new ArrayList<NamedElement>();
    while (it.hasNext()) {
        final CustomServicesWorkflow element = it.next();
        results.add(NamedElement.createElement(element.getId(), element.getLabel()));
    }
    return results;
}
Also used : ArrayList(java.util.ArrayList) CustomServicesWorkflow(com.emc.storageos.db.client.model.uimodels.CustomServicesWorkflow) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)

Example 17 with CustomServicesWorkflow

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

the class WorkflowServiceDescriptor method listDescriptors.

// This method will only return service descriptors for PUBLISHED workflows
public Collection<ServiceDescriptor> listDescriptors() {
    List<ServiceDescriptor> wfServiceDescriptors = new ArrayList<>();
    List<NamedElement> oeElements = customServicesWorkflowManager.listByStatus(CustomServicesWorkflowStatus.PUBLISHED);
    if (null != oeElements) {
        CustomServicesWorkflow oeWorkflow;
        for (NamedElement oeElement : oeElements) {
            oeWorkflow = customServicesWorkflowManager.getById(oeElement.getId());
            wfServiceDescriptors.add(mapWorkflowToServiceDescriptor(oeWorkflow));
        }
    }
    return wfServiceDescriptors;
}
Also used : ServiceDescriptor(com.emc.sa.descriptor.ServiceDescriptor) ArrayList(java.util.ArrayList) CustomServicesWorkflow(com.emc.storageos.db.client.model.uimodels.CustomServicesWorkflow) NamedElement(com.emc.storageos.db.client.constraint.NamedElementQueryResultList.NamedElement)

Example 18 with CustomServicesWorkflow

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

the class CustomServicesService method getStepHash.

private ImmutableMap<String, Step> getStepHash(final URI uri) throws Exception {
    final String raw;
    raw = ExecutionUtils.currentContext().getOrder().getWorkflowDocument();
    if (null == raw) {
        throw InternalServerErrorException.internalServerErrors.customServiceExecutionFailed("Invalid custom service.  Workflow document cannot be null");
    }
    final CustomServicesWorkflowDocument obj = WorkflowHelper.toWorkflowDocument(raw);
    final List<CustomServicesWorkflow> wfs = customServicesWorkflowManager.getByNameOrId(obj.getName());
    if (wfs == null || wfs.isEmpty() || wfs.size() > 1) {
        throw InternalServerErrorException.internalServerErrors.customServiceExecutionFailed("Workflow list is null or empty or more than one workflow per Workflow name:" + obj.getName());
    }
    if (wfs.get(0) == null || StringUtils.isEmpty(wfs.get(0).getState())) {
        throw InternalServerErrorException.internalServerErrors.customServiceExecutionFailed("Workflow state is null or empty for workflow:" + obj.getName());
    }
    if (wfs.get(0).getState().equals(CustomServicesWorkflow.CustomServicesWorkflowStatus.NONE.toString()) || wfs.get(0).getState().equals(CustomServicesWorkflow.CustomServicesWorkflowStatus.INVALID.toString())) {
        throw InternalServerErrorException.internalServerErrors.customServiceExecutionFailed("Workflow state is not valid. Cannot run workflow" + obj.getName() + "State:" + wfs.get(0).getState());
    }
    final List<Step> steps = obj.getSteps();
    final ImmutableMap.Builder<String, Step> builder = ImmutableMap.builder();
    for (final Step step : steps) {
        builder.put(step.getId(), step);
    }
    final ImmutableMap<String, Step> stepsHash = builder.build();
    ExecutionUtils.currentContext().logInfo("customServicesService.status", obj.getName());
    return stepsHash;
}
Also used : CustomServicesWorkflowDocument(com.emc.storageos.model.customservices.CustomServicesWorkflowDocument) CustomServicesWorkflow(com.emc.storageos.db.client.model.uimodels.CustomServicesWorkflow) Step(com.emc.storageos.model.customservices.CustomServicesWorkflowDocument.Step) ImmutableMap(com.google.common.collect.ImmutableMap)

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