Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/rest/ArtifactOutResource.java @ 32:c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
artifacts/trunk@78 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 13 Sep 2009 14:50:53 +0000 |
parents | 22b03d5c84c5 |
children | 3f03aee55c2f |
comparison
equal
deleted
inserted
replaced
31:c4d85a8532d1 | 32:c2d53bd30ab8 |
---|---|
16 import org.restlet.ext.xml.DomRepresentation; | 16 import org.restlet.ext.xml.DomRepresentation; |
17 | 17 |
18 import de.intevation.artifactdatabase.XMLUtils; | 18 import de.intevation.artifactdatabase.XMLUtils; |
19 | 19 |
20 import de.intevation.artifacts.ArtifactNamespaceContext; | 20 import de.intevation.artifacts.ArtifactNamespaceContext; |
21 import de.intevation.artifacts.ArtifactDatabaseException; | |
21 import de.intevation.artifacts.ArtifactDatabase; | 22 import de.intevation.artifacts.ArtifactDatabase; |
22 import de.intevation.artifacts.Artifact; | |
23 | 23 |
24 import org.w3c.dom.Document; | 24 import org.w3c.dom.Document; |
25 | 25 |
26 import java.io.IOException; | 26 import java.io.IOException; |
27 | 27 |
66 | 66 |
67 if (logger.isDebugEnabled()) { | 67 if (logger.isDebugEnabled()) { |
68 logger.debug("looking for artifact id '" + identifier + "'"); | 68 logger.debug("looking for artifact id '" + identifier + "'"); |
69 } | 69 } |
70 | 70 |
71 Artifact artifact = db.getArtifact(identifier); | |
72 | |
73 if (artifact == null) { | |
74 Response response = getResponse(); | |
75 response.setStatus( | |
76 Status.CLIENT_ERROR_NOT_FOUND, ArtifactResource.NO_ARTIFACT_FOUND); | |
77 return new EmptyRepresentation(); | |
78 } | |
79 | |
80 String mimeTypeString = XMLUtils.xpathString( | 71 String mimeTypeString = XMLUtils.xpathString( |
81 inputDocument, | 72 inputDocument, |
82 XPATH_MIME_TYPE, | 73 XPATH_MIME_TYPE, |
83 ArtifactNamespaceContext.INSTANCE); | 74 ArtifactNamespaceContext.INSTANCE); |
84 | 75 |
91 catch (Exception e) { | 82 catch (Exception e) { |
92 logger.error(e.getLocalizedMessage()); | 83 logger.error(e.getLocalizedMessage()); |
93 } | 84 } |
94 } | 85 } |
95 | 86 |
96 return new OutRepresentation( | 87 try { |
97 mimeType, artifact, inputDocument, db.getArtifactContext()); | 88 return new OutRepresentation( |
89 mimeType, | |
90 db.out(identifier, inputDocument)); | |
91 } | |
92 catch (ArtifactDatabaseException adbe) { | |
93 Response response = getResponse(); | |
94 response.setStatus( | |
95 Status.CLIENT_ERROR_NOT_FOUND, adbe.getMessage()); | |
96 return new EmptyRepresentation(); | |
97 } | |
98 } | 98 } |
99 } | 99 } |
100 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: | 100 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: |