/** * 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(DomainConnectorService connector) { ArtifactStorageService storageService = ServiceUtils.getService(ArtifactStorageService.class); if (storageService == null) return new XSPReplyFailure("Failed to resolve an artifact storage service"); XSPReply replyArtifact = connector.getNextInput(false); if (!replyArtifact.isSuccess()) return replyArtifact; Artifact artifact = ((XSPReplyResult<Artifact>) replyArtifact).getData(); XSPReply reply = storageService.store(artifact); if (!reply.isSuccess()) return reply; // reply with the artifact return replyArtifact; }
/** * 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) { DomainConnectorService connector = ServiceUtils.getService(DomainConnectorService.class, "id", connectorId); if (connector == null) return new XSPReplyFailure("Failed to resolve connector " + connectorId); ArtifactStorageService storage = ServiceUtils.getService(ArtifactStorageService.class); if (storage == null) return new XSPReplyFailure("Failed to resolve the artifact storage service"); XSPReply reply = storage.retrieve(artifactId); if (!reply.isSuccess()) return reply; return connector.pushToClient(((XSPReplyResult<Artifact>) reply).getData()); } }