/** * Adds some standard meta-data properties to the artifact instance. * @param discoveredArtifact * @param artifact */ protected void addStandardMetaData(DiscoveredArtifact discoveredArtifact, BaseArtifactType artifact) { artifact.setUuid(UUID.randomUUID().toString()); artifact.setName(discoveredArtifact.getName()); SrampModelUtils.setCustomProperty(artifact, "batch.archive-path", discoveredArtifact.getArchivePath()); //$NON-NLS-1$ if (this.context != null) { String parentUUID = (String) this.context.get(PARENT_UUID); if (parentUUID != null) SrampModelUtils.addGenericRelationship(artifact, "expandedFromDocument", parentUUID); //$NON-NLS-1$ } }
/** * Creates the artifact instance based on the type of the discovered artifact. * @param discoveredArtifact */ protected BaseArtifactType createArtifact(DiscoveredArtifact discoveredArtifact) { BaseArtifactType metaData = null; String archivePath = discoveredArtifact.getArchivePath().toLowerCase(); if (archivePath.endsWith(".xml")) { //$NON-NLS-1$ metaData = new XmlDocument(); metaData.setArtifactType(BaseArtifactEnum.XML_DOCUMENT); } else if (archivePath.endsWith(".wsdl")) { //$NON-NLS-1$ metaData = new WsdlDocument(); metaData.setArtifactType(BaseArtifactEnum.WSDL_DOCUMENT); } else if (archivePath.endsWith(".xsd")) { //$NON-NLS-1$ metaData = new XsdDocument(); metaData.setArtifactType(BaseArtifactEnum.XSD_DOCUMENT); } else if (archivePath.endsWith(".wspolicy")) { //$NON-NLS-1$ metaData = new XsdDocument(); metaData.setArtifactType(BaseArtifactEnum.POLICY_DOCUMENT); } else { metaData = new Document(); metaData.setArtifactType(BaseArtifactEnum.DOCUMENT); } return metaData; }
/** * Creates an S-RAMP archive from this JAR. * @return an S-RAMP archive * @throws ZipToSrampArchiveException */ public SrampArchive createSrampArchive() throws ZipToSrampArchiveException { this.artifactFilter.setContext(this.context); this.metaDataFactory.setContext(this.context); DiscoveredArtifacts discoveredArtifacts = discoverArtifacts(); discoveredArtifacts.index(jarWorkDir); generateMetaData(discoveredArtifacts); try { SrampArchive archive = new SrampArchive(); for (DiscoveredArtifact artifact : discoveredArtifacts) { String path = artifact.getArchivePath(); archive.addEntry(path, artifact.getMetaData(), artifact.getContent()); } return archive; } catch (Exception e) { throw new ZipToSrampArchiveException(e); } }