Package org.drools.guvnor.server.jaxrs.providers.atom

Examples of org.drools.guvnor.server.jaxrs.providers.atom.Entry


        f.setTitle(categoryPath);
        AssetItemPageResult result = rulesRepository.findAssetsByCategory(
                categoryPath, 0, pageSize);
        List<AssetItem> assets = result.assets;
        for (AssetItem item : assets) {
            Entry e = toAssetEntryAbdera(item, uriInfo);
            f.getEntries().add(e);
        }

        if (result.hasNext) {
            Link l = new Link();
View Full Code Here


                    .path("packages/{packageName}/versions/{version}").build(p.getName(), Long.toString(p.getVersionNumber()));
        } else {
            baseUri = uriInfo.getBaseUriBuilder().path("packages/{packageName}").build(p.getName());
        }

        Entry e = new Entry();
        e.setTitle(p.getTitle());
        e.setSummary(p.getDescription());
        e.setPublished(new Date(p.getLastModified().getTimeInMillis()));
        e.setBase(baseUri);
        e.getAuthors().add(new Person(p.getLastContributor()));

        e.setId(baseUri);

        Iterator<AssetItem> i = p.getAssets();
        while (i.hasNext()) {
            AssetItem item = i.next();
            Link l = new Link();

            l.setHref(UriBuilder.fromUri(baseUri).path("assets/{assetName}").build(item.getName()));
            l.setTitle(item.getTitle());
            l.setRel("asset");
            e.getLinks().add(l);
        }
        //generate meta data
        AtomPackageMetadata metaData = (AtomPackageMetadata) e.getAnyOtherJAXBObject();
        if (metaData == null) {
            metaData = new AtomPackageMetadata();
        }
        metaData.setArchived(p.isArchived());
        metaData.setUuid(p.getUUID());
        metaData.setState(p.getState() == null ? "" : p.getState().getName());
        metaData.setVersionNumber(p.getVersionNumber());
        metaData.setCheckinComment(p.getCheckinComment());

        e.setAnyOtherJAXBObject(metaData);
        Content content = new Content();
        content.setSrc(UriBuilder.fromUri(baseUri).path("binary").build());
        content.setType(MediaType.APPLICATION_OCTET_STREAM_TYPE);
//        content.setContentType(Type.MEDIA); // TODO remove me if not it's base64 encoded fine
        e.setContent(content);
        return e;
    }
View Full Code Here

            baseUri = uriInfo.getBaseUriBuilder()
                    .path("packages/{packageName}/assets/{assetName}")
                    .build(a.getModuleName(), a.getName());
        }

        Entry e = new Entry();
        e.setTitle(a.getTitle());
        e.setSummary(a.getDescription());
        e.setPublished(new Date(a.getLastModified().getTimeInMillis()));
        e.setBase(baseUri);
        e.getAuthors().add(new Person(a.getLastContributor()));

        e.setId(baseUri);
        try {
            AtomAssetMetadata atomAssetMetadata  = e.getAnyOtherJAXBObject(AtomAssetMetadata.class);
            if (atomAssetMetadata == null) {
                atomAssetMetadata = new AtomAssetMetadata();
            }
            atomAssetMetadata.setArchived(a.isArchived());
            atomAssetMetadata.setUuid(a.getUUID());
            atomAssetMetadata.setState(a.getState() == null ? "" : a.getState().getName());
            atomAssetMetadata.setFormat(a.getFormat());
            atomAssetMetadata.setVersionNumber(a.getVersionNumber());
            atomAssetMetadata.setCheckinComment(a.getCheckinComment());
            String[] categories = new String[a.getCategories().size()];
            int i = 0;
            for (CategoryItem cItem : a.getCategories()) {
                categories[i] = cItem.getName();
                i++;
            }
            atomAssetMetadata.setCategories(categories);
            e.setAnyOtherJAXBObject(atomAssetMetadata);
        } catch (Exception ex) {
            throw new WebServiceException(ex);
        }
        Content content = new Content();
        content.setSrc(UriBuilder.fromUri(baseUri).path("binary").build());
        content.setType(MediaType.APPLICATION_OCTET_STREAM_TYPE);
//        content.setContentType(Type.MEDIA); // TODO remove me if not it's base64 encoded fine
        e.setContent(content);

        return e;
    }
