Search in sources :

Example 16 with CatalogServiceRestRep

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

the class CatalogServiceUtils method getCatalogService.

public static CatalogServiceRestRep getCatalogService(URI id) {
    ViPRCatalogClient2 catalog = getCatalogClient();
    CatalogServiceRestRep service = null;
    try {
        service = catalog.services().get(id);
    } catch (ViPRHttpException e) {
        if (e.getHttpCode() == 404) {
            service = null;
        } else {
            throw e;
        }
    }
    return service;
}
Also used : ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Example 17 with CatalogServiceRestRep

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

the class AssetOptions method getAssetDependencies.

public List<String> getAssetDependencies(String assetType, URI catalogServiceId) {
    CatalogServiceRestRep catalogService = parent.services().get(catalogServiceId);
    ServiceDescriptorRestRep serviceDescriptor = catalogService.getServiceDescriptor();
    return getAssetDependencies(assetType, serviceDescriptor);
}
Also used : ServiceDescriptorRestRep(com.emc.vipr.model.catalog.ServiceDescriptorRestRep) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep)

Example 18 with CatalogServiceRestRep

use of com.emc.vipr.model.catalog.CatalogServiceRestRep 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);
}
Also used : CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) WorkflowServiceDescriptor(com.emc.sa.catalog.WorkflowServiceDescriptor) ServiceDescriptor(com.emc.sa.descriptor.ServiceDescriptor) CatalogServiceBulkRep(com.emc.vipr.model.catalog.CatalogServiceBulkRep) ArrayList(java.util.ArrayList) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) CatalogServiceAndFields(com.emc.storageos.db.client.model.uimodels.CatalogServiceAndFields)

Example 19 with CatalogServiceRestRep

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

the class CatalogServiceMapper method map.

public static CatalogServiceRestRep map(CatalogService from, ServiceDescriptor descriptor, List<CatalogServiceField> catalogServiceFields) {
    if (from == null) {
        return null;
    }
    CatalogServiceRestRep to = new CatalogServiceRestRep();
    mapDataObjectFields(from, to);
    if (from.getCatalogCategoryId() != null) {
        to.setCatalogCategory(toRelatedResource(ResourceTypeEnum.CATALOG_CATEGORY, from.getCatalogCategoryId().getURI()));
    }
    if (from.getDefaultExecutionWindowId() != null) {
        to.setDefaultExecutionWindow(toRelatedResource(ResourceTypeEnum.EXECUTION_WINDOW, from.getDefaultExecutionWindowId().getURI()));
    }
    if (from.getApprovalRequired() != null) {
        to.setApprovalRequired(from.getApprovalRequired());
    }
    if (from.getExecutionWindowRequired() != null) {
        to.setExecutionWindowRequired(from.getExecutionWindowRequired());
    }
    to.setBaseService(from.getBaseService());
    to.setDescription(from.getDescription());
    to.setImage(from.getImage());
    to.setMaxSize(from.getMaxSize());
    to.setTitle(from.getTitle());
    to.setSortedIndex(from.getSortedIndex());
    if (descriptor != null) {
        to.setServiceDescriptor(ServiceDescriptorMapper.map(descriptor));
    }
    if (catalogServiceFields != null) {
        for (CatalogServiceField catalogServiceField : catalogServiceFields) {
            CatalogServiceFieldRestRep catalogServiceFieldRestRep = new CatalogServiceFieldRestRep();
            mapDataObjectFields(catalogServiceField, catalogServiceFieldRestRep);
            catalogServiceFieldRestRep.setOverride(catalogServiceField.getOverride());
            catalogServiceFieldRestRep.setValue(catalogServiceField.getValue());
            catalogServiceFieldRestRep.setSortedIndex(catalogServiceField.getSortedIndex());
            to.getCatalogServiceFields().add(catalogServiceFieldRestRep);
        }
    }
    if (from.getRecurringAllowed() != null) {
        to.setRecurringAllowed(from.getRecurringAllowed());
    }
    return to;
}
Also used : CatalogServiceFieldRestRep(com.emc.vipr.model.catalog.CatalogServiceFieldRestRep) CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep)

Example 20 with CatalogServiceRestRep

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

the class Approvals method edit.

public static void edit(String id) {
    ViPRCatalogClient2 catalog = getCatalogClient();
    ApprovalRestRep approval = catalog.approvals().get(uri(id));
    if (!approval.getTenant().getId().toString().equals(Security.getUserInfo().getTenant())) {
        Result result = new Unauthorized(MessagesUtils.get("approval.noTenantAccess", approval.getTenant().getId()));
        renderTemplate("errors/401.html", result);
    }
    OrderRestRep order = null;
    ScheduledEventRestRep scheduledEvent = null;
    Date scheduleStartDateTime = null;
    CatalogServiceRestRep service = null;
    if (approval != null) {
        order = getOrder(approval.getOrder());
        if (order != null) {
            service = getCatalogService(order.getCatalogService());
            URI scheduledEventId = order.getScheduledEventId();
            if (scheduledEventId != null) {
                scheduledEvent = getCatalogClient().orders().getScheduledEvent(scheduledEventId);
                String isoDateTimeStr = String.format("%sT%02d:%02d:00Z", scheduledEvent.getScheduleInfo().getStartDate(), scheduledEvent.getScheduleInfo().getHourOfDay(), scheduledEvent.getScheduleInfo().getMinuteOfHour());
                DateTime startDateTime = DateTime.parse(isoDateTimeStr);
                scheduleStartDateTime = startDateTime.toDate();
            }
        }
    }
    render(approval, order, service, scheduledEvent, scheduleStartDateTime);
}
Also used : ApprovalRestRep(com.emc.vipr.model.catalog.ApprovalRestRep) Unauthorized(play.mvc.results.Unauthorized) OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep) ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) ScheduledEventRestRep(com.emc.vipr.model.catalog.ScheduledEventRestRep) URI(java.net.URI) Date(java.util.Date) DateTime(org.joda.time.DateTime) Result(play.mvc.results.Result)

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