// //////////////////////////////////////
@Override
public Blob downloadLayouts() {
final LayoutMetadataReaderFromJson propertiesReader = new LayoutMetadataReaderFromJson();
final Collection<ObjectSpecification> allSpecs = specificationLoader.allSpecifications();
final Collection<ObjectSpecification> domainObjectSpecs = Collections2.filter(allSpecs, new Predicate<ObjectSpecification>(){
@Override
public boolean apply(ObjectSpecification input) {
return !input.isAbstract() &&
!input.isService() &&
!input.isValue() &&
!input.isParentedOrFreeCollection();
}});
try {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
OutputStreamWriter writer = new OutputStreamWriter(zos);
for (ObjectSpecification objectSpec : domainObjectSpecs) {
zos.putNextEntry(new ZipEntry(zipEntryNameFor(objectSpec)));
writer.write(propertiesReader.asJson(objectSpec));
writer.flush();
zos.closeEntry();
}
writer.close();
return new Blob("layouts.zip", mimeTypeApplicationZip, baos.toByteArray());