View Full Code Here

        f.setTitle("Packages");
        f.setBase(uriInfo.getBaseUriBuilder().path("packages").build());
        ModuleIterator iter = rulesRepository.listModules();
        while (iter.hasNext()) {
            ModuleItem item = iter.next();
            Entry e = new Entry();
            e.setTitle(item.getName());
            Link l = new Link();
            l.setHref(uriInfo.getBaseUriBuilder()
                    .path("packages/{itemName}")
                    .build(item.getName()));
            e.getLinks().add(l);
            f.getEntries().add(e);
        }

        return f;
    }
View Full Code Here

        while (it.hasNext()) {
            try {
                ModuleItem historicalPackage = it.next();
                if (historicalPackage.getVersionNumber() != 0) {
                    Entry e = new Entry();
                    e.setTitle(Long.toString(historicalPackage
                            .getVersionNumber()));
                    e.setUpdated(historicalPackage.getLastModified().getTime());
                    Link l = new Link();
                    l.setHref(uriInfo
                            .getBaseUriBuilder()
                            .path("packages/{packageName}/versions/{versionNumber}")
                            .build(p.getName(), Long.toString(historicalPackage.getVersionNumber())));
                    e.getLinks().add(l);
                    f.getEntries().add(e);
                }
            } catch (RuntimeException e) {
                throw new WebApplicationException(e);
            }
View Full Code Here

                       
            AssetHistoryIterator it = asset.getHistory();
            while (it.hasNext()) {
                AssetItem historicalAsset = it.next();
                if (historicalAsset.getVersionNumber() != 0) {
                    Entry e = new Entry();
                    e.setTitle(Long.toString(historicalAsset
                            .getVersionNumber()));
                    e.setUpdated(historicalAsset.getLastModified().getTime());
                    Link l = new Link();
                    l.setHref(uriInfo
                            .getBaseUriBuilder()
                            .path("packages/{packageName}/assets/{assetName}/versions/{versionNumber}")
                            .build(asset.getModuleName(), asset.getName(),
                                    Long.toString(historicalAsset.getVersionNumber())));
                    e.getLinks().add(l);
                    f.getEntries().add(e);
                }
            }
            return f;
        } catch (RuntimeException e) {
View Full Code Here

        f.setTitle("Packages");
        f.setBase(uriInfo.getBaseUriBuilder().path("packages").build());
        ModuleIterator iter = rulesRepository.listModules();
        while (iter.hasNext()) {
            ModuleItem item = iter.next();
            Entry e = new Entry();
            e.setTitle(item.getName());
            Link l = new Link();
            l.setHref(uriInfo.getBaseUriBuilder()
                    .path("packages/{itemName}")
                    .build(item.getName()));
            e.getLinks().add(l);
            f.getEntries().add(e);
        }

        return f;
    }
View Full Code Here

        while (it.hasNext()) {
            try {
                ModuleItem historicalPackage = it.next();
                if (historicalPackage.getVersionNumber() != 0) {
                    Entry e = new Entry();
                    e.setTitle(Long.toString(historicalPackage
                            .getVersionNumber()));
                    e.setUpdated(historicalPackage.getLastModified().getTime());
                    Link l = new Link();
                    l.setHref(uriInfo
                            .getBaseUriBuilder()
                            .path("packages/{packageName}/versions/{versionNumber}")
                            .build(p.getName(), Long.toString(historicalPackage.getVersionNumber())));
                    e.getLinks().add(l);
                    f.getEntries().add(e);
                }
            } catch (RuntimeException e) {
                throw new WebApplicationException(e);
            }
View Full Code Here

                       
            AssetHistoryIterator it = asset.getHistory();
            while (it.hasNext()) {
                AssetItem historicalAsset = it.next();
                if (historicalAsset.getVersionNumber() != 0) {
                    Entry e = new Entry();
                    e.setTitle(Long.toString(historicalAsset
                            .getVersionNumber()));
                    e.setUpdated(historicalAsset.getLastModified().getTime());
                    Link l = new Link();
                    l.setHref(uriInfo
                            .getBaseUriBuilder()
                            .path("packages/{packageName}/assets/{assetName}/versions/{versionNumber}")
                            .build(asset.getModuleName(), asset.getName(),
                                    Long.toString(historicalAsset.getVersionNumber())));
                    e.getLinks().add(l);
                    f.getEntries().add(e);
                }
            }
            return f;
        } catch (RuntimeException e) {
View Full Code Here

TOP

Related Classes of org.drools.guvnor.server.jaxrs.providers.atom.Entry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.