use of com.emc.vipr.model.catalog.ScheduledEventRestRep 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);
}
use of com.emc.vipr.model.catalog.ScheduledEventRestRep in project coprhd-controller by CoprHD.
the class Orders method submitOrder.
public static void submitOrder(String serviceId) {
checkAuthenticity();
OrderCreateParam order = createAndValidateOrder(serviceId);
String status = null;
String orderId = null;
try {
if (isSchedulerEnabled()) {
ScheduledEventCreateParam event = createScheduledOrder(order);
if (Validation.hasErrors()) {
Validation.keep();
Common.flashParamsExcept("json", "body");
Services.showForm(serviceId);
}
ScheduledEventRestRep submittedEvent = getCatalogClient().orders().submitScheduledEvent(event);
status = submittedEvent.getEventStatus();
orderId = submittedEvent.getLatestOrderId().toString();
} else {
OrderRestRep submittedOrder = getCatalogClient().orders().submit(order);
status = submittedOrder.getOrderStatus();
orderId = submittedOrder.getId().toString();
}
} catch (Exception e) {
Logger.error(e, MessagesUtils.get("order.submitFailedWithDetail", e.getMessage()));
flash.error(MessagesUtils.get("order.submitFailedWithDetail", e.getMessage()));
Common.handleError();
}
if (OrderRestRep.ERROR.equalsIgnoreCase(status)) {
flash.error(MessagesUtils.get("order.submitFailed"));
} else {
flash.success(MessagesUtils.get("order.submitSuccess"));
}
Http.Cookie cookie = request.cookies.get(RECENT_ACTIVITIES);
response.setCookie(RECENT_ACTIVITIES, updateRecentActivitiesCookie(cookie, serviceId));
receipt(orderId);
}
Aggregations