List of usage examples for javax.activation MimeType MimeType
public MimeType(String rawdata) throws MimeTypeParseException
From source file:com.portfolio.rest.RestServicePortfolio.java
@Path("/nodes/node/{node-id}") @PUT//from w w w .j a v a 2s . co m @Produces(MediaType.APPLICATION_XML) public String putNode(String xmlNode, @CookieParam("user") String user, @CookieParam("credential") String token, @QueryParam("group") int groupId, @PathParam("node-id") String nodeUuid, @Context ServletConfig sc, @Context HttpServletRequest httpServletRequest, @QueryParam("user") Integer userId) { UserInfo ui = checkCredential(httpServletRequest, user, token, null); try { String returnValue = dataProvider .putNode(new MimeType("text/xml"), nodeUuid, xmlNode, ui.userId, groupId).toString(); if (returnValue.equals("faux")) { throw new RestWebApplicationException(Status.FORBIDDEN, "Vous n'avez pas les droits necessaires"); } logRestRequest(httpServletRequest, xmlNode, returnValue, Status.OK.getStatusCode()); return returnValue; } catch (RestWebApplicationException ex) { throw new RestWebApplicationException(Status.FORBIDDEN, ex.getResponse().getEntity().toString()); } catch (SQLException ex) { logRestRequest(httpServletRequest, xmlNode, null, Status.NOT_FOUND.getStatusCode()); throw new RestWebApplicationException(Status.NOT_FOUND, "Node " + nodeUuid + " not found"); } catch (Exception ex) { ex.printStackTrace(); logRestRequest(httpServletRequest, xmlNode, ex.getMessage() + "\n\n" + javaUtils.getCompleteStackTrace(ex), Status.INTERNAL_SERVER_ERROR.getStatusCode()); throw new RestWebApplicationException(Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { dataProvider.disconnect(); } }
From source file:com.portfolio.rest.RestServicePortfolio.java
@Path("/nodes/node/{nodeid}/metadata") @PUT/*from w ww.java2s . c o m*/ @Produces(MediaType.APPLICATION_XML) public String putNodeMetadata(String xmlNode, @CookieParam("user") String user, @CookieParam("credential") String token, @QueryParam("group") int groupId, @PathParam("nodeid") String nodeUuid, @Context ServletConfig sc, @Context HttpServletRequest httpServletRequest) { UserInfo ui = checkCredential(httpServletRequest, user, token, null); try { String returnValue = dataProvider .putNodeMetadata(new MimeType("text/xml"), nodeUuid, xmlNode, ui.userId, groupId).toString(); if (returnValue.equals("faux")) { throw new RestWebApplicationException(Status.FORBIDDEN, "Vous n'avez pas les droits necessaires"); } logRestRequest(httpServletRequest, xmlNode, returnValue, Status.OK.getStatusCode()); return returnValue; } catch (RestWebApplicationException ex) { throw new RestWebApplicationException(Status.FORBIDDEN, ex.getResponse().getEntity().toString()); } catch (SQLException ex) { logRestRequest(httpServletRequest, xmlNode, null, Status.NOT_FOUND.getStatusCode()); throw new RestWebApplicationException(Status.NOT_FOUND, "Node " + nodeUuid + " not found"); } catch (Exception ex) { ex.printStackTrace(); logRestRequest(httpServletRequest, xmlNode, ex.getMessage() + "\n\n" + javaUtils.getCompleteStackTrace(ex), Status.INTERNAL_SERVER_ERROR.getStatusCode()); throw new RestWebApplicationException(Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { dataProvider.disconnect(); } }
From source file:com.portfolio.rest.RestServicePortfolio.java
@Path("/nodes/node/{nodeid}/metadatawad") @PUT/* w ww . j a v a 2 s.c o m*/ @Produces(MediaType.APPLICATION_XML) public String putNodeMetadataWad(String xmlNode, @CookieParam("user") String user, @CookieParam("credential") String token, @QueryParam("group") int groupId, @PathParam("nodeid") String nodeUuid, @Context ServletConfig sc, @Context HttpServletRequest httpServletRequest) { UserInfo ui = checkCredential(httpServletRequest, user, token, null); try { String returnValue = dataProvider .putNodeMetadataWad(new MimeType("text/xml"), nodeUuid, xmlNode, ui.userId, groupId).toString(); if (returnValue.equals("faux")) { throw new RestWebApplicationException(Status.FORBIDDEN, "Vous n'avez pas les droits necessaires"); } logRestRequest(httpServletRequest, xmlNode, returnValue, Status.OK.getStatusCode()); return returnValue; } catch (RestWebApplicationException ex) { throw new RestWebApplicationException(Status.FORBIDDEN, ex.getResponse().getEntity().toString()); } catch (SQLException ex) { logRestRequest(httpServletRequest, xmlNode, null, Status.NOT_FOUND.getStatusCode()); throw new RestWebApplicationException(Status.NOT_FOUND, "Node " + nodeUuid + " not found"); } catch (Exception ex) { ex.printStackTrace(); logRestRequest(httpServletRequest, xmlNode, ex.getMessage() + "\n\n" + javaUtils.getCompleteStackTrace(ex), Status.INTERNAL_SERVER_ERROR.getStatusCode()); throw new RestWebApplicationException(Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { dataProvider.disconnect(); } }
From source file:com.portfolio.rest.RestServicePortfolio.java
@Path("/nodes/node/{nodeid}/metadataepm") @PUT/*www . j av a2 s .c o m*/ @Produces(MediaType.APPLICATION_XML) public String putNodeMetadataEpm(String xmlNode, @PathParam("nodeid") String nodeUuid, @QueryParam("group") int groupId, @Context ServletConfig sc, @Context HttpServletRequest httpServletRequest) { UserInfo ui = checkCredential(httpServletRequest, null, null, null); try { String returnValue = dataProvider .putNodeMetadataEpm(new MimeType("text/xml"), nodeUuid, xmlNode, ui.userId, groupId).toString(); if (returnValue.equals("faux")) { throw new RestWebApplicationException(Status.FORBIDDEN, "Vous n'avez pas les droits necessaires"); } if ("erreur".equals(returnValue)) throw new RestWebApplicationException(Status.NOT_MODIFIED, "Erreur"); logRestRequest(httpServletRequest, xmlNode, returnValue, Status.OK.getStatusCode()); return returnValue; } catch (RestWebApplicationException ex) { throw new RestWebApplicationException(Status.FORBIDDEN, ex.getResponse().getEntity().toString()); } catch (SQLException ex) { logRestRequest(httpServletRequest, xmlNode, null, Status.NOT_FOUND.getStatusCode()); throw new RestWebApplicationException(Status.NOT_FOUND, "Node " + nodeUuid + " not found"); } catch (Exception ex) { ex.printStackTrace(); logRestRequest(httpServletRequest, xmlNode, ex.getMessage() + "\n\n" + javaUtils.getCompleteStackTrace(ex), Status.INTERNAL_SERVER_ERROR.getStatusCode()); throw new RestWebApplicationException(Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { dataProvider.disconnect(); } }
From source file:com.portfolio.rest.RestServicePortfolio.java
@Path("/nodes/node/{nodeid}/nodecontext") @PUT/*from w w w.j a v a 2s . c o m*/ @Produces(MediaType.APPLICATION_XML) public String putNodeNodeContext(String xmlNode, @CookieParam("user") String user, @CookieParam("credential") String token, @QueryParam("group") int groupId, @PathParam("nodeid") String nodeUuid, @Context ServletConfig sc, @Context HttpServletRequest httpServletRequest) { UserInfo ui = checkCredential(httpServletRequest, user, token, null); try { String returnValue = dataProvider .putNodeNodeContext(new MimeType("text/xml"), nodeUuid, xmlNode, ui.userId, groupId).toString(); if (returnValue.equals("faux")) { throw new RestWebApplicationException(Status.FORBIDDEN, "Vous n'avez pas les droits necessaires"); } logRestRequest(httpServletRequest, xmlNode, returnValue, Status.OK.getStatusCode()); return returnValue; } catch (RestWebApplicationException ex) { throw new RestWebApplicationException(Status.FORBIDDEN, ex.getResponse().getEntity().toString()); } catch (Exception ex) { ex.printStackTrace(); logRestRequest(httpServletRequest, xmlNode, ex.getMessage() + "\n\n" + javaUtils.getCompleteStackTrace(ex), Status.INTERNAL_SERVER_ERROR.getStatusCode()); throw new RestWebApplicationException(Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { dataProvider.disconnect(); } }
From source file:com.portfolio.rest.RestServicePortfolio.java
@Path("/nodes/node/{nodeid}/noderesource") @PUT// w ww . j a v a 2s.co m @Produces(MediaType.APPLICATION_XML) public String putNodeNodeResource(String xmlNode, @CookieParam("user") String user, @CookieParam("credential") String token, @QueryParam("group") int groupId, @PathParam("nodeid") String nodeUuid, @Context ServletConfig sc, @Context HttpServletRequest httpServletRequest) { UserInfo ui = checkCredential(httpServletRequest, user, token, null); try { /// Branchement pour l'interprtation du contenu, besoin de vrifier les limitations ? //xmlNode = xmlNode.getBytes("UTF-8").toString(); /// putNode(MimeType inMimeType, String nodeUuid, String in,int userId, int groupId) // String returnValue = dataProvider.putNode(new MimeType("text/xml"),nodeUuid,xmlNode,this.userId,this.groupId).toString(); String returnValue = dataProvider .putNodeNodeResource(new MimeType("text/xml"), nodeUuid, xmlNode, ui.userId, groupId) .toString(); if (returnValue.equals("faux")) { throw new RestWebApplicationException(Status.FORBIDDEN, "Vous n'avez pas les droits necessaires"); } logRestRequest(httpServletRequest, xmlNode, returnValue, Status.OK.getStatusCode()); return returnValue; } catch (RestWebApplicationException ex) { throw new RestWebApplicationException(Status.FORBIDDEN, ex.getResponse().getEntity().toString()); } catch (Exception ex) { ex.printStackTrace(); logRestRequest(httpServletRequest, xmlNode, ex.getMessage() + "\n\n" + javaUtils.getCompleteStackTrace(ex), Status.INTERNAL_SERVER_ERROR.getStatusCode()); throw new RestWebApplicationException(Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { dataProvider.disconnect(); } }
From source file:com.portfolio.rest.RestServicePortfolio.java
@Path("/nodes/node/import/{dest-id}") @POST/*from w ww.j ava2 s . c o m*/ public String postImportNode(String xmlNode, @CookieParam("user") String user, @CookieParam("credential") String token, @QueryParam("group") int groupId, @PathParam("dest-id") String parentId, @Context ServletConfig sc, @Context HttpServletRequest httpServletRequest, @QueryParam("srcetag") String semtag, @QueryParam("srcecode") String code) { UserInfo ui = checkCredential(httpServletRequest, user, token, null); try { String returnValue = dataProvider .postImportNode(new MimeType("text/xml"), parentId, semtag, code, ui.userId, groupId) .toString(); logRestRequest(httpServletRequest, xmlNode, returnValue, Status.OK.getStatusCode()); if (returnValue == "faux") { throw new RestWebApplicationException(Status.FORBIDDEN, "Vous n'avez pas les droits d'acces"); } return returnValue; } catch (RestWebApplicationException ex) { throw new RestWebApplicationException(Status.FORBIDDEN, ex.getResponse().getEntity().toString()); } catch (Exception ex) { ex.printStackTrace(); logRestRequest(httpServletRequest, xmlNode, ex.getMessage() + "\n\n" + javaUtils.getCompleteStackTrace(ex), Status.INTERNAL_SERVER_ERROR.getStatusCode()); throw new RestWebApplicationException(Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { dataProvider.disconnect(); } }
From source file:com.portfolio.rest.RestServicePortfolio.java
@Path("/nodes/node/copy/{dest-id}") @POST/* ww w. j a v a2 s . co m*/ public String postCopyNode(String xmlNode, @CookieParam("user") String user, @CookieParam("credential") String token, @QueryParam("group") int groupId, @PathParam("dest-id") String parentId, @Context ServletConfig sc, @Context HttpServletRequest httpServletRequest, @QueryParam("srcetag") String semtag, @QueryParam("srcecode") String code) { UserInfo ui = checkCredential(httpServletRequest, user, token, null); try { String returnValue = dataProvider .postCopyNode(new MimeType("text/xml"), parentId, semtag, code, ui.userId, groupId).toString(); logRestRequest(httpServletRequest, xmlNode, returnValue, Status.OK.getStatusCode()); if (returnValue == "faux") { throw new RestWebApplicationException(Status.FORBIDDEN, "Vous n'avez pas les droits d'acces"); } else if ("Selection non existante.".equals(returnValue)) { throw new RestWebApplicationException(Status.NOT_FOUND, "Selection non existante."); } return returnValue; } catch (RestWebApplicationException ex) { throw new RestWebApplicationException(Status.FORBIDDEN, ex.getResponse().getEntity().toString()); } catch (Exception ex) { ex.printStackTrace(); logRestRequest(httpServletRequest, xmlNode, ex.getMessage() + "\n\n" + javaUtils.getCompleteStackTrace(ex), Status.INTERNAL_SERVER_ERROR.getStatusCode()); throw new RestWebApplicationException(Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { dataProvider.disconnect(); } }
From source file:com.portfolio.rest.RestServicePortfolio.java
@Path("/nodes") @GET/*from w w w .java2s .c o m*/ @Produces({ MediaType.APPLICATION_XML }) @Consumes(MediaType.APPLICATION_XML) public String getNodes(@CookieParam("user") String user, @CookieParam("credential") String token, @QueryParam("group") int groupId, @PathParam("dest-id") String parentId, @Context ServletConfig sc, @Context HttpServletRequest httpServletRequest, @QueryParam("portfoliocode") String portfoliocode, @QueryParam("semtag") String semtag, @QueryParam("semtag_parent") String semtag_parent, @QueryParam("code_parent") String code_parent) { UserInfo ui = checkCredential(httpServletRequest, user, token, null); try { String returnValue = dataProvider.getNodes(new MimeType("text/xml"), portfoliocode, semtag, ui.userId, groupId, semtag_parent, code_parent).toString(); logRestRequest(httpServletRequest, "getNodes", returnValue, Status.OK.getStatusCode()); if (returnValue == "faux") { throw new RestWebApplicationException(Status.FORBIDDEN, "Vous n'avez pas les droits d'acces"); } else if ("".equals(returnValue)) { throw new RestWebApplicationException(Status.NOT_FOUND, "Portfolio inexistant"); } return returnValue; } catch (RestWebApplicationException ex) { throw ex; } catch (Exception ex) { ex.printStackTrace(); logRestRequest(httpServletRequest, "getNodes", ex.getMessage() + "\n\n" + javaUtils.getCompleteStackTrace(ex), Status.INTERNAL_SERVER_ERROR.getStatusCode()); // dataProvider.disconnect(); throw new RestWebApplicationException(Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { dataProvider.disconnect(); } }
From source file:com.portfolio.rest.RestServicePortfolio.java
@Path("/nodes/node/{parent-id}") @POST//w w w. ja v a 2 s.c om @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_XML) public Response postNode(String xmlNode, @CookieParam("user") String user, @CookieParam("credential") String token, @QueryParam("group") Integer group, @PathParam("parent-id") String parentId, @Context ServletConfig sc, @Context HttpServletRequest httpServletRequest, @QueryParam("user") Integer userId, @QueryParam("group") int groupId) { UserInfo ui = checkCredential(httpServletRequest, user, token, null); KEvent event = new KEvent(); event.requestType = KEvent.RequestType.POST; event.eventType = KEvent.EventType.NODE; event.uuid = parentId; event.inputData = xmlNode; try { String returnValue = dataProvider .postNode(new MimeType("text/xml"), parentId, xmlNode, ui.userId, groupId).toString(); logRestRequest(httpServletRequest, xmlNode, returnValue, Status.OK.getStatusCode()); Response response; if (returnValue == "faux") { response = Response.status(event.status).entity(event.message).type(event.mediaType).build(); throw new RestWebApplicationException(Status.FORBIDDEN, "Vous n'avez pas les droits d'acces"); } event.status = 200; response = Response.status(event.status).entity(returnValue).type(event.mediaType).build(); eventbus.processEvent(event); return response; } catch (RestWebApplicationException ex) { throw new RestWebApplicationException(Status.FORBIDDEN, ex.getResponse().getEntity().toString()); } catch (Exception ex) { ex.printStackTrace(); logRestRequest(httpServletRequest, xmlNode, ex.getMessage() + "\n\n" + javaUtils.getCompleteStackTrace(ex), Status.INTERNAL_SERVER_ERROR.getStatusCode()); throw new RestWebApplicationException(Status.INTERNAL_SERVER_ERROR, ex.getMessage()); } finally { dataProvider.disconnect(); } }