@Override public void doRun() { ArtifactStorageService storage = ServiceUtils.getService(ArtifactStorageService.class); if (storage == null) { result = XSPReplyServiceUnavailable.instance(); return; } result = storage.retrieve(artifactId); if (!result.isSuccess()) return; result = storage.pushToLive(((XSPReplyResult<Artifact>) result).getData()); } }
@Override public void doRun() { ArtifactStorageService storage = ServiceUtils.getService(ArtifactStorageService.class); if (storage == null) { result = XSPReplyServiceUnavailable.instance(); return; } result = storage.delete(artifactId); } }
@Override public void doRun() { ArtifactStorageService storage = ServiceUtils.getService(ArtifactStorageService.class); if (storage == null) { result = XSPReplyServiceUnavailable.instance(); return; } result = storage.retrieve(artifactId); if (!result.isSuccess()) return; result = storage.pullFromLive(((XSPReplyResult<Artifact>) result).getData()); } }
@Override public Collection<Artifact> getOutputsFor(String specificationId) { ArtifactStorageService storageService = Register.getComponent(ArtifactStorageService.class); if (storageService == null) return Collections.emptyList(); Collection<Artifact> artifacts = new ArrayList<>(); for (String artifactId : manifest.getArtifactsForOutput(specificationId)) { XSPReply reply = storageService.retrieve(artifactId); if (reply.isSuccess()) artifacts.add(((XSPReplyResult<Artifact>) reply).getData()); } return artifacts; }
/** * Pulls an artifact from the connector into the standard storage (usually the long-term store) * * @param connector The connector to pull from * @return The result of the operation */ public static XSPReply pullArtifactFrom(ConnectorService connector) { ArtifactStorageService storageService = Register.getComponent(ArtifactStorageService.class); if (storageService == null) return XSPReplyServiceUnavailable.instance(); XSPReply replyArtifact = connector.pullArtifact(); if (!replyArtifact.isSuccess()) return replyArtifact; Artifact artifact = ((XSPReplyResult<Artifact>) replyArtifact).getData(); XSPReply reply = storageService.store(artifact); if (!reply.isSuccess()) return reply; EventService eventService = Register.getComponent(EventService.class); if (eventService != null) eventService.onEvent(new ArtifactPulledFromConnectorEvent(connector, artifact)); // reply with the artifact return new XSPReplyResult<>(artifact.getIdentifier()); }
@Override public Collection<Artifact> getInputsFor(String specificationId) { ArtifactStorageService storageService = Register.getComponent(ArtifactStorageService.class); if (storageService == null) return Collections.emptyList(); Collection<Artifact> artifacts = new ArrayList<>(); for (String artifactId : manifest.getArtifactsForInput(specificationId)) { XSPReply reply = storageService.retrieve(artifactId); if (reply.isSuccess()) artifacts.add(((XSPReplyResult<Artifact>) reply).getData()); } return artifacts; }
Collection<Quad> quads = ((XSPReplyResultCollection<Quad>) reply).getData(); Artifact artifact = new ArtifactSimple(metadata, artifactId, SemanticWebImporter.class.getCanonicalName(), quads); reply = storageService.store(artifact); if (!reply.isSuccess()) return reply;
/** * Pushes an artifact to a connector's client * * @param connectorId The identifier of the connector to push to * @param artifactId The identifier of the artifact to push * @return The result of the operation */ public static XSPReply pushArtifactTo(String connectorId, String artifactId) { ConnectorService connector = Register.getComponent(ConnectorService.class, "id", connectorId); if (connector == null) return XSPReplyNotFound.instance(); ArtifactStorageService storage = Register.getComponent(ArtifactStorageService.class); if (storage == null) return XSPReplyServiceUnavailable.instance(); XSPReply reply = storage.retrieve(artifactId); if (!reply.isSuccess()) return reply; Artifact artifact = ((XSPReplyResult<Artifact>) reply).getData(); reply = connector.pushArtifact(artifact); if (!reply.isSuccess()) return reply; EventService eventService = Register.getComponent(EventService.class); if (eventService != null) eventService.onEvent(new ArtifactPushedToConnectorEvent(connector, artifact)); return reply; } }