Search in sources :

Example 6 with ViPRHttpException

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

the class FileSystems method fileSystem.

public static void fileSystem(String fileSystemId) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    FileShareRestRep fileSystem = null;
    try {
        fileSystem = client.fileSystems().get(uri(fileSystemId));
    } catch (ViPRHttpException e) {
        if (e.getHttpCode() == 404 || e.getHttpCode() == 400) {
            flash.error(MessagesUtils.get(UNKNOWN, fileSystemId));
            fileSystems(null);
        }
        throw e;
    }
    if (fileSystem != null) {
        if (fileSystem.getVirtualArray() != null) {
            VirtualArrayRestRep virtualArray = client.varrays().get(fileSystem.getVirtualArray());
            renderArgs.put("virtualArray", virtualArray);
        }
        if (fileSystem.getVirtualPool() != null) {
            FileVirtualPoolRestRep virtualPool = client.fileVpools().get(fileSystem.getVirtualPool());
            renderArgs.put("virtualPool", virtualPool);
        }
        if (Security.isSystemAdminOrRestrictedSystemAdmin()) {
            if (fileSystem.getStorageSystem() != null) {
                StorageSystemRestRep storageSystem = client.storageSystems().get(fileSystem.getStorageSystem());
                renderArgs.put("storageSystem", storageSystem);
            }
            if (fileSystem.getPool() != null) {
                StoragePoolRestRep storagePool = client.storagePools().get(fileSystem.getPool());
                renderArgs.put("storagePool", storagePool);
            }
            if (fileSystem.getStoragePort() != null) {
                StoragePortRestRep storagePort = client.storagePorts().get(fileSystem.getStoragePort());
                renderArgs.put("storagePort", storagePort);
            }
        }
        Tasks<FileShareRestRep> tasksResponse = client.fileSystems().getTasks(fileSystem.getId());
        List<Task<FileShareRestRep>> tasks = tasksResponse.getTasks();
        renderArgs.put("tasks", tasks);
    } else {
        notFound(MessagesUtils.get("resources.filesystems.notfound"));
    }
    renderArgs.put("permissionTypeOptions", PERMISSION_TYPES);
    render(fileSystem);
}
Also used : FileVirtualPoolRestRep(com.emc.storageos.model.vpool.FileVirtualPoolRestRep) Task(com.emc.vipr.client.Task) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) StoragePortRestRep(com.emc.storageos.model.ports.StoragePortRestRep) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) StoragePoolRestRep(com.emc.storageos.model.pools.StoragePoolRestRep) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Example 7 with ViPRHttpException

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

the class Security method authenticated.

/**
 * AJAXable method that can be used to determine if the user is authenticated.
 */
public static void authenticated() {
    if (StringUtils.isBlank(getAuthToken())) {
        renderJSON(false);
    }
    try {
        UserInfo user = getUserInfo();
        renderJSON(user != null);
    } catch (ViPRHttpException e) {
        Logger.error(e, "HTTP Error: %s %s", e.getHttpCode(), e.getMessage());
        if (e.getHttpCode() == HttpStatus.SC_UNAUTHORIZED) {
            renderJSON(false);
        }
        // Propogate other errors (502, 503 most importantly)
        error(e.getHttpCode(), e.getMessage());
    } catch (Exception e) {
        Logger.error(e, "Error getting user info");
        renderJSON("error");
    }
}
Also used : UserInfo(models.security.UserInfo) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Example 8 with ViPRHttpException

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

the class OrderUtils method getOrder.

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

Example 9 with ViPRHttpException

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

the class ExceptionOnErrorFilter method handle.

@Override
public ClientResponse handle(ClientRequest request) throws ClientHandlerException {
    ClientResponse response = getNext().handle(request);
    int status = response.getStatus();
    if (status >= 400 && status < 600) {
        if (isSupportedType(response.getType())) {
            ServiceErrorRestRep serviceError;
            try {
                serviceError = response.getEntity(ServiceErrorRestRep.class);
            } catch (Exception e) {
                // Cause to fall-through to default exception
                log.error("Error parsing error message", e);
                serviceError = null;
            }
            if (serviceError != null) {
                logAndThrow(new ServiceErrorException(status, serviceError));
            }
        }
        // Fallback for unknown entity types
        String content = response.getEntity(String.class);
        logAndThrow(new ViPRHttpException(status, content));
    }
    return response;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ServiceErrorRestRep(com.emc.storageos.model.errorhandling.ServiceErrorRestRep) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException) ClientHandlerException(com.sun.jersey.api.client.ClientHandlerException) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Example 10 with ViPRHttpException

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

the class Common method handleExpiredToken.

@Util
public static void handleExpiredToken(Throwable throwable) {
    if (throwable instanceof ViPRHttpException) {
        ViPRHttpException ve = (ViPRHttpException) throwable;
        if (ve.getHttpCode() == HttpStatus.SC_UNAUTHORIZED) {
            Logger.info("Clearing auth token");
            // Auth token may have expired
            Security.clearAuthToken();
            Security.redirectToAuthPage();
        }
    }
}
Also used : ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException) BourneUtil(util.BourneUtil) Util(play.mvc.Util)

Aggregations

ViPRHttpException (com.emc.vipr.client.exceptions.ViPRHttpException)13 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)5 Task (com.emc.vipr.client.Task)4 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)2 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)2 ViPRCatalogClient2 (com.emc.vipr.client.ViPRCatalogClient2)2 AssetOptionsContext (com.emc.sa.asset.AssetOptionsContext)1 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)1 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)1 ComputeImageServerRestRep (com.emc.storageos.model.compute.ComputeImageServerRestRep)1 ServiceErrorRestRep (com.emc.storageos.model.errorhandling.ServiceErrorRestRep)1 FileSnapshotRestRep (com.emc.storageos.model.file.FileSnapshotRestRep)1 BucketRestRep (com.emc.storageos.model.object.BucketRestRep)1 StoragePoolRestRep (com.emc.storageos.model.pools.StoragePoolRestRep)1 StoragePortRestRep (com.emc.storageos.model.ports.StoragePortRestRep)1 StorageSystemRestRep (com.emc.storageos.model.systems.StorageSystemRestRep)1 FileVirtualPoolRestRep (com.emc.storageos.model.vpool.FileVirtualPoolRestRep)1 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)1 AssetDependencyResponse (com.emc.vipr.model.catalog.AssetDependencyResponse)1 AssetOption (com.emc.vipr.model.catalog.AssetOption)1