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