annotate src/main/java/de/mpiwg/itgroup/annotations/restlet/annotations_ui/AnnotationResource.java @ 93:3d1a00418b42 admin_ui_rel_links

starting web admin ui with relative links. doesn't fully work yet.
author casties
date Mon, 09 Feb 2015 12:55:51 +0100
parents e973cbf5d58f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
50
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
1 /**
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
2 *
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
3 */
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
4 package de.mpiwg.itgroup.annotations.restlet.annotations_ui;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
5
70
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
6 /*
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
7 * #%L
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
8 * AnnotationManager
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
9 * %%
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
10 * Copyright (C) 2012 - 2014 MPIWG Berlin
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
11 * %%
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
12 * This program is free software: you can redistribute it and/or modify
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
13 * it under the terms of the GNU Lesser General Public License as
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
14 * published by the Free Software Foundation, either version 3 of the
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
15 * License, or (at your option) any later version.
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
16 *
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
17 * This program is distributed in the hope that it will be useful,
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
20 * GNU General Lesser Public License for more details.
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
21 *
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
22 * You should have received a copy of the GNU General Lesser Public
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
23 * License along with this program. If not, see
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
24 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
25 * #L%
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
26 */
2b1e6df5e21a added lgpl_v3 license information.
casties
parents: 65
diff changeset
27
65
c0dd5314bada deal with special characters in urls.
casties
parents: 50
diff changeset
28 import java.io.UnsupportedEncodingException;
c0dd5314bada deal with special characters in urls.
casties
parents: 50
diff changeset
29 import java.net.URLDecoder;
75
25eb2e1df106 change logging to java.util.logging.
casties
parents: 70
diff changeset
30 import java.util.logging.Logger;
65
c0dd5314bada deal with special characters in urls.
casties
parents: 50
diff changeset
31
50
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
32 import org.restlet.data.Form;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
33 import org.restlet.data.MediaType;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
34 import org.restlet.data.Reference;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
35 import org.restlet.data.Status;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
36 import org.restlet.representation.Representation;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
37 import org.restlet.representation.StringRepresentation;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
38 import org.restlet.resource.Delete;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
39 import org.restlet.resource.Get;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
40 import org.restlet.resource.Put;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
41 import org.restlet.resource.ResourceException;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
42 import org.restlet.resource.ServerResource;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
43
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
44 import de.mpiwg.itgroup.annotations.Annotation;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
45 import de.mpiwg.itgroup.annotations.neo4j.AnnotationStore;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
46 import de.mpiwg.itgroup.annotations.restlet.BaseRestlet;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
47
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
48 /**
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
49 * Resource class for a single annotation.
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
50 *
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
51 * @author casties
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
52 *
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
53 */
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
54 public class AnnotationResource extends ServerResource {
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
55
75
25eb2e1df106 change logging to java.util.logging.
casties
parents: 70
diff changeset
56 public static Logger logger = Logger.getLogger("de.mpiwg.itgroup.annotations.restlet.annotations_ui.AnnotationResource");
50
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
57
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
58 protected AnnotationStore store;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
59
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
60 protected String requestId;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
61
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
62 protected Annotation annotation;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
63
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
64 @Override
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
65 protected void doInit() throws ResourceException {
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
66 super.doInit();
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
67 // id from URI /annotations/persons/{id}
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
68 requestId = (String) getRequest().getAttributes().get("id");
75
25eb2e1df106 change logging to java.util.logging.
casties
parents: 70
diff changeset
69 logger.fine("annoation-id=" + requestId);
50
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
70 // get store instance
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
71 if (store == null) {
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
72 store = ((BaseRestlet) getApplication()).getAnnotationStore();
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
73 }
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
74 // get annotation from store
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
75 if (requestId != null) {
65
c0dd5314bada deal with special characters in urls.
casties
parents: 50
diff changeset
76 // URL decode
c0dd5314bada deal with special characters in urls.
casties
parents: 50
diff changeset
77 try {
c0dd5314bada deal with special characters in urls.
casties
parents: 50
diff changeset
78 requestId = URLDecoder.decode(requestId, "UTF-8");
c0dd5314bada deal with special characters in urls.
casties
parents: 50
diff changeset
79 } catch (UnsupportedEncodingException e) {
c0dd5314bada deal with special characters in urls.
casties
parents: 50
diff changeset
80 // this shouldn't happen
c0dd5314bada deal with special characters in urls.
casties
parents: 50
diff changeset
81 }
50
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
82 // the ID in the path is encoded
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
83 String id = Annotation.decodeId(requestId);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
84 annotation = store.getAnnotationById(id);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
85 }
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
86 }
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
87
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
88 /**
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
89 * GET with HTML content type. Shows the person.
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
90 *
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
91 * @param entity
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
92 * @return
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
93 */
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
94 @Get("html")
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
95 public Representation doGetHTML(Representation entity) {
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
96 if (annotation == null) {
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
97 // invalid id
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
98 setStatus(Status.CLIENT_ERROR_NOT_FOUND);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
99 return null;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
100 }
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
101 String result = null;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
102 // get form parameter
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
103 Form f = this.getQuery();
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
104 String form = f.getFirstValue("form");
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
105 if (form != null && form.equals("edit")) {
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
106 /*
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
107 // output edit form
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
108 result = "<html><body>\n";
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
109 result += String.format("<h1>Edit person %s</h1>\n", annotation.getId());
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
110 result += String.format("<p><a href=\"%s\">All persons</a></p>", this.getReference().getParentRef());
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
111 // tunnel PUT method through POST
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
112 result += String.format("<form method=\"post\" action=\"%s?method=PUT\">\n", this.getReference().getHierarchicalPart());
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
113 result += "<table>";
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
114 result += String.format("<tr><td><b>name</b></td><td><input type=\"text\" name=\"name\" value=\"%s\"/></td></tr>\n",
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
115 annotation.getName());
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
116 result += String.format("<tr><td><b>uri</b></td><td><input type=\"text\" name=\"uri\" value=\"%s\"/></td></tr>\n",
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
117 annotation.getUriString());
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
118 result += "</table>\n";
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
119 result += "<p><input type=\"submit\"/></p>";
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
120 result += "</table>\n</form>\n</body>\n</html>";
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
121 */
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
122 } else {
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
123 // output person content
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
124 result = "<html><body>\n<h1>Annotation</h1>\n";
93
3d1a00418b42 starting web admin ui with relative links. doesn't fully work yet.
casties
parents: 78
diff changeset
125 result += "<p><a href=\"./\">All annotations</a></p>";
50
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
126 result += "<table>";
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
127 result += String.format("<tr><td><b>uri</b></td><td>%s</td></tr>\n", annotation.getUri());
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
128 result += String.format("<tr><td><b>text</b></td><td>%s</td></tr>\n", annotation.getBodyText());
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
129 result += String.format("<tr><td><b>target</b></td><td>%s</td></tr>\n", annotation.getTargetBaseUri());
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
130 result += String.format("<tr><td><b>fragment</b></td><td>%s</td></tr>\n", annotation.getTargetFragment());
77
f2ff7de7b49d show more fields in annotations_ui annotation view.
casties
parents: 75
diff changeset
131 result += String.format("<tr><td><b>quote</b></td><td>%s</td></tr>\n", annotation.getQuote());
f2ff7de7b49d show more fields in annotations_ui annotation view.
casties
parents: 75
diff changeset
132 result += String.format("<tr><td><b>resource</b></td><td>%s</td></tr>\n", annotation.getResourceUri());
50
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
133 result += String.format("<tr><td><b>creator</b></td><td>%s</td></tr>\n", annotation.getCreatorName());
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
134 result += "</table>\n";
78
e973cbf5d58f more annotation attributes displayed in AnnotationResource.
casties
parents: 77
diff changeset
135 result += "<br/>\n";
e973cbf5d58f more annotation attributes displayed in AnnotationResource.
casties
parents: 77
diff changeset
136 result += "<table>";
e973cbf5d58f more annotation attributes displayed in AnnotationResource.
casties
parents: 77
diff changeset
137 result += String.format("<tr><td><b>admin permission</b></td><td>%s</td></tr>\n", annotation.getAdminPermission() != null ? annotation.getAdminPermission().getIdString() : "null");
e973cbf5d58f more annotation attributes displayed in AnnotationResource.
casties
parents: 77
diff changeset
138 result += String.format("<tr><td><b>delete permission</b></td><td>%s</td></tr>\n", annotation.getDeletePermission() != null ? annotation.getDeletePermission().getIdString() : "null");
e973cbf5d58f more annotation attributes displayed in AnnotationResource.
casties
parents: 77
diff changeset
139 result += String.format("<tr><td><b>update permission</b></td><td>%s</td></tr>\n", annotation.getUpdatePermission() != null ? annotation.getUpdatePermission().getIdString() : "null");
e973cbf5d58f more annotation attributes displayed in AnnotationResource.
casties
parents: 77
diff changeset
140 result += String.format("<tr><td><b>read permission</b></td><td>%s</td></tr>\n", annotation.getReadPermission() != null ? annotation.getReadPermission().getIdString() : "null");
e973cbf5d58f more annotation attributes displayed in AnnotationResource.
casties
parents: 77
diff changeset
141 result += "</table>\n";
50
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
142 //result += "<p><a href=\"?form=edit\">Edit annotation</a></p>\n";
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
143 // tunnel POST as DELETE
93
3d1a00418b42 starting web admin ui with relative links. doesn't fully work yet.
casties
parents: 78
diff changeset
144 result += "<form method=\"post\" action=\"?method=DELETE\"><input type=\"submit\" value=\"Delete annotation\"/></form>\n";
50
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
145 result += "</body>\n</html>";
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
146 }
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
147 return new StringRepresentation(result, MediaType.TEXT_HTML);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
148 }
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
149
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
150 /**
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
151 * PUT updates the annotation.
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
152 *
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
153 * @param entity
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
154 * @return
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
155 */
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
156 @Put
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
157 public Representation doPut(Representation entity) {
75
25eb2e1df106 change logging to java.util.logging.
casties
parents: 70
diff changeset
158 logger.fine("AnnotationResource.doPut!");
50
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
159 if (annotation == null) {
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
160 // invalid id
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
161 setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
162 return null;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
163 }
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
164 // NOT YET
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
165 return null;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
166 /*
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
167 // TODO: do authentication
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
168 Form form = new Form(entity);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
169 String name = form.getFirstValue("name");
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
170 String uri = form.getFirstValue("uri");
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
171 if (name != null && !name.isEmpty()) {
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
172 annotation.setName(name);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
173 }
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
174 if (uri != null && !uri.isEmpty()) {
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
175 annotation.setUri(uri);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
176 }
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
177 store.storeActor(annotation);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
178 // return 303: see other
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
179 setStatus(Status.REDIRECTION_SEE_OTHER);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
180 // go GET same URL
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
181 Reference url = this.getReference();
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
182 this.getResponse().setLocationRef(url);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
183 return null;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
184 */
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
185 }
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
186
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
187 /**
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
188 * DELETE deletes the annotation.
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
189 *
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
190 * @param entity
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
191 * @return
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
192 */
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
193 @Delete
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
194 public Representation doDelete(Representation entity) {
75
25eb2e1df106 change logging to java.util.logging.
casties
parents: 70
diff changeset
195 logger.fine("AnnotationResource.doDelete!");
50
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
196 if (annotation == null) {
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
197 // invalid id
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
198 setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
199 return null;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
200 }
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
201 // TODO: do authentication
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
202 store.deleteAnnotationById(annotation.getUri());
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
203 // return 303: see other
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
204 setStatus(Status.REDIRECTION_SEE_OTHER);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
205 // go GET parent URL
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
206 Reference url = this.getReference().getParentRef();
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
207 this.getResponse().setLocationRef(url);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
208 return null;
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
209 }
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents:
diff changeset
210 }