Search in sources :

Example 1 with OrderJobInfo

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

the class RecentOrdersDataTable method getDeleteJobStatus.

public String getDeleteJobStatus() {
    OrderJobInfo info = OrderUtils.queryOrderJob(JOB_TYPE_DELETE);
    // if the job is done or no job, return null
    String status = null;
    if (info != null && !info.isNoJobOrJobDone()) {
        status = MessagesUtils.get("orders.delete.status", new Date(info.getStartTime()), new Date(info.getEndTime()), info.getCompleted(), info.getTotal(), info.getFailed());
        if (info.getTotal() >= OrderDataTable.ORDER_MAX_DELETE_PER_GC) {
            status = String.format("%s %s", status, MessagesUtils.get("orders.delete.all.threshold", OrderDataTable.ORDER_MAX_DELETE_PER_GC));
        }
    }
    Logger.info("getDeleteJobStatus: {}", status);
    return status;
}
Also used : OrderJobInfo(com.emc.vipr.model.catalog.OrderJobInfo) Date(java.util.Date)

Example 2 with OrderJobInfo

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

the class OrderService method getJobStatus.

/**
 * @brief Query status of deleting/downloading orders
 * @param typeStr the type of the job which can be 'DELETE' or 'DOWNLOAD'
 * @return job status
 */
@GET
@Path("/job-status")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
public OrderJobInfo getJobStatus(@DefaultValue("DELETE_ORDER") @QueryParam(SearchConstants.JOB_TYPE) String typeStr) {
    OrderServiceJob.JobType type;
    try {
        type = OrderServiceJob.JobType.valueOf(typeStr);
    } catch (Exception e) {
        log.error("Failed to get job type e=", e);
        throw APIException.badRequests.invalidParameterWithCause(SearchConstants.JOB_TYPE, typeStr, e);
    }
    OrderJobStatus status = queryJobInfo(type);
    return status != null ? status.toOrderJobInfo() : new OrderJobInfo();
}
Also used : OrderJobInfo(com.emc.vipr.model.catalog.OrderJobInfo) OrderJobStatus(com.emc.sa.api.utils.OrderJobStatus) InvalidParameterException(java.security.InvalidParameterException) WebApplicationException(javax.ws.rs.WebApplicationException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) OrderServiceJob(com.emc.sa.api.utils.OrderServiceJob) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 3 with OrderJobInfo

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

the class OrderJobStatus method toOrderJobInfo.

@JsonIgnore
public OrderJobInfo toOrderJobInfo() {
    OrderJobInfo info = new OrderJobInfo();
    info.setTotal(total);
    info.setStartTime(startTime);
    info.setEndTime(endTime);
    info.setCompleted(getCompletedNumber());
    info.setFailed(getFailed());
    info.setTimeUsedPerOrder(timeUsedPerOrder);
    info.setTids(Collections.unmodifiableList(tids));
    return info;
}
Also used : OrderJobInfo(com.emc.vipr.model.catalog.OrderJobInfo) JsonIgnore(org.codehaus.jackson.annotate.JsonIgnore)

Example 4 with OrderJobInfo

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

the class RecentOrdersDataTable method getDownloadJobStatus.

public String getDownloadJobStatus() {
    OrderJobInfo info = OrderUtils.queryOrderJob(JOB_TYPE_DOWNLOAD);
    // if the job is done or no job, return null
    String status = null;
    if (info != null && !info.isNoJobOrJobDone()) {
        if (info.getStartTime() == 0) {
            status = MessagesUtils.get("orders.download.status.notime", info.getCompleted(), info.getTotal(), info.getFailed());
        } else {
            status = MessagesUtils.get("orders.download.status", new Date(info.getStartTime()), new Date(info.getEndTime()), info.getCompleted(), info.getTotal(), info.getFailed());
        }
    }
    Logger.info("getDownloadJobStatus: {}", status);
    return status;
}
Also used : OrderJobInfo(com.emc.vipr.model.catalog.OrderJobInfo) Date(java.util.Date)

Aggregations

OrderJobInfo (com.emc.vipr.model.catalog.OrderJobInfo)4 Date (java.util.Date)2 OrderJobStatus (com.emc.sa.api.utils.OrderJobStatus)1 OrderServiceJob (com.emc.sa.api.utils.OrderServiceJob)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)1 URISyntaxException (java.net.URISyntaxException)1 InvalidParameterException (java.security.InvalidParameterException)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 JsonIgnore (org.codehaus.jackson.annotate.JsonIgnore)1