示例#1
0
 /**
  * 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");
 }
示例#2
0
 /**
  * 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);
   }
 }