import org.apache.tuscany.sca.monitor.ValidationException;
public class DependencyUtils {
public static List<String> getDependencies(String contributionURI, Map<String, ZipInputStream> possibles) throws ValidationException, IOException, ContributionReadException, XMLStreamException {
Deployer deployer = TuscanyRuntime.newInstance().getDeployer();
Map<String, ContributionMetadata> contributionMetaDatas = new HashMap<String, ContributionMetadata>();
for (String curi : possibles.keySet()) {
ZipInputStream zis = possibles.get(curi);
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
if (Contribution.SCA_CONTRIBUTION_META.equals(entry.getName())) {
byte[] buffer = new byte[2048];
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedOutputStream bos = new BufferedOutputStream(baos, buffer.length);
int size;
while ((size = zis.read(buffer, 0, buffer.length)) != -1) {
bos.write(buffer, 0, size);
}
bos.close();
contributionMetaDatas.put(curi, (ContributionMetadata)deployer.loadXMLDocument(new StringReader(baos.toString())));
}
}
zis.close(); // close it so no one tries to reuse the already read stream
}
Monitor monitor = deployer.createMonitor();
try {
return deployer.getDependencies(contributionMetaDatas, contributionURI, monitor);
} finally {
monitor.analyzeProblems();
}
}