Search in sources :

Example 11 with RestLinkRep

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);
}
Also used : RestLinkRep(com.emc.storageos.model.RestLinkRep)

Example 12 with RestLinkRep

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;
}
Also used : NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) RestLinkRep(com.emc.storageos.model.RestLinkRep) WFDirectoryRestRep(com.emc.vipr.model.catalog.WFDirectoryRestRep)

Example 13 with RestLinkRep

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;
}
Also used : ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) RestLinkRep(com.emc.storageos.model.RestLinkRep) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 14 with RestLinkRep

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;
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) RestLinkRep(com.emc.storageos.model.RestLinkRep) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep)

Example 15 with RestLinkRep

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;
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) SearchResultResourceRep(com.emc.storageos.model.search.SearchResultResourceRep) RestLinkRep(com.emc.storageos.model.RestLinkRep) OrderMapper.toExecutionLogList(com.emc.sa.api.mapper.OrderMapper.toExecutionLogList) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList) ArrayList(java.util.ArrayList) OrderMapper.toOrderLogList(com.emc.sa.api.mapper.OrderMapper.toOrderLogList) OrderLogList(com.emc.vipr.model.catalog.OrderLogList) OrderList(com.emc.vipr.model.catalog.OrderList) List(java.util.List) ExecutionLogList(com.emc.vipr.model.catalog.ExecutionLogList) URIUtil.asString(com.emc.storageos.db.client.URIUtil.asString) ResRepFilter(com.emc.storageos.api.service.impl.response.ResRepFilter) SearchResults(com.emc.storageos.model.search.SearchResults) Date(java.util.Date)

Aggregations

RestLinkRep (com.emc.storageos.model.RestLinkRep)22 URI (java.net.URI)9 SearchResultResourceRep (com.emc.storageos.model.search.SearchResultResourceRep)8 SearchResults (com.emc.storageos.model.search.SearchResults)6 ArrayList (java.util.ArrayList)6 NamedURI (com.emc.storageos.db.client.model.NamedURI)5 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)5 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)4 StringMap (com.emc.storageos.db.client.model.StringMap)4 URISyntaxException (java.net.URISyntaxException)4 List (java.util.List)4 BulkList (com.emc.storageos.api.service.impl.response.BulkList)3 ResRepFilter (com.emc.storageos.api.service.impl.response.ResRepFilter)3 SearchedResRepList (com.emc.storageos.api.service.impl.response.SearchedResRepList)2 TimestampedURIQueryResult (com.emc.storageos.db.client.TimestampedURIQueryResult)2 AggregatedConstraint (com.emc.storageos.db.client.constraint.AggregatedConstraint)2 Constraint (com.emc.storageos.db.client.constraint.Constraint)2 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)2 NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)2 StringSet (com.emc.storageos.db.client.model.StringSet)2