@Override public void complete(CompleterInvocation completerInvocation) { String currentValue = completerInvocation.getGivenCompleteValue(); for (ArtifactTypeEnum t : ArtifactTypeEnum.values()) { String candidate = t.getType(); if (StringUtils.isBlank(currentValue) || candidate.startsWith(currentValue)) { completerInvocation.addCompleterValue(candidate); } } } }
/** * Asserts that the given feature is enabled. If it is not, then an exception * is thrown. If this client is not set to validating, then this method will * always pass. * @param feature * @throws ArtificerClientException */ private void assertFeatureEnabled(ArtifactType feature) throws ArtificerClientException { if (this.validating) { if (!this.enabledFeatures.contains(feature.getArtifactType().getType())) { throw new ArtificerClientException(Messages.i18n.format("FEATURE_NOT_SUPPORTED")); } } }
/** * Called to unwrap the S-RAMP artifact from its wrapper. * @param artifactWrapper the S-RAMP artifact wrapper * @return the specific artifact based on type */ public BaseArtifactType unwrap(Artifact artifactWrapper) { try { Method method = Artifact.class.getMethod("get" + getArtifactType().getType()); BaseArtifactType artifact = (BaseArtifactType) method.invoke(artifactWrapper); artifact.setArtifactType(this.getArtifactType().getApiType()); return artifact; } catch (Exception e) { throw new RuntimeException(Messages.i18n.format("ARTIFACT_UNWRAP_ERROR", getArtifactType().getType()), e); } }
@Override public void complete(CompleterInvocation completerInvocation) { UploadArtifactCommand command = (UploadArtifactCommand) completerInvocation.getCommand(); if (CollectionUtils.isEmpty(command.arguments)) { FileNameCompleterDelegate.complete(completerInvocation); } else if (command.arguments.size() == 1) { String currentValue = completerInvocation.getGivenCompleteValue(); for (ArtifactTypeEnum t : ArtifactTypeEnum.values()) { String candidate = t.getType(); if (StringUtils.isBlank(currentValue) || candidate.startsWith(currentValue)) { completerInvocation.addCompleterValue(candidate); } } } } }
/** * @see java.lang.Object#toString() */ @Override public String toString() { return String.format("/s-ramp/%1$s/%2$s (%3$s)", getArtifactType().getModel(), getArtifactType() .getType(), getMimeType()); }
protected void processImportedXsds(List<XsdDocumentTarget> targetCollection, Element schema, String targetNS) throws XPathExpressionException { NodeList nodes = (NodeList) query(schema, "./xsd:import", XPathConstants.NODESET); for (int idx = 0; idx < nodes.getLength(); idx++) { Element node = (Element) nodes.item(idx); if (node.hasAttribute("namespace") && node.hasAttribute("schemaLocation")) { String namespace = node.getAttribute("namespace"); String schemaLocation = node.getAttribute("schemaLocation"); stripPath(schemaLocation); XsdDocument xsdDocumentRef = derivedArtifacts.lookupXsdDocument(namespace, schemaLocation); XsdDocumentTarget xsdDocumentTarget = new XsdDocumentTarget(); xsdDocumentTarget.setArtifactType(XsdDocumentEnum.XSD_DOCUMENT); if (xsdDocumentRef != null) { xsdDocumentTarget.setValue(xsdDocumentRef.getUuid()); } else { relationshipSources.add(new NamespaceRelationshipSource(namespace, schemaLocation, xsdDocumentTarget, targetCollection, ArtifactTypeEnum.XsdDocument.getModel(), ArtifactTypeEnum.XsdDocument.getType())); } targetCollection.add(xsdDocumentTarget); } } }
try { String atomUrl = String.format("%1$s/%2$s/%3$s/%4$s/media", srampEndpoint, artifactType.getArtifactType().getModel(), artifactType.getArtifactType().getType(), artifactUuid);
/** * @return the artifact type */ public String getType() { if (getArtifactType() == ArtifactTypeEnum.ExtendedArtifactType || getArtifactType() == ArtifactTypeEnum.ExtendedDocument) { return getExtendedType(); } else { return getArtifactType().getType(); } }
protected void processRedefinedXsds(List<XsdDocumentTarget> targetCollection, Element schema, String targetNS) throws XPathExpressionException { NodeList nodes = (NodeList) query(schema, "./xsd:redefine", XPathConstants.NODESET); for (int idx = 0; idx < nodes.getLength(); idx++) { Element node = (Element) nodes.item(idx); if (node.hasAttribute("schemaLocation")) { String schemaLocation = node.getAttribute("schemaLocation"); stripPath(schemaLocation); XsdDocument xsdDocumentRef = derivedArtifacts.lookupXsdDocument(targetNS, schemaLocation); XsdDocumentTarget xsdDocumentTarget = new XsdDocumentTarget(); xsdDocumentTarget.setArtifactType(XsdDocumentEnum.XSD_DOCUMENT); if (xsdDocumentRef != null) { xsdDocumentTarget.setValue(xsdDocumentRef.getUuid()); } else { relationshipSources.add(new NamespaceRelationshipSource(targetNS, schemaLocation, xsdDocumentTarget, targetCollection, ArtifactTypeEnum.XsdDocument.getModel(), ArtifactTypeEnum.XsdDocument.getType())); } targetCollection.add(xsdDocumentTarget); } } }
protected void processIncludedXsds(List<XsdDocumentTarget> targetCollection, Element schema, String targetNS) throws XPathExpressionException { NodeList nodes = (NodeList) query(schema, "./xsd:include", XPathConstants.NODESET); for (int idx = 0; idx < nodes.getLength(); idx++) { Element node = (Element) nodes.item(idx); if (node.hasAttribute("schemaLocation")) { String schemaLocation = node.getAttribute("schemaLocation"); stripPath(schemaLocation); XsdDocument xsdDocumentRef = derivedArtifacts.lookupXsdDocument(targetNS, schemaLocation); XsdDocumentTarget xsdDocumentTarget = new XsdDocumentTarget(); xsdDocumentTarget.setArtifactType(XsdDocumentEnum.XSD_DOCUMENT); if (xsdDocumentRef != null) { xsdDocumentTarget.setValue(xsdDocumentRef.getUuid()); } else { relationshipSources.add(new NamespaceRelationshipSource(targetNS, schemaLocation, xsdDocumentTarget, targetCollection, ArtifactTypeEnum.XsdDocument.getModel(), ArtifactTypeEnum.XsdDocument.getType())); } targetCollection.add(xsdDocumentTarget); } } }
} else { relationshipSources.add(new QNameRelationshipSource(msgQname, target, null, ArtifactTypeEnum.Message.getModel(), ArtifactTypeEnum.Message.getType()));
private void processWsdlImports() throws XPathExpressionException { WsdlDocument wsdlDocument; if (getPrimaryArtifact() instanceof WsdlDocument) { wsdlDocument = (WsdlDocument) getPrimaryArtifact(); } else { return; } NodeList nodes = (NodeList) this.query(rootElement, ".//wsdl:import", XPathConstants.NODESET); for (int idx = 0; idx < nodes.getLength(); idx++) { Element node = (Element) nodes.item(idx); if (node.hasAttribute("namespace")) { String namespace = node.getAttribute("namespace"); String location = node.getAttribute("location"); stripPath(location); WsdlDocument wsdlDocumentRef = derivedArtifacts.lookupWsdlDocument(namespace); WsdlDocumentTarget wsdlDocumentTarget = new WsdlDocumentTarget(); wsdlDocumentTarget.setArtifactType(WsdlDocumentEnum.WSDL_DOCUMENT); if (wsdlDocumentRef != null) { wsdlDocumentTarget.setValue(wsdlDocumentRef.getUuid()); } else { relationshipSources.add(new NamespaceRelationshipSource(namespace, location, wsdlDocumentTarget, wsdlDocument.getImportedWsdls(), ArtifactTypeEnum.WsdlDocument.getModel(), ArtifactTypeEnum.WsdlDocument.getType())); } wsdlDocument.getImportedWsdls().add(wsdlDocumentTarget); } } }
} else { relationshipSources.add(new QNameRelationshipSource(msgQname, target, null, ArtifactTypeEnum.Message.getModel(), ArtifactTypeEnum.Message.getType()));
} else { relationshipSources.add(new QNameRelationshipSource(msgQname, target, null, ArtifactTypeEnum.Message.getModel(), ArtifactTypeEnum.Message.getType()));
for (ArtifactSummary summary : rset) { ArtifactType type = summary.getArtifactType(); String displayType = type.getArtifactType().getType().toString(); if (type.isExtendedType() && type.getExtendedType() != null) { displayType = type.getExtendedType();
try { String artifactModel = type.getArtifactType().getModel(); String artifactType = type.getArtifactType().getType(); if ("ext".equals(type.getArtifactType().getModel()) && type.getExtendedType()!=null) { artifactType = type.getExtendedType();
for (ArtifactSummary summary : rset) { ArtifactType type = summary.getArtifactType(); String displayType = type.getArtifactType().getType().toString(); if (type.isExtendedType() && type.getExtendedType() != null) { displayType = type.getExtendedType();
/** * Gets the full meta-data listing for an Artifact in the S-RAMP repository. * @param artifactType * @param artifactUuid * @throws ArtificerClientException * @throws ArtificerServerException */ public BaseArtifactType getArtifactMetaData(ArtifactType artifactType, String artifactUuid) throws ArtificerClientException, ArtificerServerException { assertFeatureEnabled(artifactType); ClientResponse<Entry> response = null; try { String atomUrl = String.format("%1$s/%2$s/%3$s/%4$s", srampEndpoint, artifactType.getArtifactType().getModel(), artifactType.getArtifactType().getType(), artifactUuid); ClientRequest request = createClientRequest(atomUrl); response = request.get(Entry.class); Entry entry = response.getEntity(); return ArtificerAtomUtils.unwrapSrampArtifact(artifactType, entry); } catch (ArtificerServerException e) { throw e; } catch (Throwable e) { throw new ArtificerClientException(e); } finally { closeQuietly(response); } }
public BaseArtifactType addComment(String uuid, ArtifactType type, String text) throws ArtificerClientException, ArtificerServerException { assertFeatureEnabled(type); ClientResponse<Entry> response = null; try { String artifactModel = type.getArtifactType().getModel(); String artifactType = type.getArtifactType().getType(); if ("ext".equals(type.getArtifactType().getModel()) && type.getExtendedType() != null) { artifactType = type.getExtendedType(); } String atomUrl = String.format("%1$s/%2$s/%3$s/%4$s/comment", srampEndpoint, artifactModel, artifactType, uuid); ClientRequest request = createClientRequest(atomUrl); request.body(MediaType.TEXT_PLAIN, text); response = request.post(Entry.class); Entry entry = response.getEntity(); return ArtificerAtomUtils.unwrapSrampArtifact(type, entry); } catch (ArtificerServerException e) { throw e; } catch (Throwable e) { throw new ArtificerClientException(e); } finally { closeQuietly(response); } }
try { String artifactModel = type.getArtifactType().getModel(); String artifactType = type.getArtifactType().getType(); if ("ext".equals(type.getArtifactType().getModel()) && type.getExtendedType()!=null) { artifactType = type.getExtendedType();