Mercurial > dive4elements > framework
diff artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java @ 293:a367a0d011af
Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
artifacts/trunk@2331 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 14 Jul 2011 14:22:23 +0000 |
parents | 39c0ff00d188 |
children | b530e83acf2e |
line wrap: on
line diff
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Wed Jul 13 13:12:08 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Thu Jul 14 14:22:23 2011 +0000 @@ -23,6 +23,7 @@ import de.intevation.artifacts.CallContext; import de.intevation.artifacts.CallMeta; import de.intevation.artifacts.CollectionItem; +import de.intevation.artifacts.GlobalContext; import de.intevation.artifacts.Hook; import de.intevation.artifacts.Service; import de.intevation.artifacts.ServiceFactory; @@ -68,6 +69,10 @@ private static Logger logger = Logger.getLogger(ArtifactDatabaseImpl.class); + /** The key under which the artifact database is stored in the global + * context.*/ + public static final String GLOBAL_CONTEXT_KEY = "global.artifact.database"; + /** Message that is returned if an operation was successful.*/ public static final String OPERATION_SUCCESSFUL = "SUCCESS"; @@ -403,7 +408,7 @@ /** * Reference of the global context of the artifact runtime system. */ - protected Object context; + protected GlobalContext context; /** * The signing secret to be used for ex-/importing artifacts. @@ -463,7 +468,9 @@ setupCallContextListener(bootstrap); setupHooks(bootstrap); - context = bootstrap.getContext(); + context = bootstrap.getContext(); + context.put(GLOBAL_CONTEXT_KEY, this); + exportSecret = bootstrap.getExportSecret(); wireWithBackend(backend); @@ -713,6 +720,20 @@ } } + + public Artifact getRawArtifact(String identifier) + throws ArtifactDatabaseException + { + PersistentArtifact artifact = backend.getArtifact(identifier); + + if (artifact == null) { + throw new ArtifactDatabaseException(NO_SUCH_ARTIFACT); + } + + return artifact.getArtifact(); + } + + public Document describe( String identifier, Document data,