use of com.emc.vipr.model.catalog.OrderRestRep in project coprhd-controller by CoprHD.
the class OrderService method getUserOrders.
/**
* Gets the list of orders within a time range for current user
*
* @brief List Orders
* @param startTimeStr start time of the query
* @param endTimeStr end time of the query
* @param maxCount The max number of orders this API returns
* @param ordersOnlyStr if ture, only returns orders info, other info such as OrderParameter
* will not be returned
* @return a list of orders
* @throws DatabaseException when a DB error occurs
*/
@GET
@Path("/my-orders")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public OrderBulkRep getUserOrders(@DefaultValue("") @QueryParam(SearchConstants.START_TIME_PARAM) String startTimeStr, @DefaultValue("") @QueryParam(SearchConstants.END_TIME_PARAM) String endTimeStr, @DefaultValue("-1") @QueryParam(SearchConstants.ORDER_MAX_COUNT) String maxCount, @DefaultValue("false") @QueryParam(SearchConstants.ORDERS_ONLY) String ordersOnlyStr) throws DatabaseException {
long startTimeInMS = getTime(startTimeStr, 0);
long endTimeInMS = getTime(endTimeStr, System.currentTimeMillis());
if (startTimeInMS > endTimeInMS) {
throw APIException.badRequests.endTimeBeforeStartTime(startTimeStr, endTimeStr);
}
int max = Integer.parseInt(maxCount);
boolean ordersOnly = Boolean.parseBoolean(ordersOnlyStr);
log.info("start={} end={} max={}", startTimeInMS, endTimeInMS, max);
StorageOSUser user = getUserFromContext();
List<Order> orders = orderManager.getUserOrders(user, startTimeInMS, endTimeInMS, max);
List<OrderRestRep> list = toOrders(orders, user, ordersOnly);
OrderBulkRep rep = new OrderBulkRep(list);
return rep;
}
use of com.emc.vipr.model.catalog.OrderRestRep in project coprhd-controller by CoprHD.
the class OrderUtils method getErrorOrders.
public static List<OrderRestRep> getErrorOrders(URI tenantId) {
ViPRCatalogClient2 catalog = getCatalogClient();
List<OrderRestRep> scheduledOrders = catalog.orders().search().byStatus(OrderStatus.ERROR.name(), tenantId).run();
return scheduledOrders;
}
use of com.emc.vipr.model.catalog.OrderRestRep in project coprhd-controller by CoprHD.
the class OrderUtils method getOrder.
public static OrderRestRep getOrder(URI id) {
ViPRCatalogClient2 catalog = getCatalogClient();
OrderRestRep order = null;
try {
order = catalog.orders().get(id);
} catch (ViPRHttpException e) {
if (e.getHttpCode() == 404) {
order = null;
} else {
throw e;
}
}
return order;
}
use of com.emc.vipr.model.catalog.OrderRestRep in project coprhd-controller by CoprHD.
the class OrderUtils method getScheduledOrders.
public static List<OrderRestRep> getScheduledOrders(URI tenantId) {
ViPRCatalogClient2 catalog = getCatalogClient();
List<OrderRestRep> scheduledOrders = catalog.orders().search().byStatus(OrderStatus.SCHEDULED.name(), tenantId).run();
return scheduledOrders;
}
use of com.emc.vipr.model.catalog.OrderRestRep in project coprhd-controller by CoprHD.
the class SupportPackageCreator method getOrders.
private List<OrderRestRep> getOrders() {
if ((orderTypes == OrderTypes.ALL) || (orderTypes == OrderTypes.ERROR)) {
List<OrderRestRep> orders = Lists.newArrayList();
if (tenantIds != null) {
for (URI tenantId : tenantIds) {
SearchBuilder<OrderRestRep> search = catalogApi().orders().search().byTimeRange(this.startTime, this.endTime, tenantId);
if (orderTypes == OrderTypes.ERROR) {
search.filter(new FailedOrderFilter());
}
List<OrderRestRep> tenantOrders = search.run();
Logger.info("Found %s Orders for tenantId %s", tenantOrders.size(), tenantId);
orders.addAll(tenantOrders);
}
} else {
SearchBuilder<OrderRestRep> search = catalogApi().orders().search().byTimeRange(this.startTime, this.endTime);
if (orderTypes == OrderTypes.ERROR) {
search.filter(new FailedOrderFilter());
}
orders = search.run();
Logger.info("Found %s Orders", orders.size());
}
return orders;
} else {
return Collections.emptyList();
}
}
Aggregations