use of com.sun.jersey.multipart.MultiPart in project atlas by apache.
the class AtlasBaseClient method importData.
public AtlasImportResult importData(AtlasImportRequest request, String absoluteFilePath) throws AtlasServiceException {
FileDataBodyPart filePart = new FileDataBodyPart("data", new File(absoluteFilePath));
MultiPart multipartEntity = new FormDataMultiPart().field("request", AtlasType.toJson(request), MediaType.APPLICATION_JSON_TYPE).bodyPart(filePart);
return callAPI(IMPORT, AtlasImportResult.class, multipartEntity);
}
use of com.sun.jersey.multipart.MultiPart in project data-access by pentaho.
the class DataSourcePublishIT method testAnalysis_ACL.
@Test
public void testAnalysis_ACL() throws Exception {
repositoryBase.login(singleTenantAdminUserName, defaultTenant, new String[] { repositoryBase.getTenantAdminRoleName(), AUTHENTICATED_ROLE_NAME });
final String catalogID = "FoodMart";
final InputStream uploadAnalysis = new FileInputStream("target/test-classes/schema.xml");
final boolean overwrite = true;
final boolean xmlaEnabledFlag = false;
final String parameters = "DataSource=" + catalogID + ";EnableXmla=" + xmlaEnabledFlag + ";overwrite=" + overwrite;
MultiPart part = new FormDataMultiPart().field("catalogName", catalogID).field("datasourceName", catalogID).field("overwrite", String.valueOf(overwrite)).field("xmlaEnabledFlag", String.valueOf(xmlaEnabledFlag)).field("parameters", parameters).bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("uploadAnalysis").fileName("schema.xml").size(uploadAnalysis.available()).build(), uploadAnalysis, MediaType.TEXT_XML_TYPE));
WebResource webResource = resource();
final ClientResponse noAnalysis = webResource.path(DATA_ACCESS_API_DATASOURCE_ANALYSIS + catalogID + "/acl").get(ClientResponse.class);
assertEquals(Response.Status.CONFLICT.getStatusCode(), noAnalysis.getStatus());
ClientResponse postAnalysis = webResource.path("data-access/api/mondrian/postAnalysis").type(MediaType.MULTIPART_FORM_DATA_TYPE).post(ClientResponse.class, part);
assertEquals(Response.Status.OK.getStatusCode(), postAnalysis.getStatus());
final ClientResponse noACL = webResource.path(DATA_ACCESS_API_DATASOURCE_ANALYSIS + catalogID + "/acl").get(ClientResponse.class);
assertEquals(Response.Status.NOT_FOUND.getStatusCode(), noACL.getStatus());
repositoryBase.login(USERNAME_SUZY, defaultTenant, new String[] { AUTHENTICATED_ROLE_NAME });
checkAnalysis(webResource, catalogID, true);
repositoryBase.login(singleTenantAdminUserName, defaultTenant, new String[] { repositoryBase.getTenantAdminRoleName(), AUTHENTICATED_ROLE_NAME });
final ClientResponse changeACL = webResource.path(DATA_ACCESS_API_DATASOURCE_ANALYSIS + catalogID + "/acl").put(ClientResponse.class, generateACL(USERNAME_SUZY, RepositoryFileSid.Type.USER));
assertEquals(Response.Status.OK.getStatusCode(), changeACL.getStatus());
repositoryBase.login(USERNAME_SUZY, defaultTenant, new String[] { AUTHENTICATED_ROLE_NAME });
checkAnalysis(webResource, catalogID, true);
final ClientResponse noAccessACL = webResource.path(DATA_ACCESS_API_DATASOURCE_ANALYSIS + catalogID + "/acl").get(ClientResponse.class);
assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), noAccessACL.getStatus());
final ClientResponse noAccessACLNoDS = webResource.path(DATA_ACCESS_API_DATASOURCE_ANALYSIS + catalogID + "_not_exist/acl").get(ClientResponse.class);
assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), noAccessACLNoDS.getStatus());
}
Aggregations