Search in sources :

Example 1 with ViPRException

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

the class FileVirtualPools method save.

@FlashException(keep = true, referrer = { "create", "edit" })
public static void save(FileVirtualPoolForm vpool) {
    if (vpool == null) {
        list();
    }
    vpool.deserialize();
    vpool.validate("vpool");
    if (Validation.hasErrors()) {
        Common.handleError();
    }
    try {
        FileVirtualPoolRestRep result = vpool.save();
        flash.success(MessagesUtils.get(SAVED_SUCCESS, result.getName()));
        backToReferrer();
    } catch (ViPRException e) {
        throwFlashException(vpool, e);
    }
}
Also used : FileVirtualPoolRestRep(com.emc.storageos.model.vpool.FileVirtualPoolRestRep) ViPRException(com.emc.vipr.client.exceptions.ViPRException) FlashException(controllers.util.FlashException)

Example 2 with ViPRException

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

the class Projects method saveProjectACLs.

@Util
private static void saveProjectACLs(String projectId, List<AclEntryForm> aclEntries) {
    List<ACLEntry> currentProjectAcls = ProjectUtils.getACLs(projectId);
    ACLAssignmentChanges changes = new ACLAssignmentChanges();
    changes.getAdd().addAll(AclEntryForm.getAddedAcls(currentProjectAcls, aclEntries));
    changes.getRemove().addAll(AclEntryForm.getRemovedAcls(currentProjectAcls, aclEntries));
    try {
        ProjectUtils.updateACLs(projectId, changes);
    } catch (ViPRException e) {
        Logger.error(e, "Failed to update Project ACLs");
        String errorDesc = e.getMessage();
        if (e instanceof ServiceErrorException) {
            errorDesc = ((ServiceErrorException) e).getDetailedMessage();
        }
        flash.error(MessagesUtils.get("projects.updateProjectACLs.failed", errorDesc));
    }
}
Also used : ACLAssignmentChanges(com.emc.storageos.model.auth.ACLAssignmentChanges) ACLEntry(com.emc.storageos.model.auth.ACLEntry) ViPRException(com.emc.vipr.client.exceptions.ViPRException) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) Util(play.mvc.Util)

Example 3 with ViPRException

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

the class VirtualArrays method saveTenantACLs.

/**
 * Saves tenant ACLs on the virtual array.
 *
 * @param virtualArrayId
 *            the virtual array ID.
 * @param tenants
 *            the tenant ACLs.
 */
private static void saveTenantACLs(String virtualArrayId, List<String> tenants) {
    Set<String> tenantIds = Sets.newHashSet();
    if (tenants != null) {
        tenantIds.addAll(tenants);
    }
    ACLUpdateBuilder builder = new ACLUpdateBuilder(VirtualArrayUtils.getACLs(virtualArrayId));
    builder.setTenants(tenantIds);
    try {
        VirtualArrayUtils.updateACLs(virtualArrayId, builder.getACLUpdate());
    } catch (ViPRException e) {
        Logger.error(e, "Failed to update Virtual Array ACLs");
        String errorDesc = e.getMessage();
        if (e instanceof ServiceErrorException) {
            errorDesc = ((ServiceErrorException) e).getDetailedMessage();
        }
        flash.error(MessagesUtils.get("varrays.updateVarrayACLs.failed", errorDesc));
    }
}
Also used : ViPRException(com.emc.vipr.client.exceptions.ViPRException) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) ACLUpdateBuilder(util.builders.ACLUpdateBuilder)

Example 4 with ViPRException

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

the class Logs method getAsItems.

/**
 * @deprecated Replaced by
 * @see #getAsItems(ItemProcessor, Collection, Collection, Collection, Integer, String, String, String, Integer)
 */
@Deprecated
public void getAsItems(ItemProcessor<LogMessage> processor, Collection<String> nodeIds, Collection<String> logNames, Integer severity, String start, String end, String regex, Integer maxCount) {
    ListProcessor<LogMessage> listProcessor = new ListProcessor<LogMessage>(LogMessage.class, processor);
    InputStream in = getAsStream(nodeIds, logNames, severity, start, end, regex, maxCount);
    try {
        listProcessor.process(in);
    } catch (Exception e) {
        throw new ViPRException(e);
    } finally {
        try {
            in.close();
        } catch (IOException e) {
        // Silently ignore
        }
    }
}
Also used : ListProcessor(com.emc.vipr.client.impl.jaxb.ListProcessor) LogMessage(com.emc.vipr.model.sys.logging.LogMessage) InputStream(java.io.InputStream) ViPRException(com.emc.vipr.client.exceptions.ViPRException) IOException(java.io.IOException) IOException(java.io.IOException) ViPRException(com.emc.vipr.client.exceptions.ViPRException)

Example 5 with ViPRException

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

the class TaskUtil method waitForTask.

public static TaskResourceRep waitForTask(RestClient client, TaskResourceRep task, long timeoutMillis) {
    long startTime = System.currentTimeMillis();
    while (isRunning(task) || isSuspended(task)) {
        if (timeoutMillis > 0 && (System.currentTimeMillis() - startTime) > timeoutMillis) {
            throw new TimeoutException("Timed out waiting for task to complete");
        }
        try {
            Thread.sleep(client.getConfig().getTaskPollingInterval());
        } catch (InterruptedException e) {
            throw new ViPRException(e);
        }
        refreshSession(client);
        task = refresh(client, task);
    }
    return task;
}
Also used : ViPRException(com.emc.vipr.client.exceptions.ViPRException) TimeoutException(com.emc.vipr.client.exceptions.TimeoutException)

Aggregations

ViPRException (com.emc.vipr.client.exceptions.ViPRException)7 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)3 ACLUpdateBuilder (util.builders.ACLUpdateBuilder)2 ACLAssignmentChanges (com.emc.storageos.model.auth.ACLAssignmentChanges)1 ACLEntry (com.emc.storageos.model.auth.ACLEntry)1 BlockVirtualPoolRestRep (com.emc.storageos.model.vpool.BlockVirtualPoolRestRep)1 FileVirtualPoolRestRep (com.emc.storageos.model.vpool.FileVirtualPoolRestRep)1 TimeoutException (com.emc.vipr.client.exceptions.TimeoutException)1 ListProcessor (com.emc.vipr.client.impl.jaxb.ListProcessor)1 LogMessage (com.emc.vipr.model.sys.logging.LogMessage)1 FlashException (controllers.util.FlashException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Util (play.mvc.Util)1