Search in sources :

Example 21 with OrderRestRep

use of com.emc.vipr.model.catalog.OrderRestRep in project coprhd-controller by CoprHD.

the class OrdersApi method getOrder.

protected static OrderRestRep getOrder(String orderId) {
    OrderRestRep order = getCatalogClient().orders().get(uri(orderId));
    checkPermissions(order);
    return order;
}
Also used : OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep)

Example 22 with OrderRestRep

use of com.emc.vipr.model.catalog.OrderRestRep 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);
}
Also used : ApprovalRestRep(com.emc.vipr.model.catalog.ApprovalRestRep) Unauthorized(play.mvc.results.Unauthorized) OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep) ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) ScheduledEventRestRep(com.emc.vipr.model.catalog.ScheduledEventRestRep) URI(java.net.URI) Date(java.util.Date) DateTime(org.joda.time.DateTime) Result(play.mvc.results.Result)

Example 23 with OrderRestRep

use of com.emc.vipr.model.catalog.OrderRestRep in project coprhd-controller by CoprHD.

the class Approvals method submit.

public static void submit(String id, ApprovalsForm approval) {
    ViPRCatalogClient2 catalog = getCatalogClient();
    ApprovalRestRep approvalRep = catalog.approvals().get(uri(id));
    OrderRestRep order = getOrder(approvalRep.getOrder());
    if (approvalRep.isPending()) {
        approval.validate("approval");
        if (Validation.hasErrors()) {
            Common.handleError();
        }
        if (isApprove(approval.getSubmit())) {
            approve(approvalRep, approval.getMessage());
            flash.put("success", MessagesUtils.get("approval.approve.message", order.getSubmittedBy()));
        } else if (isReject(approval.getSubmit())) {
            reject(approvalRep, approval.getMessage());
            flash.put("warn", MessagesUtils.get("approval.reject.message", order.getSubmittedBy()));
        }
    } else {
        flash.error(MessagesUtils.get("approval.notPending.error", order.getOrderNumber()));
    }
    index();
}
Also used : ApprovalRestRep(com.emc.vipr.model.catalog.ApprovalRestRep) OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep) ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2)

Example 24 with OrderRestRep

use of com.emc.vipr.model.catalog.OrderRestRep in project coprhd-controller by CoprHD.

the class ExecutionWindows method delete.

public static void delete(ExecutionWindowForm executionWindowForm) {
    ExecutionWindowRestRep executionWindow = ExecutionWindowUtils.getExecutionWindow(uri(executionWindowForm.id));
    if (executionWindow == null) {
        notFound();
    }
    List<OrderRestRep> scheduledOrders = OrderUtils.getScheduledOrdersByExecutionWindow(uri(executionWindowForm.id));
    if (Validation.hasErrors() || !scheduledOrders.isEmpty()) {
        if (!scheduledOrders.isEmpty()) {
            renderArgs.put("error", MessagesUtils.get("executionWindow.deleted.containsScheduledOrders", scheduledOrders.size()));
        }
        response.status = 400;
        executionWindowForm.readFrom(executionWindow);
        addDateTimeRenderArgs();
        render("@edit", executionWindowForm);
    }
    ExecutionWindowUtils.deleteExecutionWindow(executionWindow);
    renderText(MessagesUtils.get("executionWindow.deleted.success", executionWindow.getName()));
}
Also used : ExecutionWindowRestRep(com.emc.vipr.model.catalog.ExecutionWindowRestRep) OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep)

Example 25 with OrderRestRep

use of com.emc.vipr.model.catalog.OrderRestRep 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);
}
Also used : OrderCreateParam(com.emc.vipr.model.catalog.OrderCreateParam) OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep) Http(play.mvc.Http) ScheduledEventCreateParam(com.emc.vipr.model.catalog.ScheduledEventCreateParam) ScheduledEventRestRep(com.emc.vipr.model.catalog.ScheduledEventRestRep) FlashException(controllers.util.FlashException)

Aggregations

OrderRestRep (com.emc.vipr.model.catalog.OrderRestRep)27 ViPRCatalogClient2 (com.emc.vipr.client.ViPRCatalogClient2)7 ApprovalRestRep (com.emc.vipr.model.catalog.ApprovalRestRep)4 URI (java.net.URI)4 CatalogServiceRestRep (com.emc.vipr.model.catalog.CatalogServiceRestRep)3 OrderBulkRep (com.emc.vipr.model.catalog.OrderBulkRep)3 ArrayList (java.util.ArrayList)3 Order (com.emc.storageos.db.client.model.uimodels.Order)2 OrderAndParams (com.emc.storageos.db.client.model.uimodels.OrderAndParams)2 OrderParameter (com.emc.storageos.db.client.model.uimodels.OrderParameter)2 OrderCreateParam (com.emc.vipr.model.catalog.OrderCreateParam)2 ScheduledEventRestRep (com.emc.vipr.model.catalog.ScheduledEventRestRep)2 FlashException (controllers.util.FlashException)2 OrderFilter (com.emc.sa.api.mapper.OrderFilter)1 TimeSeriesConstraint (com.emc.storageos.db.client.constraint.TimeSeriesConstraint)1 Tags (com.emc.storageos.model.search.Tags)1 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)1 ViPRHttpException (com.emc.vipr.client.exceptions.ViPRHttpException)1 ExecutionWindowRestRep (com.emc.vipr.model.catalog.ExecutionWindowRestRep)1 OrderInfo (com.emc.vipr.model.catalog.OrderInfo)1