Search in sources :

Example 26 with CatalogServiceRestRep

use of com.emc.vipr.model.catalog.CatalogServiceRestRep in project coprhd-controller by CoprHD.

the class CatalogApi method invokeByPath.

public static void invokeByPath(String sp1, String sp2, String sp3, String sp4, String sp5) {
    CatalogCategoryRestRep catalog = CatalogCategoryUtils.getRootCategory();
    DataObjectRestRep results = findCategoryOrService(catalog, sp1, sp2, sp3, sp4, sp5);
    if (results != null && results instanceof CatalogServiceRestRep) {
        CatalogServiceRestRep catalogService = (CatalogServiceRestRep) results;
        runCatalogService(catalogService.getId().toString());
    } else {
        notFound();
    }
}
Also used : DataObjectRestRep(com.emc.storageos.model.DataObjectRestRep) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) CatalogCategoryRestRep(com.emc.vipr.model.catalog.CatalogCategoryRestRep)

Example 27 with CatalogServiceRestRep

use of com.emc.vipr.model.catalog.CatalogServiceRestRep in project coprhd-controller by CoprHD.

the class CatalogApi method createAndValidateOrder.

private static OrderCreateParam createAndValidateOrder(String serviceId) {
    CatalogServiceRestRep service = CatalogServiceUtils.getCatalogService(uri(serviceId));
    ServiceDescriptorRestRep descriptor = service.getServiceDescriptor();
    // Filter out actual Service Parameters
    Map<String, String> parameters = parseParameters(service, descriptor);
    if (Validation.hasErrors()) {
        response.status = HttpStatus.SC_BAD_REQUEST;
        renderApi(getValidationErrors());
    }
    // Create request and perform selection
    OrderCreateParam order = createOrder(service, descriptor, parameters);
    return order;
}
Also used : ServiceDescriptorRestRep(com.emc.vipr.model.catalog.ServiceDescriptorRestRep) OrderCreateParam(com.emc.vipr.model.catalog.OrderCreateParam) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep)

Example 28 with CatalogServiceRestRep

use of com.emc.vipr.model.catalog.CatalogServiceRestRep in project coprhd-controller by CoprHD.

the class CatalogApi method browseCatalog.

public static void browseCatalog(String sp1, String sp2, String sp3, String sp4, String sp5) {
    CatalogCategoryRestRep catalogCategory = CatalogCategoryUtils.getRootCategory();
    DataObjectRestRep result = findCategoryOrService(catalogCategory, sp1, sp2, sp3, sp4, sp5);
    if (result instanceof CatalogCategoryRestRep) {
        renderApi(newCategoryInfo((CatalogCategoryRestRep) result));
    } else if (result instanceof CatalogServiceRestRep) {
        renderApi(newServiceInfo((CatalogServiceRestRep) result));
    }
}
Also used : DataObjectRestRep(com.emc.storageos.model.DataObjectRestRep) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) CatalogCategoryRestRep(com.emc.vipr.model.catalog.CatalogCategoryRestRep)

Example 29 with CatalogServiceRestRep

use of com.emc.vipr.model.catalog.CatalogServiceRestRep in project coprhd-controller by CoprHD.

the class Orders method addParametersToFlash.

@Util
private static void addParametersToFlash(OrderRestRep order) {
    CatalogServiceRestRep service = CatalogServiceUtils.getCatalogService(uri(order.getCatalogService().getId().toString()));
    HashMap<String, String> tableParams = new HashMap<String, String>();
    if (service == null || service.getServiceDescriptor() == null) {
        flash.error("order.submitFailedWithDetail", " The Workflow or Service Descriptor is deleted");
        Logger.error("Service Descriptor not found");
        throw new IllegalStateException("No Service Descriptor found. Might be Customservices Workflow  is deleted ");
    }
    for (ServiceItemRestRep item : service.getServiceDescriptor().getItems()) {
        if (item.isTable()) {
            for (ServiceFieldRestRep tableItem : ((ServiceFieldTableRestRep) item).getItems()) {
                tableParams.put(tableItem.getName(), item.getName());
            }
        }
    }
    for (Parameter parameter : order.getParameters()) {
        // Do not add encrypted values to the flash scope
        if (parameter.isEncrypted()) {
            continue;
        }
        List<String> values = TextUtils.parseCSV(parameter.getValue());
        for (int i = 0; i < values.size(); i++) {
            String value = values.get(i);
            String name = parameter.getLabel();
            if (tableParams.containsKey(name)) {
                name = tableParams.get(name) + "[" + i + "]." + name;
            }
            flash.put(name, value);
        }
    }
}
Also used : ServiceItemRestRep(com.emc.vipr.model.catalog.ServiceItemRestRep) ServiceFieldTableRestRep(com.emc.vipr.model.catalog.ServiceFieldTableRestRep) HashMap(java.util.HashMap) ServiceFieldRestRep(com.emc.vipr.model.catalog.ServiceFieldRestRep) Parameter(com.emc.vipr.model.catalog.Parameter) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) BourneUtil(util.BourneUtil) TaskUtil(com.emc.vipr.client.core.impl.TaskUtil) Util(play.mvc.Util)

Aggregations

CatalogServiceRestRep (com.emc.vipr.model.catalog.CatalogServiceRestRep)29 ServiceDescriptorRestRep (com.emc.vipr.model.catalog.ServiceDescriptorRestRep)7 CatalogCategoryRestRep (com.emc.vipr.model.catalog.CatalogCategoryRestRep)6 ViPRCatalogClient2 (com.emc.vipr.client.ViPRCatalogClient2)4 ApprovalRestRep (com.emc.vipr.model.catalog.ApprovalRestRep)3 CatalogServiceFieldRestRep (com.emc.vipr.model.catalog.CatalogServiceFieldRestRep)3 OrderRestRep (com.emc.vipr.model.catalog.OrderRestRep)3 ServiceFieldRestRep (com.emc.vipr.model.catalog.ServiceFieldRestRep)3 Util (play.mvc.Util)3 CatalogServiceField (com.emc.storageos.db.client.model.uimodels.CatalogServiceField)2 DataObjectRestRep (com.emc.storageos.model.DataObjectRestRep)2 TaskUtil (com.emc.vipr.client.core.impl.TaskUtil)2 Parameter (com.emc.vipr.model.catalog.Parameter)2 URI (java.net.URI)2 HashMap (java.util.HashMap)2 DateTime (org.joda.time.DateTime)2 BourneUtil (util.BourneUtil)2 WorkflowServiceDescriptor (com.emc.sa.catalog.WorkflowServiceDescriptor)1 ServiceDescriptor (com.emc.sa.descriptor.ServiceDescriptor)1 CatalogService (com.emc.storageos.db.client.model.uimodels.CatalogService)1