Changeset 239
- Timestamp:
- 03/17/10 13:45:10 (14 years ago)
- Location:
- VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/VirtualCollectionRegistryMarshaller.java
r215 r239 92 92 93 93 public VirtualCollection unmarshal(InputStream input, Format format, 94 String encoding) throws IOException {94 String encoding) throws VirtualCollectionRegistryException, IOException { 95 95 if (input == null) { 96 96 throw new NullPointerException("input == null"); … … 104 104 return vc; 105 105 } catch (UnmarshalException e) { 106 logger.log(Level.WARNING, "error unmarshalling virtual collection", 107 e.getLinkedException()); 108 throw new IOException("error unmarshalling virtual collection", 109 e.getLinkedException()); 106 throw new VirtualCollectionRegistryUsageException("invalid " + 107 "virtual collection format", e.getLinkedException()); 110 108 } catch (Exception e) { 111 109 logger.log(Level.WARNING, "error unmarshalling virtual collection", e); -
VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/rest/VirtualCollectionRegistryExceptionMapper.java
r236 r239 57 57 while (t != null) { 58 58 if (t instanceof SAXParseException) { 59 SAXParseException e = (SAXParseException) t; 60 errors.add(e.getMessage() + ", line = " + e.getLineNumber() 61 + ", column = " + e.getColumnNumber()); 59 final SAXParseException e = (SAXParseException) t; 60 String message = e.getMessage(); 61 if (message.startsWith("cvc")) { 62 int pos = message.indexOf(':'); 63 if (pos != 0) { 64 message = message.substring(pos + 1); 65 } 66 } 67 errors.add(message + 68 " [line = " + e.getLineNumber() + 69 ", column = " + e.getColumnNumber() + "]"); 70 } else if (t instanceof XMLStreamException) { 71 final XMLStreamException e = (XMLStreamException) t; 72 String message = e.getMessage(); 73 if (message.startsWith("ParseError")) { 74 int pos = message.indexOf(':'); 75 if (pos != -1) { 76 pos = message.indexOf(':', pos + 1); 77 if (pos != -1) { 78 message = message.substring(pos + 1); 79 } 80 } 81 } 82 if (e.getLocation() != null) { 83 message = message + 84 " [line = " + e.getLocation().getLineNumber() + 85 ", column = " + e.getLocation().getColumnNumber() + 86 "]"; 87 } 88 errors.add(message); 62 89 } else { 63 90 errors.add(t.getMessage()); -
VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/rest/VirtualCollectionRegistryRestService.java
r235 r239 85 85 .build(); 86 86 return Response.created(uri).entity(response).build(); 87 } catch ( Exception e) {87 } catch (IOException e) { 88 88 throw new VirtualCollectionRegistryException("create", e); 89 89 } … … 117 117 MediaType.APPLICATION_JSON }) 118 118 public Response updateVirtualCollection(@PathParam("id") long id, 119 VirtualCollection vc) throws VirtualCollectionRegistryException {119 InputStream input) throws VirtualCollectionRegistryException { 120 120 Principal principal = security.getUserPrincipal(); 121 121 if (principal == null) { 122 122 throw new NullPointerException("princial == null"); 123 123 } 124 registry.updateVirtualCollection(principal, id, vc); 125 RestResponse response = new RestResponse(); 126 response.setIsSuccess(true); 127 response.setInfo("updated"); 128 response.setId(id); 129 return Response.ok(response).build(); 124 try { 125 Format format = getInputFormat(); 126 String encoding = getInputEncoding(); 127 VirtualCollection vc = registry.getMarshaller() 128 .unmarshal(input, format, encoding); 129 registry.updateVirtualCollection(principal, id, vc); 130 RestResponse response = new RestResponse(); 131 response.setIsSuccess(true); 132 response.setInfo("updated"); 133 response.setId(id); 134 return Response.ok(response).build(); 135 } catch (IOException e) { 136 throw new VirtualCollectionRegistryException("update", e); 137 138 } 130 139 } 131 140
Note: See TracChangeset
for help on using the changeset viewer.