Search in sources :

Example 51 with MultivaluedMapImpl

use of com.sun.jersey.core.util.MultivaluedMapImpl in project incubator-atlas by apache.

the class TypesJerseyResourceIT method testGetTraitNames.

@Test
public void testGetTraitNames() throws Exception {
    String[] traitsAdded = addTraits();
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add("type", DataTypes.TypeCategory.TRAIT.name());
    JSONObject response = atlasClientV1.callAPIWithQueryParams(AtlasClient.API.LIST_TYPES, queryParams);
    Assert.assertNotNull(response);
    Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
    final JSONArray list = response.getJSONArray(AtlasClient.RESULTS);
    Assert.assertNotNull(list);
    Assert.assertTrue(list.length() >= traitsAdded.length);
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) JSONArray(org.codehaus.jettison.json.JSONArray) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) Test(org.testng.annotations.Test)

Example 52 with MultivaluedMapImpl

use of com.sun.jersey.core.util.MultivaluedMapImpl in project coprhd-controller by CoprHD.

the class DataDomainClient method getMTreeCapacityInfo.

public DDMtreeCapacityInfos getMTreeCapacityInfo(String ddSystem, String mtreeId, int page, int pgSize, DDStatsDataViewQuery dataView, DDStatsIntervalQuery interval, boolean requestedIntervalOnly, String sort) throws DataDomainApiException {
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    if (page >= 0) {
        queryParams.add(DataDomainApiConstants.PAGE, String.valueOf(page));
    }
    if (pgSize > 0) {
        queryParams.add(DataDomainApiConstants.PAGE_SIZE, String.valueOf(pgSize));
    }
    if (DDStatsDataViewQuery.isMember(dataView)) {
        queryParams.add(DataDomainApiConstants.DATA_VIEW, dataView.toString());
    }
    // }
    if (dataView.equals(DDStatsDataViewQuery.delta)) {
        queryParams.add(DataDomainApiConstants.REQUESTED_INTERVAL_ONLY, String.valueOf(requestedIntervalOnly));
    }
    if ((sort != null) && (sort.endsWith(DataDomainApiConstants.COLLECTION_EPOCH))) {
        queryParams.add(DataDomainApiConstants.SORT, sort);
    }
    ClientResponse response = get(DataDomainApiConstants.uriDataDomainMtreeStatsCapacity(ddSystem, mtreeId), (MultivaluedMap<String, String>) queryParams);
    return getResponseObject(DDMtreeCapacityInfos.class, response);
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl)

Example 53 with MultivaluedMapImpl

use of com.sun.jersey.core.util.MultivaluedMapImpl in project coprhd-controller by CoprHD.

the class DataDomainClient method getMTreeList.

public DDMTreeList getMTreeList(String system) throws DataDomainApiException {
    // As per DD team, the maximum mtrees that DDOS supports is 100. Hence we need
    // to request for page with size 100 so we get all MTrees.
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add("size", String.valueOf(DataDomainApiConstants.DD_MAX_MTREE_LIMIT));
    ClientResponse response = get(DataDomainApiConstants.uriDataDomainMtrees(system), (MultivaluedMap<String, String>) queryParams);
    return getResponseObject(DDMTreeList.class, response);
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl)

Example 54 with MultivaluedMapImpl

use of com.sun.jersey.core.util.MultivaluedMapImpl in project coprhd-controller by CoprHD.

the class IsilonApi method createDir.

/**
 * Create a directory with the path specified
 *
 * @param fspath
 *            Dir path to be created
 * @param recursive
 *            if true, will create parent recursively if it doesn't
 *            exist
 * @throws IsilonException
 */
public void createDir(String fspath, boolean recursive) throws IsilonException {
    fspath = scrubPath(fspath);
    ClientResponse resp = null;
    try {
        // check if already exists
        if (existsDir(fspath)) {
            return;
        }
        fspath = URLEncoder.encode(fspath, "UTF-8");
        MultivaluedMap<String, String> queryParams = null;
        if (recursive) {
            queryParams = new MultivaluedMapImpl();
            queryParams.add("recursive", "1");
        }
        sLogger.debug("IsilonApi createDir {} - start", fspath);
        resp = _client.put(_baseUrl.resolve(URI_IFS.resolve(fspath)), queryParams, "");
        sLogger.debug("IsilonApi createDir {} - complete", fspath);
        if (resp.getStatus() != 200) {
            processErrorResponse("create directory", fspath, resp.getStatus(), resp.getEntity(JSONObject.class));
        }
    } catch (IsilonException ie) {
        throw ie;
    } catch (Exception e) {
        if (e.getCause() instanceof ConnectException) {
            throw IsilonException.exceptions.unableToConnect(_baseUrl, e);
        }
        final Status status = resp != null ? resp.getClientResponseStatus() : Status.NOT_FOUND;
        throw IsilonException.exceptions.createDirFailed(fspath, status, e);
    } finally {
        if (resp != null) {
            resp.close();
        }
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Status(com.sun.jersey.api.client.ClientResponse.Status) JSONObject(org.codehaus.jettison.json.JSONObject) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) ConnectException(java.net.ConnectException) JSONException(org.codehaus.jettison.json.JSONException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ConnectException(java.net.ConnectException)

Example 55 with MultivaluedMapImpl

use of com.sun.jersey.core.util.MultivaluedMapImpl in project coprhd-controller by CoprHD.

the class FileSystemListRequest method getByStorageResource.

/**
 * Get file system using its storageResourceId
 *
 * @param storageResourceId
 * @return
 */
public VNXeFileSystem getByStorageResource(String storageResourceId) {
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add(VNXeConstants.FILTER, VNXeConstants.STORAGE_RESOURCE_FILTER + "\"" + storageResourceId + "\"");
    setQueryParameters(queryParams);
    VNXeFileSystem result = null;
    List<VNXeFileSystem> fsList = getDataForObjects(VNXeFileSystem.class);
    // it should just return 1
    if (fsList != null && !fsList.isEmpty()) {
        result = fsList.get(0);
    } else {
        _logger.info("No file system found using the storage resource id: " + storageResourceId);
    }
    return result;
}
Also used : VNXeFileSystem(com.emc.storageos.vnxe.models.VNXeFileSystem) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl)

Aggregations

MultivaluedMapImpl (com.sun.jersey.core.util.MultivaluedMapImpl)131 Test (org.junit.Test)55 ClientResponse (com.sun.jersey.api.client.ClientResponse)48 WebResource (com.sun.jersey.api.client.WebResource)39 JSONObject (org.codehaus.jettison.json.JSONObject)39 Test (org.testng.annotations.Test)35 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)13 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)12 List (java.util.List)11 MockNM (org.apache.hadoop.yarn.server.resourcemanager.MockNM)11 JSONArray (org.codehaus.jettison.json.JSONArray)9 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)8 Client (com.sun.jersey.api.client.Client)7 SearchFilter (org.apache.atlas.model.SearchFilter)7 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)7 WebDriverHelper (org.orcid.api.common.WebDriverHelper)7 Response (javax.ws.rs.core.Response)6 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)6 AtlasLineageInfo (org.apache.atlas.model.lineage.AtlasLineageInfo)6 MockAM (org.apache.hadoop.yarn.server.resourcemanager.MockAM)6