use of com.emc.storageos.model.RestLinkRep in project coprhd-controller by CoprHD.
the class DbObjectMapper method mapDataObjectFields.
public static void mapDataObjectFields(DataObject from, DataObjectRestRep to) {
to.setLink(new RestLinkRep("self", RestLinkFactory.newLink(from)));
mapDataObjectFieldsNoLink(from, to);
}
use of com.emc.storageos.model.RestLinkRep in project coprhd-controller by CoprHD.
the class WFDirectoryService method map.
private WFDirectoryRestRep map(WFDirectory from) {
WFDirectoryRestRep to = new WFDirectoryRestRep();
mapDataObjectFields(from, to);
if (null != from.getParent()) {
if (from.getParent().equals(getRootLevelParentId())) {
// Removing the dummy parent Id that was set during create
to.setParent(null);
} else {
to.setParent(new RelatedResourceRep(from.getParent(), new RestLinkRep("self", RestLinkFactory.newLink(ResourceTypeEnum.WF_DIRECTORY, from.getParent()))));
}
}
if (null != from.getWorkflows()) {
to.setWorkflows(StringSetUtil.stringSetToUriList(from.getWorkflows()));
}
return to;
}
use of com.emc.storageos.model.RestLinkRep in project coprhd-controller by CoprHD.
the class ClusterInfoMapper method toClusterInfoWithSelfLink.
public static ClusterInfo toClusterInfoWithSelfLink(ClusterInfo from) {
ClusterInfo copyTo = new ClusterInfo();
copyTo.setCurrentState(from.getCurrentState());
copyTo.setSelfLink(new RestLinkRep());
copyTo.getSelfLink().setLinkName("self");
try {
copyTo.getSelfLink().setLinkRef(new URI(ClusterInfo.CLUSTER_URI));
} catch (URISyntaxException e) {
throw APIException.badRequests.parameterIsNotValidURI(ClusterInfo.CLUSTER_URI);
}
return copyTo;
}
use of com.emc.storageos.model.RestLinkRep in project coprhd-controller by CoprHD.
the class CallHomeServiceImpl method toTask.
private TaskResourceRep toTask(Task task) {
TaskResourceRep taskResourceRep = new TaskResourceRep();
taskResourceRep.setId(task.getId());
NamedURI resource = task.getResource();
NamedRelatedResourceRep namedRelatedResourceRep = new NamedRelatedResourceRep(resource.getURI(), new RestLinkRep("self", URI.create("/" + resource.getURI())), resource.getName());
taskResourceRep.setResource(namedRelatedResourceRep);
if (!StringUtils.isBlank(task.getRequestId())) {
taskResourceRep.setOpId(task.getRequestId());
}
// Operation
taskResourceRep.setState(task.getStatus());
if (task.getServiceCode() != null) {
taskResourceRep.setServiceError(toServiceErrorRestRep(toServiceCode(task.getServiceCode()), task.getMessage()));
} else {
taskResourceRep.setMessage(task.getMessage());
}
taskResourceRep.setDescription(task.getDescription());
taskResourceRep.setStartTime(task.getStartTime());
taskResourceRep.setEndTime(task.getEndTime());
taskResourceRep.setProgress(task.getProgress() != null ? task.getProgress() : 0);
taskResourceRep.setQueuedStartTime(task.getQueuedStartTime());
taskResourceRep.setQueueName(task.getQueueName());
return taskResourceRep;
}
use of com.emc.storageos.model.RestLinkRep in project coprhd-controller by CoprHD.
the class OrderService method getOtherSearchResults.
/**
* parameter: 'orderStatus' The status for the order
* parameter: 'startTime' Start time to search for orders
* parameter: 'endTime' End time to search for orders
*
* @return Return a list of matching orders or an empty list if no match was found.
*/
@Override
protected SearchResults getOtherSearchResults(Map<String, List<String>> parameters, boolean authorized) {
StorageOSUser user = getUserFromContext();
String tenantId = user.getTenantId();
if (parameters.containsKey(SearchConstants.TENANT_ID_PARAM)) {
tenantId = parameters.get(SearchConstants.TENANT_ID_PARAM).get(0);
}
verifyAuthorizedInTenantOrg(uri(tenantId), user);
if (!parameters.containsKey(SearchConstants.ORDER_STATUS_PARAM) && !parameters.containsKey(SearchConstants.START_TIME_PARAM) && !parameters.containsKey(SearchConstants.END_TIME_PARAM)) {
throw APIException.badRequests.invalidParameterSearchMissingParameter(getResourceClass().getName(), SearchConstants.ORDER_STATUS_PARAM + " or " + SearchConstants.START_TIME_PARAM + " or " + SearchConstants.END_TIME_PARAM);
}
if (parameters.containsKey(SearchConstants.ORDER_STATUS_PARAM) && (parameters.containsKey(SearchConstants.START_TIME_PARAM) || parameters.containsKey(SearchConstants.END_TIME_PARAM))) {
throw APIException.badRequests.parameterForSearchCouldNotBeCombinedWithAnyOtherParameter(getResourceClass().getName(), SearchConstants.ORDER_STATUS_PARAM, SearchConstants.START_TIME_PARAM + " or " + SearchConstants.END_TIME_PARAM);
}
List<Order> orders = Lists.newArrayList();
if (parameters.containsKey(SearchConstants.ORDER_STATUS_PARAM)) {
String orderStatus = parameters.get(SearchConstants.ORDER_STATUS_PARAM).get(0);
ArgValidator.checkFieldNotEmpty(orderStatus, SearchConstants.ORDER_STATUS_PARAM);
orders = orderManager.findOrdersByStatus(uri(tenantId), OrderStatus.valueOf(orderStatus));
} else if (parameters.containsKey(SearchConstants.START_TIME_PARAM) || parameters.containsKey(SearchConstants.END_TIME_PARAM)) {
Date startTime = null;
if (parameters.containsKey(SearchConstants.START_TIME_PARAM)) {
startTime = TimeUtils.getDateTimestamp(parameters.get(SearchConstants.START_TIME_PARAM).get(0));
}
Date endTime = null;
if (parameters.containsKey(SearchConstants.END_TIME_PARAM)) {
endTime = TimeUtils.getDateTimestamp(parameters.get(SearchConstants.END_TIME_PARAM).get(0));
}
if (startTime == null && endTime == null) {
throw APIException.badRequests.invalidParameterSearchMissingParameter(getResourceClass().getName(), SearchConstants.ORDER_STATUS_PARAM + " or " + SearchConstants.START_TIME_PARAM + " or " + SearchConstants.END_TIME_PARAM);
}
if (startTime.after(endTime)) {
throw APIException.badRequests.endTimeBeforeStartTime(startTime.toString(), endTime.toString());
}
int maxCount = -1;
List<String> c = parameters.get(SearchConstants.ORDER_MAX_COUNT);
if (c != null) {
String maxCountParam = parameters.get(SearchConstants.ORDER_MAX_COUNT).get(0);
maxCount = Integer.parseInt(maxCountParam);
}
orders = orderManager.findOrdersByTimeRange(uri(tenantId), startTime, endTime, maxCount);
}
ResRepFilter<SearchResultResourceRep> resRepFilter = (ResRepFilter<SearchResultResourceRep>) getPermissionFilter(getUserFromContext(), _permissionsHelper);
List<SearchResultResourceRep> searchResultResourceReps = Lists.newArrayList();
for (Order order : orders) {
RestLinkRep selfLink = new RestLinkRep("self", RestLinkFactory.newLink(getResourceType(), order.getId()));
SearchResultResourceRep searchResultResourceRep = new SearchResultResourceRep();
searchResultResourceRep.setId(order.getId());
searchResultResourceRep.setLink(selfLink);
if (authorized || resRepFilter.isAccessible(searchResultResourceRep)) {
searchResultResourceReps.add(searchResultResourceRep);
}
}
SearchResults result = new SearchResults();
result.setResource(searchResultResourceReps);
return result;
}
Aggregations