Search in sources :

Example 16 with ViPRCatalogClient2

use of com.emc.vipr.client.ViPRCatalogClient2 in project coprhd-controller by CoprHD.

the class CatalogServiceUtils method moveUpService.

public static void moveUpService(URI catalogServiceId) {
    ViPRCatalogClient2 catalog = getCatalogClient();
    catalog.services().moveUp(catalogServiceId);
}
Also used : ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2)

Example 17 with ViPRCatalogClient2

use of com.emc.vipr.client.ViPRCatalogClient2 in project coprhd-controller by CoprHD.

the class CatalogServiceUtils method moveUpServiceField.

public static void moveUpServiceField(URI catalogServiceId, String fieldName) {
    ViPRCatalogClient2 catalog = getCatalogClient();
    catalog.services().moveUpField(catalogServiceId, fieldName);
}
Also used : ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2)

Example 18 with ViPRCatalogClient2

use of com.emc.vipr.client.ViPRCatalogClient2 in project coprhd-controller by CoprHD.

the class CatalogServiceUtils method getCatalogService.

public static CatalogServiceRestRep getCatalogService(URI id) {
    ViPRCatalogClient2 catalog = getCatalogClient();
    CatalogServiceRestRep service = null;
    try {
        service = catalog.services().get(id);
    } catch (ViPRHttpException e) {
        if (e.getHttpCode() == 404) {
            service = null;
        } else {
            throw e;
        }
    }
    return service;
}
Also used : ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Example 19 with ViPRCatalogClient2

use of com.emc.vipr.client.ViPRCatalogClient2 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 20 with ViPRCatalogClient2

use of com.emc.vipr.client.ViPRCatalogClient2 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)

Aggregations

ViPRCatalogClient2 (com.emc.vipr.client.ViPRCatalogClient2)32 OrderRestRep (com.emc.vipr.model.catalog.OrderRestRep)7 ApprovalRestRep (com.emc.vipr.model.catalog.ApprovalRestRep)4 CatalogServiceRestRep (com.emc.vipr.model.catalog.CatalogServiceRestRep)4 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)2 ViPRHttpException (com.emc.vipr.client.exceptions.ViPRHttpException)2 URI (java.net.URI)2 Date (java.util.Date)2 OrderTextCreator (com.emc.storageos.db.client.util.OrderTextCreator)1 AssetDependencyRequest (com.emc.vipr.model.catalog.AssetDependencyRequest)1 AssetOptionsRequest (com.emc.vipr.model.catalog.AssetOptionsRequest)1 ExecutionLogRestRep (com.emc.vipr.model.catalog.ExecutionLogRestRep)1 ExecutionStateRestRep (com.emc.vipr.model.catalog.ExecutionStateRestRep)1 ExecutionWindowRestRep (com.emc.vipr.model.catalog.ExecutionWindowRestRep)1 OrderLogRestRep (com.emc.vipr.model.catalog.OrderLogRestRep)1 Reference (com.emc.vipr.model.catalog.Reference)1 ScheduledEventRestRep (com.emc.vipr.model.catalog.ScheduledEventRestRep)1 ApprovalRequestInfo (models.datatable.ApprovalsDataTable.ApprovalRequestInfo)1 DateTime (org.joda.time.DateTime)1 Util (play.mvc.Util)1