use of org.eclipse.vorto.repository.web.core.exceptions.NotAuthorizedException in project vorto by eclipse.
the class AbstractRepositoryController method addModelToZip.
protected void addModelToZip(ZipOutputStream zipOutputStream, ModelId modelId) throws Exception {
try {
FileContent modelFile = getModelRepository(modelId).getFileContent(modelId, Optional.empty()).get();
ModelInfo modelResource = getModelRepository(modelId).getById(modelId);
try {
ZipEntry zipEntry = new ZipEntry(modelResource.getId().getPrettyFormat() + modelResource.getType().getExtension());
zipOutputStream.putNextEntry(zipEntry);
zipOutputStream.write(modelFile.getContent());
zipOutputStream.closeEntry();
} catch (Exception ex) {
// entry possible exists already, so skipping TODO: ugly hack!!
}
for (ModelId reference : modelResource.getReferences()) {
addModelToZip(zipOutputStream, reference);
}
} catch (NotAuthorizedException notAuthorized) {
return;
}
}
Aggregations