LENS-1217 : Remove old java ui server
Project: http://git-wip-us.apache.org/repos/asf/lens/repo Commit: http://git-wip-us.apache.org/repos/asf/lens/commit/b5763ff0 Tree: http://git-wip-us.apache.org/repos/asf/lens/tree/b5763ff0 Diff: http://git-wip-us.apache.org/repos/asf/lens/diff/b5763ff0 Branch: refs/heads/current-release-line Commit: b5763ff06eecec1bcf5ab08b84c97da8c4d3cd38 Parents: 7ca35b8 Author: Rajat Khandelwal <[email protected]> Authored: Sun Jul 24 08:05:55 2016 +0530 Committer: Amareshwari Sriramadasu <[email protected]> Committed: Sun Jul 24 08:05:55 2016 +0530 ---------------------------------------------------------------------- .../lens/server/api/LensConfConstants.java | 40 --- .../java/org/apache/lens/server/LensServer.java | 17 - .../org/apache/lens/server/LensServices.java | 2 +- .../lens/server/ui/MetastoreUIResource.java | 321 ------------------- .../lens/server/ui/QueryServiceUIResource.java | 269 ---------------- .../lens/server/ui/SessionUIResource.java | 148 --------- .../lens/server/ui/StaticFileResource.java | 123 ------- .../java/org/apache/lens/server/ui/UIApp.java | 46 --- .../src/main/resources/lensserver-default.xml | 24 -- .../org/apache/lens/server/TestLensServer.java | 45 --- .../lens/server/TestStaticFileResource.java | 109 ------- .../lens/server/ui/TestSessionUIResource.java | 124 ------- 12 files changed, 1 insertion(+), 1267 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lens/blob/b5763ff0/lens-server-api/src/main/java/org/apache/lens/server/api/LensConfConstants.java ---------------------------------------------------------------------- diff --git a/lens-server-api/src/main/java/org/apache/lens/server/api/LensConfConstants.java b/lens-server-api/src/main/java/org/apache/lens/server/api/LensConfConstants.java index bd9b1ab..9f51565 100644 --- a/lens-server-api/src/main/java/org/apache/lens/server/api/LensConfConstants.java +++ b/lens-server-api/src/main/java/org/apache/lens/server/api/LensConfConstants.java @@ -188,46 +188,6 @@ public final class LensConfConstants { public static final long SESSION_TIMEOUT_SECONDS_DEFAULT = 1440 * 60; // Default is one day /** - * The Constant - */ - public static final String SERVER_UI_ENABLE = SERVER_PFX + "ui.enable"; - - /** - * The Constant - */ - public static final boolean DEFAULT_SERVER_UI_ENABLE = true; - - /** - * The Constant SERVER_UI_URI. - */ - public static final String SERVER_UI_URI = SERVER_PFX + "ui.base.uri"; - - /** - * The Constant DEFAULT_SERVER_UI_URI. - */ - public static final String DEFAULT_SERVER_UI_URI = "http://0.0.0.0:19999/"; - - /** - * The Constant SERVER_UI_STATIC_DIR. - */ - public static final String SERVER_UI_STATIC_DIR = SERVER_PFX + ".ui.static.dir"; - - /** - * The Constant DEFAULT_SERVER_UI_STATIC_DIR. - */ - public static final String DEFAULT_SERVER_UI_STATIC_DIR = "webapp/lens-server/static"; - - /** - * The Constant SERVER_UI_ENABLE_CACHING. - */ - public static final String SERVER_UI_ENABLE_CACHING = SERVER_PFX + "ui.enable.caching"; - - /** - * The Constant DEFAULT_SERVER_UI_ENABLE_CACHING. - */ - public static final boolean DEFAULT_SERVER_UI_ENABLE_CACHING = true; - - /** * The Constant SERVER_STATE_PERSISTENCE_INTERVAL_MILLIS. */ public static final String SERVER_STATE_PERSISTENCE_INTERVAL_MILLIS = http://git-wip-us.apache.org/repos/asf/lens/blob/b5763ff0/lens-server/src/main/java/org/apache/lens/server/LensServer.java ---------------------------------------------------------------------- diff --git a/lens-server/src/main/java/org/apache/lens/server/LensServer.java b/lens-server/src/main/java/org/apache/lens/server/LensServer.java index b6983f4..203c249 100644 --- a/lens-server/src/main/java/org/apache/lens/server/LensServer.java +++ b/lens-server/src/main/java/org/apache/lens/server/LensServer.java @@ -32,7 +32,6 @@ import org.apache.lens.server.error.GenericExceptionMapper; import org.apache.lens.server.error.LensJAXBValidationExceptionMapper; import org.apache.lens.server.metrics.MetricsServiceImpl; import org.apache.lens.server.model.MappedDiagnosticLogSegregationContext; -import org.apache.lens.server.ui.UIApp; import org.apache.hadoop.hive.conf.HiveConf; @@ -93,19 +92,9 @@ public class LensServer { adminCtx .setAttribute("com.codahale.metrics.servlets.MetricsServlet.registry", (metricsService.getMetricRegistry())); adminCtx.setAttribute("com.codahale.metrics.servlets.HealthCheckServlet.registry", metricsService.getHealthCheck()); - final ServletRegistration sgMetrics = adminCtx.addServlet("admin", new AdminServlet()); sgMetrics.addMapping("/admin/*"); - adminCtx.deploy(server); - - if (conf.getBoolean(LensConfConstants.SERVER_UI_ENABLE, - LensConfConstants.DEFAULT_SERVER_UI_ENABLE)) { - String uiServerURI = conf.get(LensConfConstants.SERVER_UI_URI, LensConfConstants.DEFAULT_SERVER_UI_URI); - HttpServer uiServer = GrizzlyHttpServerFactory.createHttpServer(UriBuilder.fromUri(uiServerURI).build(), - getUIApp(), false); - serverList.add(uiServer); - } } private ResourceConfig getApp() { @@ -119,12 +108,6 @@ public class LensServer { return app; } - private ResourceConfig getUIApp() { - ResourceConfig uiApp = ResourceConfig.forApplicationClass(UIApp.class); - uiApp.setApplicationName("Lens UI"); - return uiApp; - } - /** * Start services. * http://git-wip-us.apache.org/repos/asf/lens/blob/b5763ff0/lens-server/src/main/java/org/apache/lens/server/LensServices.java ---------------------------------------------------------------------- diff --git a/lens-server/src/main/java/org/apache/lens/server/LensServices.java b/lens-server/src/main/java/org/apache/lens/server/LensServices.java index 7618669..56094e0 100644 --- a/lens-server/src/main/java/org/apache/lens/server/LensServices.java +++ b/lens-server/src/main/java/org/apache/lens/server/LensServices.java @@ -425,7 +425,7 @@ public class LensServices extends CompositeService implements ServiceProvider { //2. persist the latest state of all the services persistLensServiceState(); - }finally { + } finally { try { persistenceFS.close(); log.info("Persistence File system object close complete"); http://git-wip-us.apache.org/repos/asf/lens/blob/b5763ff0/lens-server/src/main/java/org/apache/lens/server/ui/MetastoreUIResource.java ---------------------------------------------------------------------- diff --git a/lens-server/src/main/java/org/apache/lens/server/ui/MetastoreUIResource.java b/lens-server/src/main/java/org/apache/lens/server/ui/MetastoreUIResource.java deleted file mode 100644 index 27388a7..0000000 --- a/lens-server/src/main/java/org/apache/lens/server/ui/MetastoreUIResource.java +++ /dev/null @@ -1,321 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.lens.server.ui; - -import java.util.List; -import java.util.UUID; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; - -import org.apache.lens.api.LensSessionHandle; -import org.apache.lens.api.metastore.*; -import org.apache.lens.server.LensServices; -import org.apache.lens.server.api.error.LensException; -import org.apache.lens.server.api.metastore.CubeMetastoreService; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import lombok.extern.slf4j.Slf4j; - -/** - * metastore UI resource api - * <p></p> - * This provides api for all things metastore UI. - */ - -@Path("metastoreapi") -@Slf4j -public class MetastoreUIResource { - - public CubeMetastoreService getSvc() { - return LensServices.get().getService(CubeMetastoreService.NAME); - } - - private void checkSessionHandle(LensSessionHandle sessionHandle) { - if (sessionHandle == null) { - throw new BadRequestException("Invalid session handle"); - } - } - - /** - * API to know if metastore service is up and running - * - * @return Simple text saying it up - */ - @GET - @Produces(MediaType.TEXT_PLAIN) - public String getMessage() { - return "Metastore is up"; - } - - /** - * Get all Cube names, Dimension Table names and Storage names - * - * @param publicId The publicId for the session in which user is working - * @return JSON string consisting of different table names and types - * @throws WebApplicationException wraps LensException - */ - @GET - @Path("tables") - @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - public String getAllTables(@QueryParam("publicId") UUID publicId) { - LensSessionHandle sessionHandle = SessionUIResource.getOpenSession(publicId); - checkSessionHandle(sessionHandle); - JSONArray tableList = new JSONArray(); - - List<String> cubes; - try { - cubes = getSvc().getAllCubeNames(sessionHandle); - } catch (LensException e) { - throw new WebApplicationException(e); - } - - if (cubes != null) { - for (String cube : cubes) { - try { - tableList.put(new JSONObject().put("name", cube).put("type", "cube")); - } catch (JSONException j) { - log.error("Error while parsing json", j); - } - } - } - - List<String> dimTables; - try { - dimTables = getSvc().getAllDimensionNames(sessionHandle); - } catch (LensException e) { - throw new WebApplicationException(e); - } - - if (dimTables != null) { - for (String dimTable : dimTables) { - try { - tableList.put(new JSONObject().put("name", dimTable).put("type", "dimtable")); - } catch (JSONException j) { - log.error("Error while parsing json", j); - } - } - } - - try { - List<String> nativeTables = getSvc().getAllNativeTableNames(sessionHandle, "all", null); - for (String nativeTable : nativeTables) { - tableList.put(new JSONObject().put("name", nativeTable).put("type", "native")); - } - } catch (Exception e) { - log.error("Error while getting all native tables", e); - } - - return tableList.toString(); - } - - - /** - * Gets metadata of a cube or dimension - * - * @param publicId The publicId for the session in which user is working - * @param name name of cube or dimension to be described - * @return JSON string consisting of different dimension and measure names and types - * @throws WebApplicationException wraps LensException - */ - @GET - @Path("tables/{name}") - @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - public String getDescription(@QueryParam("publicId") UUID publicId, @QueryParam("type") String type, - @PathParam("name") String name) { - LensSessionHandle sessionHandle = SessionUIResource.getOpenSession(publicId); - checkSessionHandle(sessionHandle); - JSONArray attribList = new JSONArray(); - if (type.equals("cube")) { - XBaseCube cube; - try { - cube = (XBaseCube) getSvc().getCube(sessionHandle, name); - } catch (LensException e) { - throw new WebApplicationException(e); - } - - if (cube.getMeasures() != null) { - for (XMeasure measure : cube.getMeasures().getMeasure()) { - try { - attribList.put(new JSONObject().put("name", measure.getName()).put("type", measure.getType())); - } catch (JSONException j) { - log.error("Error while parsing json", j); - } - } - } - if (cube.getDimAttributes() != null) { - for (XDimAttribute dim : cube.getDimAttributes().getDimAttribute()) { - try { - attribList.put(new JSONObject().put("name", dim.getName()).put("type", dim.getType())); - } catch (JSONException j) { - log.error("Error while parsing json", j); - } - } - } - } else if (type.equals("dimtable")) { - XDimension table; - try { - table = getSvc().getDimension(sessionHandle, name); - } catch (LensException e) { - throw new WebApplicationException(e); - } - if (table.getAttributes() != null) { - for (XDimAttribute col : table.getAttributes().getDimAttribute()) { - try { - attribList.put(new JSONObject().put("name", col.getName()).put("type", col.getType())); - } catch (JSONException j) { - log.error("Error while parsing json", j); - } - } - } - - if (table.getExpressions() != null) { - for (XExprColumn expr : table.getExpressions().getExpression()) { - try { - attribList.put(new JSONObject().put("name", expr.getName()).put("type", "expression") - .put("expression", expr.getExprSpec())); - } catch (JSONException j) { - log.error("Error while parsing json", j); - } - } - } - } - return attribList.toString(); - } - - /** - * Get all Table and column names and types which contain the search word - * - * @param publicId The publicId for the session in which user is working - * @param keyword keyword to be searched - * @return JSON string consisting of different table and column names and types - */ - @GET - @Path("searchablefields") - @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - public String getFilterResults(@QueryParam("publicId") UUID publicId, @QueryParam("keyword") String keyword) { - LensSessionHandle sessionHandle = SessionUIResource.getOpenSession(publicId); - checkSessionHandle(sessionHandle); - JSONArray tableList = null; - JSONArray searchResultList = new JSONArray(); - try { - - tableList = new JSONArray(getAllTables(publicId)); - } catch (JSONException j) { - log.error("Error while parsing json", j); - } - for (int item = 0; item < tableList.length(); item++) { - String name = null, type = null; - try { - name = tableList.getJSONObject(item).getString("name"); - type = tableList.getJSONObject(item).getString("type"); - } catch (JSONException j) { - log.error("Error while parsing json", j); - } - if (type.equals("cube")) { - JSONArray cubeAttribList = null; - JSONArray cubeSearchResultList = new JSONArray(); - try { - - cubeAttribList = new JSONArray(getDescription(publicId, "cube", name)); - } catch (JSONException j) { - log.error("Error while parsing json", j); - } - for (int col = 0; col < cubeAttribList.length(); col++) { - String colname = null, coltype = null; - try { - colname = cubeAttribList.getJSONObject(col).getString("name"); - coltype = cubeAttribList.getJSONObject(col).getString("type"); - - } catch (JSONException j) { - log.error("Error while parsing json", j); - } - if (colname.contains(keyword)) { - try { - cubeSearchResultList.put(new JSONObject().put("name", colname).put("type", coltype)); - } catch (JSONException j) { - log.error("Error while parsing json", j); - } - } - } - if (cubeSearchResultList.length() > 0) { - try { - searchResultList.put(new JSONObject().put("name", name).put("type", type).put("columns", - cubeSearchResultList)); - } catch (JSONException j) { - log.error("Error while parsing json", j); - } - } else if (name.contains(keyword)) { - try { - searchResultList.put(new JSONObject().put("name", name).put("type", type).put("columns", - cubeSearchResultList)); - } catch (JSONException j) { - log.error("Error while parsing json", j); - } - } - } else if (type.equals("dimtable")) { - JSONArray dimAttribList = null; - JSONArray dimSearchResultList = new JSONArray(); - try { - - dimAttribList = new JSONArray(getDescription(publicId, "dimtable", name)); - } catch (JSONException j) { - log.error("Error while parsing json", j); - } - for (int col = 0; col < dimAttribList.length(); col++) { - String colname = null, coltype = null; - try { - colname = dimAttribList.getJSONObject(col).getString("name"); - coltype = dimAttribList.getJSONObject(col).getString("type"); - - } catch (JSONException j) { - log.error("Error while parsing json", j); - } - if (colname.contains(keyword)) { - try { - dimSearchResultList.put(new JSONObject().put("name", colname).put("type", coltype)); - } catch (JSONException j) { - log.error("Error while parsing json", j); - } - } - } - if (dimSearchResultList.length() > 0) { - try { - searchResultList.put(new JSONObject().put("name", name).put("type", type).put("columns", - dimSearchResultList)); - } catch (JSONException j) { - log.error("Error while parsing json", j); - } - } else if (name.contains(keyword)) { - try { - searchResultList.put(new JSONObject().put("name", name).put("type", type).put("columns", - dimSearchResultList)); - } catch (JSONException j) { - log.error("Error while parsing json", j); - } - } - } - } - return searchResultList.toString(); - } -} - http://git-wip-us.apache.org/repos/asf/lens/blob/b5763ff0/lens-server/src/main/java/org/apache/lens/server/ui/QueryServiceUIResource.java ---------------------------------------------------------------------- diff --git a/lens-server/src/main/java/org/apache/lens/server/ui/QueryServiceUIResource.java b/lens-server/src/main/java/org/apache/lens/server/ui/QueryServiceUIResource.java deleted file mode 100644 index 304dc8e..0000000 --- a/lens-server/src/main/java/org/apache/lens/server/ui/QueryServiceUIResource.java +++ /dev/null @@ -1,269 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.lens.server.ui; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.apache.lens.api.APIResult; -import org.apache.lens.api.LensConf; -import org.apache.lens.api.LensSessionHandle; -import org.apache.lens.api.query.*; -import org.apache.lens.server.LensServices; -import org.apache.lens.server.api.error.LensException; -import org.apache.lens.server.api.query.QueryExecutionService; - -import org.apache.commons.lang.StringUtils; - -import org.glassfish.jersey.media.multipart.FormDataParam; - -import lombok.extern.slf4j.Slf4j; - -/** - * The Class QueryServiceUIResource. - */ -@Path("/queryuiapi") -@Slf4j -public class QueryServiceUIResource { - - /** The query server. */ - private QueryExecutionService queryServer; - - // assert: query is not empty - - /** - * Check query. - * - * @param query the query - */ - private void checkQuery(String query) { - if (StringUtils.isBlank(query)) { - throw new BadRequestException("Invalid query"); - } - } - - // assert: sessionHandle is not null - - /** - * Check session handle. - * - * @param sessionHandle the session handle - */ - private void checkSessionHandle(LensSessionHandle sessionHandle) { - if (sessionHandle == null) { - throw new BadRequestException("Invalid session handle"); - } - } - - /** - * Instantiates a new query service ui resource. - */ - public QueryServiceUIResource() { - log.info("Query UI Service"); - queryServer = LensServices.get().getService(QueryExecutionService.NAME); - } - - /** - * Gets the query handle. - * - * @param queryHandle the query handle - * @return the query handle - */ - private QueryHandle getQueryHandle(String queryHandle) { - try { - return QueryHandle.fromString(queryHandle); - } catch (Exception e) { - throw new BadRequestException("Invalid query handle: " + queryHandle, e); - } - } - - /** - * Get all the queries in the query server; can be filtered with state and user. - * - * @param publicId The public id of the session in which user is working - * @param state If any state is passed, all the queries in that state will be returned, otherwise all queries will - * be returned. Possible states are {@link org.apache.lens.api.query.QueryStatus.Status#values()} - * @param user return queries matching the user. If set to "all", return queries of all users. By default, - * returns queries of the current user. - * @param driver Get queries submitted on a specific driver. - * @param queryName human readable query name set by user (optional) - * @param fromDate the from date - * @param toDate the to date - * @return List of {@link QueryHandle} objects - */ - @GET - @Path("queries") - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) - public List<QueryHandle> getAllQueries(@QueryParam("publicId") UUID publicId, - @DefaultValue("") @QueryParam("state") String state, @DefaultValue("") @QueryParam("user") String user, - @DefaultValue("") @QueryParam("driver") String driver, @DefaultValue("") @QueryParam("queryName") String queryName, - @DefaultValue("-1") @QueryParam("fromDate") long fromDate, @DefaultValue("-1") @QueryParam("toDate") long toDate) { - LensSessionHandle sessionHandle = SessionUIResource.getOpenSession(publicId); - checkSessionHandle(sessionHandle); - try { - return queryServer.getAllQueries(sessionHandle, state, user, driver, queryName, fromDate, - toDate == -1L ? Long.MAX_VALUE : toDate); - } catch (LensException e) { - throw new WebApplicationException(e); - } - } - - /** - * Submit the query for explain or execute or execute with a timeout. - * - * @param publicId The public id of the session in which user is submitting the query. Any configuration set in the - * session will be picked up. - * @param query The query to run - * @param queryName human readable query name set by user (optional) - * @return {@link QueryHandle} - */ - @POST - @Path("queries") - @Consumes({MediaType.MULTIPART_FORM_DATA}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) - public QuerySubmitResult query(@FormDataParam("publicId") UUID publicId, @FormDataParam("query") String query, - @DefaultValue("") @FormDataParam("queryName") String queryName) { - LensSessionHandle sessionHandle = SessionUIResource.getOpenSession(publicId); - checkSessionHandle(sessionHandle); - LensConf conf; - checkQuery(query); - try { - conf = new LensConf(); - return queryServer.executeAsync(sessionHandle, query, conf, queryName); - } catch (LensException e) { - throw new WebApplicationException(e); - } - } - - /** - * Get lens query and its current status. - * - * @param publicId The public id of session handle - * @param queryHandle The query handle - * @return {@link LensQuery} - */ - @GET - @Path("queries/{queryHandle}") - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) - public LensQuery getStatus(@QueryParam("publicId") UUID publicId, @PathParam("queryHandle") String queryHandle) { - LensSessionHandle sessionHandle = SessionUIResource.getOpenSession(publicId); - checkSessionHandle(sessionHandle); - try { - return queryServer.getQuery(sessionHandle, getQueryHandle(queryHandle)); - } catch (LensException e) { - throw new WebApplicationException(e); - } - } - - /** - * Fetch the result set. - * - * @param publicId The public id of user's session handle - * @param queryHandle The query handle - * @param pageNumber page number of the query result set to be read - * @param fetchSize fetch size - * @return {@link ResultRow} - */ - @GET - @Path("queries/{queryHandle}/resultset") - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) - public ResultRow getResultSet(@QueryParam("publicId") UUID publicId, @PathParam("queryHandle") String queryHandle, - @QueryParam("pageNumber") int pageNumber, @QueryParam("fetchsize") int fetchSize) { - LensSessionHandle sessionHandle = SessionUIResource.getOpenSession(publicId); - checkSessionHandle(sessionHandle); - List<Object> rows = new ArrayList<Object>(); - log.info("FetchResultSet for queryHandle:{}", queryHandle); - try { - QueryResultSetMetadata resultSetMetadata = queryServer.getResultSetMetadata(sessionHandle, - getQueryHandle(queryHandle)); - List<ResultColumn> metaColumns = resultSetMetadata.getColumns(); - List<Object> metaResultColumns = new ArrayList<Object>(); - for (ResultColumn column : metaColumns) { - metaResultColumns.add(column.getName()); - } - rows.add(new ResultRow(metaResultColumns)); - QueryResult result = queryServer.fetchResultSet(sessionHandle, getQueryHandle(queryHandle), (pageNumber - 1) - * fetchSize, fetchSize); - if (result instanceof InMemoryQueryResult) { - InMemoryQueryResult inMemoryQueryResult = (InMemoryQueryResult) result; - List<ResultRow> tableRows = inMemoryQueryResult.getRows(); - rows.addAll(tableRows); - } else if (result instanceof PersistentQueryResult) { - PersistentQueryResult persistentQueryResult = (PersistentQueryResult) result; - rows.add("PersistentResultSet"); - } - return new ResultRow(rows); - } catch (LensException e) { - throw new WebApplicationException(e); - } - } - - /** - * Cancel the query specified by the handle. - * - * @param publicId The user session handle - * @param queryHandle The query handle - * @return APIResult with state {@link org.apache.lens.api.APIResult.Status#SUCCEEDED} in case of successful - * cancellation. APIResult with state {@link org.apache.lens.api.APIResult.Status#FAILED} in case of cancellation - * failure. - */ - @DELETE - @Path("queries/{queryHandle}") - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) - public APIResult cancelQuery(@QueryParam("sessionid") UUID publicId, @PathParam("queryHandle") String queryHandle) { - LensSessionHandle sessionHandle = SessionUIResource.getOpenSession(publicId); - checkSessionHandle(sessionHandle); - try { - boolean ret = queryServer.cancelQuery(sessionHandle, getQueryHandle(queryHandle)); - if (ret) { - return new APIResult(APIResult.Status.SUCCEEDED, "Cancel on the query " + queryHandle + " is successful"); - } else { - return new APIResult(APIResult.Status.FAILED, "Cancel on the query " + queryHandle + " failed"); - } - } catch (LensException e) { - throw new WebApplicationException(e); - } - } - - /** - * Get the http endpoint for result set. - * - * @param publicId the public id - * @param queryHandle The query handle - * @return Response with result as octet stream - */ - @GET - @Path("queries/{queryHandle}/httpresultset") - @Produces({MediaType.APPLICATION_OCTET_STREAM}) - public Response getHttpResultSet(@QueryParam("sessionid") UUID publicId, - @PathParam("queryHandle") String queryHandle) { - LensSessionHandle sessionHandle = SessionUIResource.getOpenSession(publicId); - checkSessionHandle(sessionHandle); - try { - return queryServer.getHttpResultSet(sessionHandle, getQueryHandle(queryHandle)); - } catch (LensException e) { - throw new WebApplicationException(e); - } - } -} http://git-wip-us.apache.org/repos/asf/lens/blob/b5763ff0/lens-server/src/main/java/org/apache/lens/server/ui/SessionUIResource.java ---------------------------------------------------------------------- diff --git a/lens-server/src/main/java/org/apache/lens/server/ui/SessionUIResource.java b/lens-server/src/main/java/org/apache/lens/server/ui/SessionUIResource.java deleted file mode 100644 index 37bf094..0000000 --- a/lens-server/src/main/java/org/apache/lens/server/ui/SessionUIResource.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.lens.server.ui; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; - -import org.apache.lens.api.APIResult; -import org.apache.lens.api.APIResult.Status; -import org.apache.lens.api.LensConf; -import org.apache.lens.api.LensSessionHandle; -import org.apache.lens.server.LensServices; -import org.apache.lens.server.api.error.LensException; -import org.apache.lens.server.api.session.SessionService; - -import org.glassfish.jersey.media.multipart.FormDataParam; - -import lombok.extern.slf4j.Slf4j; - -/** - * Session resource api - * <p></p> - * This provides api for all things in session. - */ -@Path("/uisession") -@Slf4j -public class SessionUIResource { - - /** The open sessions. */ - private static HashMap<UUID, LensSessionHandle> openSessions - = new HashMap<UUID, LensSessionHandle>(); - - /** The session service. */ - private SessionService sessionService; - - /** - * get open session from uuid - * @param id - * @return - */ - public static LensSessionHandle getOpenSession(UUID id) { - return openSessions.get(id); - } - - /** - * API to know if session service is up and running - * - * @return Simple text saying it up - */ - @GET - @Produces({MediaType.TEXT_PLAIN}) - public String getMessage() { - return "session is up!"; - } - - /** - * Instantiates a new session ui resource. - * - * @throws LensException the lens exception - */ - public SessionUIResource() throws LensException { - sessionService = LensServices.get().getService(SessionService.NAME); - } - - /** - * Check session handle. - * - * @param sessionHandle the session handle - */ - private void checkSessionHandle(LensSessionHandle sessionHandle) { - if (sessionHandle == null) { - throw new BadRequestException("Invalid session handle"); - } - } - - /** - * Create a new session with Lens server. - * - * @param username User name of the Lens server user - * @param password Password of the Lens server user - * @param database (Optional) Set current database to supplied value - * @param sessionconf Key-value properties which will be used to configure this session - * @return A Session handle unique to this session - */ - @POST - @Consumes({MediaType.MULTIPART_FORM_DATA}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) - public LensSessionHandle openSession(@FormDataParam("username") String username, - @FormDataParam("password") String password, - @FormDataParam("database") @DefaultValue("") String database, - @FormDataParam("sessionconf") LensConf sessionconf) { - try { - Map<String, String> conf; - if (sessionconf != null) { - conf = sessionconf.getProperties(); - } else { - conf = new HashMap<String, String>(); - } - LensSessionHandle handle = sessionService.openSession(username, password, database, conf); - openSessions.put(handle.getPublicId(), handle); - return handle; - } catch (LensException e) { - throw new WebApplicationException(e); - } - } - - /** - * Close a Lens server session. - * - * @param publicId Session's public id of the session to be closed - * @return APIResult object indicating if the operation was successful (check result.getStatus()) - */ - @DELETE - @Path("{publicId}") - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) - public APIResult closeSession(@PathParam("publicId") UUID publicId) { - log.info("Closing session with id: {}", publicId); - LensSessionHandle sessionHandle = getOpenSession(publicId); - checkSessionHandle(sessionHandle); - openSessions.remove(publicId); - try { - sessionService.closeSession(sessionHandle); - } catch (LensException e) { - return new APIResult(Status.FAILED, e.getMessage()); - } - return new APIResult(Status.SUCCEEDED, "Close session with id" + sessionHandle + "succeeded"); - } -} http://git-wip-us.apache.org/repos/asf/lens/blob/b5763ff0/lens-server/src/main/java/org/apache/lens/server/ui/StaticFileResource.java ---------------------------------------------------------------------- diff --git a/lens-server/src/main/java/org/apache/lens/server/ui/StaticFileResource.java b/lens-server/src/main/java/org/apache/lens/server/ui/StaticFileResource.java deleted file mode 100644 index 7e07589..0000000 --- a/lens-server/src/main/java/org/apache/lens/server/ui/StaticFileResource.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.lens.server.ui; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.concurrent.TimeUnit; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.apache.lens.server.LensServices; -import org.apache.lens.server.api.LensConfConstants; - -import org.apache.hadoop.hive.conf.HiveConf; - -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.io.Files; - -/** - * The Class StaticFileResource. - */ -@Path("/") -public class StaticFileResource { - - // Cache for file content, bound by both size and time - /** The Constant CONTENT_CACHE. */ - private static final LoadingCache<String, String> CONTENT_CACHE = CacheBuilder.newBuilder().maximumSize(100) - .expireAfterAccess(10, TimeUnit.MINUTES).build(new CacheLoader<String, String>() { - String baseDir = null; - - @Override - public String load(String filePath) throws Exception { - if (baseDir == null) { - baseDir = LensServices.get().getHiveConf() - .get(LensConfConstants.SERVER_UI_STATIC_DIR, LensConfConstants.DEFAULT_SERVER_UI_STATIC_DIR); - } - return loadFile(baseDir, filePath); - } - }); - - /** - * Load file. - * - * @param baseDir the base dir - * @param filePath the file path - * @return the string - * @throws IOException Signals that an I/O exception has occurred. - */ - private static String loadFile(String baseDir, String filePath) throws IOException { - return Files.toString(new File(baseDir, filePath), Charset.forName("UTF-8")); - } - - /** - * Gets the static resource. - * - * @param filePath the file path - * @return the static resource - */ - @GET - @Path("/{filePath:.*}") - public Response getStaticResource(@PathParam("filePath") String filePath) { - try { - HiveConf conf = LensServices.get().getHiveConf(); - if (conf.getBoolean(LensConfConstants.SERVER_UI_ENABLE_CACHING, - LensConfConstants.DEFAULT_SERVER_UI_ENABLE_CACHING)) { - return Response.ok(CONTENT_CACHE.get(filePath), getMediaType(filePath)).build(); - } else { - // This is for dev mode - String baseDir = conf.get(LensConfConstants.SERVER_UI_STATIC_DIR, - LensConfConstants.DEFAULT_SERVER_UI_STATIC_DIR); - return Response.ok(loadFile(baseDir, filePath), getMediaType(filePath)).build(); - } - } catch (Exception e) { - if (e.getCause() instanceof FileNotFoundException || e instanceof FileNotFoundException) { - throw new NotFoundException("Not Found: " + filePath); - } - throw new WebApplicationException("Server error: " + e.getCause(), e); - } - } - - /** - * Gets the media type. - * - * @param filePath the file path - * @return the media type - */ - private String getMediaType(String filePath) { - if (filePath == null) { - return null; - } - - if (filePath.endsWith(".html")) { - return MediaType.TEXT_HTML; - } else if (filePath.endsWith(".js")) { - return "application/javascript"; - } else if (filePath.endsWith(".css")) { - return "text/css"; - } - return null; - } -} http://git-wip-us.apache.org/repos/asf/lens/blob/b5763ff0/lens-server/src/main/java/org/apache/lens/server/ui/UIApp.java ---------------------------------------------------------------------- diff --git a/lens-server/src/main/java/org/apache/lens/server/ui/UIApp.java b/lens-server/src/main/java/org/apache/lens/server/ui/UIApp.java deleted file mode 100644 index de4ce33..0000000 --- a/lens-server/src/main/java/org/apache/lens/server/ui/UIApp.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.lens.server.ui; - -import java.util.Set; - -import javax.ws.rs.ApplicationPath; - -import org.apache.lens.server.BaseApp; - -/** - * The Class UIApp. - */ -@ApplicationPath("/ui") -public class UIApp extends BaseApp { - - @Override - protected Class getResource() { - return StaticFileResource.class; - } - - public Set<Class<?>> getClasses() { - final Set<Class<?>> classes = super.getClasses(); - classes.add(QueryServiceUIResource.class); - classes.add(SessionUIResource.class); - classes.add(MetastoreUIResource.class); - return classes; - } - -} http://git-wip-us.apache.org/repos/asf/lens/blob/b5763ff0/lens-server/src/main/resources/lensserver-default.xml ---------------------------------------------------------------------- diff --git a/lens-server/src/main/resources/lensserver-default.xml b/lens-server/src/main/resources/lensserver-default.xml index 3ce8fc1..fa2d0dd 100644 --- a/lens-server/src/main/resources/lensserver-default.xml +++ b/lens-server/src/main/resources/lensserver-default.xml @@ -102,30 +102,6 @@ </property> <property> - <name>lens.server.ui.base.uri</name> - <value>http://0.0.0.0:19999/</value> - <description>The base url for the Lens UI Server</description> - </property> - - <property> - <name>lens.server.ui.static.dir</name> - <value>webapp/lens-server/static</value> - <description>The base directory to server UI static files from</description> - </property> - - <property> - <name>lens.server.ui.enable</name> - <value>true</value> - <description>Bringing up the ui server is optional. By default it brings up UI server.</description> - </property> - - <property> - <name>lens.server.ui.enable.caching</name> - <value>true</value> - <description>Set this to false to disable static file caching in the UI server</description> - </property> - - <property> <name>lens.server.query.state.logger.enabled</name> <value>true</value> <description>Disable or enable the query state logger with this config. http://git-wip-us.apache.org/repos/asf/lens/blob/b5763ff0/lens-server/src/test/java/org/apache/lens/server/TestLensServer.java ---------------------------------------------------------------------- diff --git a/lens-server/src/test/java/org/apache/lens/server/TestLensServer.java b/lens-server/src/test/java/org/apache/lens/server/TestLensServer.java deleted file mode 100644 index eb27f61..0000000 --- a/lens-server/src/test/java/org/apache/lens/server/TestLensServer.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.lens.server; - -import java.io.IOException; - -import org.apache.lens.server.api.LensConfConstants; - -import org.apache.hadoop.hive.conf.HiveConf; - -import org.testng.Assert; -import org.testng.annotations.Test; - -public class TestLensServer { - - /** - * Test UI server - */ - @Test - public void testUIServer() throws IOException { - HiveConf conf = LensServerConf.createHiveConf(); - LensServer thisServer = LensServer.createLensServer(conf); - Assert.assertEquals(thisServer.getServerList().size(), 2); - - conf.set(LensConfConstants.SERVER_UI_ENABLE, "false"); - thisServer = LensServer.createLensServer(conf); - Assert.assertEquals(thisServer.getServerList().size(), 1); - } -} http://git-wip-us.apache.org/repos/asf/lens/blob/b5763ff0/lens-server/src/test/java/org/apache/lens/server/TestStaticFileResource.java ---------------------------------------------------------------------- diff --git a/lens-server/src/test/java/org/apache/lens/server/TestStaticFileResource.java b/lens-server/src/test/java/org/apache/lens/server/TestStaticFileResource.java deleted file mode 100644 index f8c5bf2..0000000 --- a/lens-server/src/test/java/org/apache/lens/server/TestStaticFileResource.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.lens.server; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; -import java.util.Set; - -import javax.ws.rs.core.Application; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; - -import org.apache.lens.server.api.LensConfConstants; -import org.apache.lens.server.ui.UIApp; - -import org.glassfish.jersey.filter.LoggingFilter; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -/** - * The Class TestStaticFileResource. - */ -@Test(groups = "unit-test") -public class TestStaticFileResource extends LensJerseyTest { - - /* - * (non-Javadoc) - * - * @see org.glassfish.jersey.test.JerseyTest#setUp() - */ - @BeforeTest - public void setUp() throws Exception { - super.setUp(); - } - - /* - * (non-Javadoc) - * - * @see org.glassfish.jersey.test.JerseyTest#tearDown() - */ - @AfterTest - public void tearDown() throws Exception { - super.tearDown(); - } - - /* - * (non-Javadoc) - * - * @see org.glassfish.jersey.test.JerseyTest#configure() - */ - @Override - protected Application configure() { - return new UIApp() { - @Override - public Set<Class<?>> getClasses() { - Set<Class<?>> classes = super.getClasses(); - classes.add(LoggingFilter.class); - return classes; - } - }; - } - - @Override - protected URI getUri() { - return UriBuilder.fromUri("http://localhost/").port(getTestPort()).build(); - } - - @Override - protected URI getBaseUri() { - return getUri(); - } - - /** - * Test static file resource. - * - * @throws Exception the exception - */ - @Test - public void testStaticFileResource() throws Exception { - LensServices.get().getHiveConf().set(LensConfConstants.SERVER_UI_STATIC_DIR, "src/main/webapp/static"); - LensServices.get().getHiveConf().setBoolean(LensConfConstants.SERVER_UI_ENABLE_CACHING, false); - - System.out.println("@@@@ " + target().path("index.html").getUri()); - Response response = target().path("index.html").request().get(); - assertEquals(response.getStatus(), 200); - - response = target().path("index234.html").request().get(); - assertEquals(response.getStatus(), 404); - } - -} http://git-wip-us.apache.org/repos/asf/lens/blob/b5763ff0/lens-server/src/test/java/org/apache/lens/server/ui/TestSessionUIResource.java ---------------------------------------------------------------------- diff --git a/lens-server/src/test/java/org/apache/lens/server/ui/TestSessionUIResource.java b/lens-server/src/test/java/org/apache/lens/server/ui/TestSessionUIResource.java deleted file mode 100644 index aa28747..0000000 --- a/lens-server/src/test/java/org/apache/lens/server/ui/TestSessionUIResource.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.lens.server.ui; - -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.Application; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.apache.lens.api.LensConf; -import org.apache.lens.api.LensSessionHandle; -import org.apache.lens.server.LensJerseyTest; -import org.apache.lens.server.api.error.LensException; - -import org.glassfish.jersey.media.multipart.FormDataBodyPart; -import org.glassfish.jersey.media.multipart.FormDataContentDisposition; -import org.glassfish.jersey.media.multipart.FormDataMultiPart; - -import org.testng.Assert; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -/** - * The Class TestSessionUIResource. - */ -@Test(groups = "unit-test") -public class TestSessionUIResource extends LensJerseyTest { - - /* - * (non-Javadoc) - * - * @see org.glassfish.jersey.test.JerseyTest#setUp() - */ - @BeforeTest - public void setUp() throws Exception { - super.setUp(); - } - - /* - * (non-Javadoc) - * - * @see org.glassfish.jersey.test.JerseyTest#tearDown() - */ - @AfterTest - public void tearDown() throws Exception { - super.tearDown(); - } - - /* - * (non-Javadoc) - * - * @see org.glassfish.jersey.test.JerseyTest#configure() - */ - @Override - protected Application configure() { - return new UIApp(); - } - - private FormDataMultiPart getMultiFormData(String username, String password) { - final FormDataMultiPart mp = new FormDataMultiPart(); - - mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("username").build(), username)); - mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("password").build(), password)); - mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionconf").fileName("sessionconf").build(), - new LensConf(), MediaType.APPLICATION_XML_TYPE)); - return mp; - } - - /** - * Test ui session - */ - @Test - public void testUISession() throws LensException { - final WebTarget target = target().path("uisession"); - FormDataMultiPart mp = getMultiFormData("UITest", "UITest"); - - LensSessionHandle lensSessionHandle = target.request().post( - Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), LensSessionHandle.class); - Assert.assertTrue(lensSessionHandle != null); - - Response deleteResponse = target.path(lensSessionHandle.getPublicId().toString()).request().delete(); - Assert.assertEquals(deleteResponse.getStatus(), 200); - } - - @Test - public void testJsonResponsesFromServer() { - final WebTarget target = target().path("uisession"); - FormDataMultiPart mp = getMultiFormData("UITest", "UITest"); - - Response response = target.request().accept(MediaType.APPLICATION_JSON). - post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE)); - Assert.assertEquals(response.getStatus(), 200); - Assert.assertEquals(response.getMediaType().toString(), "application/json"); - } - - @Test - public void testXMLResponsesFromServer() { - final WebTarget target = target().path("uisession"); - FormDataMultiPart mp = getMultiFormData("UITest", "UITest"); - - Response response = target.request().accept(MediaType.APPLICATION_XML). - post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE)); - Assert.assertEquals(response.getStatus(), 200); - Assert.assertEquals(response.getMediaType().toString(), "application/xml"); - } -}
