comparison src/main/java/de/intevation/lada/rest/LProbeService.java @ 289:f4701a64e8a3

Added upload function to the ProbenService. Must be implemented.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Tue, 13 Aug 2013 16:26:00 +0200
parents 2098db2e8fbd
children f0e1caad6027
comparison
equal deleted inserted replaced
288:7cd0f953651d 289:f4701a64e8a3
26 import de.intevation.lada.data.QueryBuilder; 26 import de.intevation.lada.data.QueryBuilder;
27 import de.intevation.lada.data.Repository; 27 import de.intevation.lada.data.Repository;
28 import de.intevation.lada.model.LProbe; 28 import de.intevation.lada.model.LProbe;
29 import de.intevation.lada.model.LProbeInfo; 29 import de.intevation.lada.model.LProbeInfo;
30 30
31 import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
32
31 /** 33 /**
32 * This class produces a RESTful service to read, write and update 34 * This class produces a RESTful service to read, write and update
33 * LProbe objects. 35 * LProbe objects.
34 * 36 *
35 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a> 37 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a>
218 } 220 }
219 catch(AuthenticationException ae) { 221 catch(AuthenticationException ae) {
220 return new Response(false, 699, new ArrayList<LProbeInfo>()); 222 return new Response(false, 699, new ArrayList<LProbeInfo>());
221 } 223 }
222 } 224 }
225 /**
226 * Import LProbe object.
227 * See
228 * http://howtodoinjava.com/2013/05/21/jax-rs-resteasy-file-upload-httpclient-example/
229 * for more details on the implementation.
230 *
231 * @param input MulitpartFormDataInput containing the file to upload.
232 * @param header The HTTP header containing authorization information.
233 * @return Response object.
234 */
235 @POST
236 @Path("/import")
237 @Produces("application/json")
238 @Consumes("multipart/form-data")
239 public Response upload(MultipartFormDataInput input, @Context HttpHeaders header) {
240 try {
241 AuthenticationResponse auth = authentication.authorizedGroups(header);
242 // TODO: Check Authorisation. How should we check the
243 // authorisation while importing? I think we must differ between
244 // updating already existing proben and creating new proben. (ti)
245 // <2013-08-13 16:24>
246 //if (auth.getNetzbetreiber().contains(probe.getNetzbetreiberId()) &&
247 // auth.getMst().contains(probe.getMstId())) {
248 // LProbe p = probe.toLProbe();
249 // return repository.create(p);
250 //}
251 // TODO: Response must contain a "file" attribute with the name of
252 // the uploaded file.(ti) <2013-08-13 16:23>
253 return new Response(true, 200, null);
254 //return new Response(false, 698, null);
255 }
256 catch(AuthenticationException ae) {
257 return new Response(false, 699, null);
258 }
259 }
223 } 260 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)