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;
}
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);
}
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);
}
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;
}
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);
}
Aggregations