Search in sources :

Example 1 with Unauthorized

use of play.mvc.results.Unauthorized 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)

Aggregations

ViPRCatalogClient2 (com.emc.vipr.client.ViPRCatalogClient2)1 ApprovalRestRep (com.emc.vipr.model.catalog.ApprovalRestRep)1 CatalogServiceRestRep (com.emc.vipr.model.catalog.CatalogServiceRestRep)1 OrderRestRep (com.emc.vipr.model.catalog.OrderRestRep)1 ScheduledEventRestRep (com.emc.vipr.model.catalog.ScheduledEventRestRep)1 URI (java.net.URI)1 Date (java.util.Date)1 DateTime (org.joda.time.DateTime)1 Result (play.mvc.results.Result)1 Unauthorized (play.mvc.results.Unauthorized)1