コード例 #1
0
 /**
  * Post method for creating an instance of PrivacyPreferences using XML as the input format.
  *
  * @param data an PrivacyPreferencesConverter entity that is deserialized from an XML stream
  * @return an instance of PrivacyPreferencesConverter
  */
 @POST
 @Consumes({"application/xml", "application/json"})
 public Response post(PrivacyPreferencesConverter data) {
   PersistenceService persistenceSvc = PersistenceService.getInstance();
   try {
     persistenceSvc.beginTx();
     EntityManager em = persistenceSvc.getEntityManager();
     PrivacyPreferences entity = data.resolveEntity(em);
     createEntity(data.resolveEntity(em));
     persistenceSvc.commitTx();
     return Response.created(uriInfo.getAbsolutePath().resolve(entity.getId() + "/")).build();
   } finally {
     persistenceSvc.close();
   }
 }
コード例 #2
0
 /**
  * Get method for retrieving a collection of PrivacyPreferences instance in XML format.
  *
  * @return an instance of PrivacyPreferencessConverter
  */
 @Secured({"ROLE_ADMIN", "ADMIN_ACCESS"})
 @GET
 @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
 public PrivacyPreferencessConverter get(
     @QueryParam("start") @DefaultValue("0") int start,
     @QueryParam("max") @DefaultValue("10") int max,
     @QueryParam("expandLevel") @DefaultValue("1") int expandLevel,
     @QueryParam("query") @DefaultValue("SELECT e FROM PrivacyPreferences e") String query) {
   PersistenceService persistenceSvc = PersistenceService.getInstance();
   try {
     persistenceSvc.beginTx();
     return new PrivacyPreferencessConverter(
         getEntities(start, max, query), uriInfo.getAbsolutePath(), expandLevel);
   } finally {
     persistenceSvc.commitTx();
     persistenceSvc.close();
   }
 }