Changeset 6038
- Timestamp:
- 02/24/15 10:37:58 (9 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java
r6024 r6038 59 59 60 60 /** 61 * 61 * REST class for GETting, POSTing, PUTting and DELETing annotations or their substructures (child elements); 62 * Every REST method in the case of successful completion of its action outputs the declared output type 63 * (a JAXB-element or a message string) or sends a HTTP-error with the corresponding diagnostics otherwise. 62 64 * @author olhsha 63 65 */ -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AutheticationResource.java
r6013 r6038 35 35 36 36 /** 37 * 37 * REST class for GETting a logged in principal, log-in and log-out; 38 * Every REST method in the case of successful completion of its action outputs the declared output type 39 * (a JAXB-element or a message string) or sends a HTTP-error with the corresponding diagnostics otherwise. 38 40 * @author olhsha 39 41 */ -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/CachedRepresentationResource.java
r6014 r6038 52 52 53 53 /** 54 * 54 * REST class for GETting, POSTing and PUTting cached representations; 55 * DELETing cached representation is provided by TargetRsource class; 56 * Every REST method in the case of successful completion of its action outputs the declared output type 57 * (a JAXB-element or a message string) or sends a HTTP-error with the corresponding diagnostics otherwise. 55 58 * @author olhsha 56 59 */ -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/DebugResource.java
r6015 r6038 44 44 45 45 /** 46 * REST class for GETting information useful for debugging the back-end or a front-end; 47 * Every REST method in the case of successful completion of its action outputs the declared output type 48 * (a JAXB-element or a message string) or sends a HTTP-error with the corresponding diagnostics otherwise; 46 49 * The class is used only by "admin" and "developer" principals; these account types are set in "principal" table. 47 50 * @author olhsha -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/NotebookResource.java
r6021 r6038 47 47 48 48 /** 49 * Created on : Jun 11, 2013, 5:10:55 PM 50 * 51 * @author Peter Withers <peter.withers@mpi.nl> 49 * REST interface for GETting, POSTing, PUTting and DELETing notebooks or their substructures (child elements); 50 * Every REST method in the case of successful completion of its action outputs the declared output type 51 * (a JAXB-element or a message string) or sends a HTTP-error with the corresponding diagnostics otherwise. 52 * @author Peter Withers <peter.withers@mpi.nl>, olhsha@mpi.nl 52 53 */ 53 54 @Component -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/PrincipalResource.java
r6024 r6038 53 53 54 54 /** 55 * 56 * @author olhsha 55 * REST class for GETting, POSTing, PUTting and DELETing principals or their substructures (child elements); 56 * Every REST method in the case of successful completion of its action outputs the declared output type 57 * (a JAXB-element or a message string) or sends a HTTP-error with the corresponding diagnostics otherwise. 58 * @author olhsha 57 59 */ 58 60 @Component -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/ProjectInfoResource.java
r6021 r6038 30 30 31 31 /** 32 * 32 * A help REST class so far containing only one method outputting the backend-version number. 33 33 * @author olhsha 34 34 */ … … 38 38 public class ProjectInfoResource extends ResourceResource{ 39 39 40 /** 41 * 42 * @return a message string containing the number of the version of the backend. 43 * @throws IOException if getting a principal or sending the error fails.s 44 */ 40 45 @GET 41 46 @Produces(MediaType.TEXT_PLAIN) -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/RequestWrappers.java
r5850 r6038 33 33 34 34 /** 35 * 35 * Different requests for different resources still have some steps in common and therefore 36 * can be wrapped in a class whose higher-order methods performs the common steps and then call 37 * the methods performing the specific part; the specific-part object is passed as a parameter. 36 38 * @author olhsha 37 39 */ … … 44 46 private String _resourceType = "resourceType"; 45 47 48 /** 49 * Set the instance of a specific REST class. 50 * @param resourceResource 51 */ 46 52 public RequestWrappers(ResourceResource resourceResource) { 47 53 this.resourceResource = resourceResource; 48 54 } 49 55 56 /** 57 * 58 * @param identifier the external UUID of the resource over which the action should have been performed. 59 * @param resource a type of resource: "annotation", "principal", "cached representation", "notebook", "target". 60 * @param action a string naming the action that should have been performed. 61 * @return 62 */ 50 63 public String FORBIDDEN_RESOURCE_ACTION(String identifier, String resource, String action) { 51 64 return " The logged-in principal cannot perform action that falls under access mode'" + action + "', with the " + resource + " with the identifier " + identifier; 52 65 } 53 66 67 /** 68 * This is the simplest wrapper which checks if there is a logged-in principal. 69 * @param params list of parameters that will be used by a specific part of the request (in "the continuation"). 70 * @param dbRequestor the object that will be performing the specific part of the request ("continuation"). 71 * @return the requested resource. 72 * @throws IOException if sending error message fails in the called methods. 73 * @throws NotInDataBaseException if thrown by the specific part of the request. 74 * @throws ForbiddenException if the action is forbidden for the inlogged user. 75 */ 54 76 public T wrapRequestResource(Map params, ILambda<Map, T> dbRequestor) throws IOException, NotInDataBaseException, ForbiddenException { 55 77 Number remotePrincipalID = resourceResource.getPrincipalID(); … … 61 83 } 62 84 85 /** 86 * 87 * @param params list of parameters that will be used by a specific part of the request (in "the continuation"). 88 * @param dbRequestor the object that will be performing the specific part of the request ("continuation"). 89 * @param resource a {@link Resource} object, representing the type of a resource "annotation", "principal", "cached representation", "notebook", "target". 90 * @param action an {@link Access} object representing the type ("mightiness") of the action. 91 * @param externalId the external UUID of the resource. 92 * @return the resource. 93 * @throws IOException if sending error message fails in the called methods. 94 * @throws NotInDataBaseException if thrown by the specific part of the request. 95 * @throws ForbiddenException if the action is forbidden for the inlogged user. 96 */ 63 97 public T wrapRequestResource(Map params, ILambda<Map, T> dbRequestor, Resource resource, Access action, String externalId) throws IOException, ForbiddenException, NotInDataBaseException { 64 98 Number principalID = resourceResource.getPrincipalID(); … … 80 114 81 115 82 116 /** 117 * The method is used for uniformity to treat principal-specific requests as others; 118 * in the future the common part can be added if necessary. 119 * @param params list of parameters that will be used by a specific part of the request (in "the continuation"). 120 * @param dbRequestor the object that will be performing the specific part of the request ("continuation"). 121 * @return a {@link Principal} element. 122 * @throws IOException if sending error message fails in the called methods. 123 * @throws NotInDataBaseException if thrown by the specific part of the request. 124 * @throws PrincipalExists if a principal with the given e-mail or name is already exist in the database 125 * (thrown if the request is to add or update a principal) 126 */ 83 127 public JAXBElement<Principal> wrapAddPrincipalRequest(Map params, ILambdaPrincipal<Map, Principal> dbRequestor) throws IOException, NotInDataBaseException, PrincipalExists { 84 128 return new ObjectFactory().createPrincipal(dbRequestor.apply(params)); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/ResourceJaxbMarshallerProvider.java
r4603 r6038 26 26 27 27 /** 28 * 28 * Manages serialisation of java object into xml elements. 29 29 * @author olhsha 30 30 */ -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/ResourceJaxbUnmarshallerProvider.java
r5174 r6038 27 27 28 28 /** 29 * 29 * Manages deserialisation of xml elements into java objects according to the dasish schema; 30 * also validates according to this schema; the schema and other settings are done in {@link JaxbUnmarshallerFactory}. 30 31 * @author olhsha 31 32 */ -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/ResourceResource.java
r5468 r6038 34 34 35 35 /** 36 * 36 * This class is a super-class of any [SpecificPart]Resource of this REST package and contains the methods 37 * and field common for each of them. 37 38 * @author olhsha 38 39 */ … … 55 56 protected String[] admissibleAccess = {"read", "write", "owner"}; 56 57 58 /** 59 * 60 * @return the internal database id of the logged in principal if the authentication went well, 61 * otherwise sends a corresponding error message. 62 * @throws IOException if sending the error fails. 63 */ 57 64 public Number getPrincipalID() throws IOException { 58 65 -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/TargetResource.java
r5836 r6038 54 54 55 55 /** 56 * 56 * REST class for GETting, POSTing, PUTting and DELETing targets or their substructures (child elements); 57 * Every REST method in the case of successful completion of its action outputs the declared output type 58 * (a JAXB-element or a message string) or sends a HTTP-error with the corresponding diagnostics otherwise. 59 57 60 * @author olhsha 58 61 */ 59 /** 60 * 61 * @author olhsha 62 */ 62 63 63 @Component 64 64 @Path("/targets") … … 66 66 public class TargetResource extends ResourceResource { 67 67 68 /** 69 * Sets {@link HttpServletRequest} object, to be used in unit tests. 70 * @param request a @link HttpServletRequest} object to be set. 71 */ 68 72 public void setHttpRequest(HttpServletRequest request) { 69 73 this.httpServletRequest = request; … … 73 77 } 74 78 75 // TODOD both unit tests 79 /** 80 * 81 * @param externalIdentifier the external UUId of the target. 82 * @return a {@link Target} element representing a target object with "externalIdentifier". 83 * @throws IOException if sending an error fails. 84 */ 76 85 @GET 77 86 @Produces(MediaType.TEXT_XML) … … 105 114 } 106 115 107 ///////////////////////////////////////////////// 116 /** 117 * 118 * @param externalIdentifier the external UUID of a target. 119 * @return a {@link ReferenceList} element representing the list of he-references of the targets that 120 * refer to the same link. 121 * @throws IOException if sending the error fails. 122 */ 108 123 @GET 109 124 @Produces(MediaType.TEXT_XML) 110 125 @Path("{targetid: " + BackendConstants.regExpIdentifier + "}/versions") 111 126 @Transactional(readOnly = true) 112 public JAXBElement<ReferenceList> getSiblingTargets(@PathParam("targetid") String externalIdentifier) throws HTTPException,IOException {127 public JAXBElement<ReferenceList> getSiblingTargets(@PathParam("targetid") String externalIdentifier) throws IOException { 113 128 Map params = new HashMap(); 114 129 try { … … 137 152 } 138 153 139 //////////////////////////////////////////////// 154 /** 155 * 156 * @param targetIdentifier the external UUID of a target. 157 * @param fragmentDescriptor a string representing the location of the target within the cached-representation's content. 158 * @param multiPart a {@link MultiPart} object representing two-part request body, containing the cached representation metadata 159 * ({@link CachedRepresentationInfo} element} and a blob for a cached representation content. 160 * @return a {@link CachedRepresentationInfo} element containing the metadata of the just added cached representation; 161 * the difference with the input metadata is that a persistent external UUID is assigned, and the last-updated 162 * attribute is changed. 163 * @throws IOException if sending the error fails. 164 */ 140 165 @POST 141 166 @Consumes("multipart/mixed") … … 185 210 } 186 211 187 //////////////////////////////////////////////// 212 /** 213 * 214 * @param targetIdentifier the external UUID of a target. 215 * @param cachedIdentifier the external UUID of a cached representation. 216 * @param fragmentDescriptor the new fragment descriptor locating the target within the cached representation. 217 * @return a message about the updated; should be "1 row is updated" in a case of success. 218 * @throws IOException if sending an error fails. 219 */ 188 220 @PUT 189 221 @Produces(MediaType.APPLICATION_XML) … … 213 245 } 214 246 247 /** 248 * 249 * @param targetExternalIdentifier the external UUID of a target. 250 * @param cachedExternalIdentifier the external UUID of a chaced representation. 251 * @return a message reporting how deletion went; in the case of success it tells 252 * how many pairing (target, cached) have been deleted. 253 * @throws IOException if sending the error fails. 254 */ 215 255 @DELETE 216 256 @Path("{targetid: " + BackendConstants.regExpIdentifier + "}/cached/{cachedid: " + BackendConstants.regExpIdentifier + "}") 217 257 public String deleteCachedForTarget(@PathParam("targetid") String targetExternalIdentifier, 218 @PathParam("cachedid") String cachedExternalIdentifier) throws HTTPException,IOException {258 @PathParam("cachedid") String cachedExternalIdentifier) throws IOException { 219 259 Number remotePrincipalID = this.getPrincipalID(); 220 260 if (remotePrincipalID == null) { -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/WelcomeResource.java
r5385 r6038 22 22 import javax.ws.rs.Path; 23 23 import javax.ws.rs.Produces; 24 import javax.ws.rs.core.Context;25 24 import javax.ws.rs.core.MediaType; 26 import javax.ws.rs.core.UriInfo;27 25 import org.springframework.stereotype.Component; 28 26 29 27 /** 30 * 28 * The class contains so far 1 method, outputting a welcome string. 31 29 * @author olhsha 32 30 */ … … 35 33 public class WelcomeResource extends ResourceResource{ 36 34 35 /** 36 * 37 * @return the welcome-string for the logged-in principal, or the "null-principal". 38 */ 37 39 @GET 38 40 @Produces(MediaType.TEXT_HTML)
Note: See TracChangeset
for help on using the changeset viewer.