Package org.apache.tuscany.sca.implementation.data.collection

Examples of org.apache.tuscany.sca.implementation.data.collection.Item


    private org.apache.tuscany.sca.implementation.data.collection.Entry<Object, Object> createEntry(SyndEntry feedEntry) {
        if (feedEntry != null) {
            if (itemClassType.getPhysical() == Item.class) {
                String key = feedEntry.getUri();
               
                Item item = new Item();
                item.setTitle(feedEntry.getTitle());
               
                List<?> contents = feedEntry.getContents();
                if (!contents.isEmpty()) {
                    SyndContent content = (SyndContent)contents.get(0);
                    String value = content.getValue();
                    item.setContents(value);
                }
               
                for (Object l : feedEntry.getLinks()) {
                    SyndLink link = (SyndLink)l;
                    if (link.getRel() == null || "edit".equals(link.getRel())) {
                        String href = link.getHref();
                        if (href.startsWith("null/")) {
                            href = href.substring(5);
                        }
                        item.setLink(href);
                        break;
                    }
                }
               
                item.setDate(feedEntry.getPublishedDate());
               
                return new org.apache.tuscany.sca.implementation.data.collection.Entry<Object, Object>(key, item);
               
            } else {
                String key = feedEntry.getUri();
View Full Code Here


                                       DataType<?> itemClassType, DataType<?> itemXMLType, Mediator mediator) {
        if (feedEntry != null) {
            if (itemClassType.getPhysical() == Item.class) {
                String key = feedEntry.getId().toString();
               
                Item item = new Item();
                item.setTitle(feedEntry.getTitle());
                item.setContents(feedEntry.getContent());
               
                for (Link link : feedEntry.getLinks()) {
                    if (link.getRel() == null || "self".equals(link.getRel())) {
                        if (item.getLink() == null) {
                            item.setLink(link.getHref().toString());
                        }
                    } else if ("related".equals(link.getRel())) {
                        item.setRelated(link.getHref().toString());
                    } else if ("alternate".equals(link.getRel())) {
                        item.setAlternate(link.getHref().toString());
                    }
                }
               
                item.setDate(feedEntry.getUpdated());
               
                return new Entry<Object, Object>(key, item);
               
            } else {
                String key = null;
View Full Code Here

     *
     * @param fileName
     * @return
     */
    private static Item item(String fileName) {
        Item item = new Item();
        item.setTitle(fileName);
        item.setLink("/files/" + fileName);
        return item;
    }
View Full Code Here

                                  DataType<?> itemClassType, DataType<?> itemXMLType, Mediator mediator,
                                  Factory factory) {
        Object key = entry.getKey();
        Object data = entry.getData();
        if (data instanceof Item) {
            Item item = (Item)data;
           
            org.apache.abdera.model.Entry feedEntry = factory.newEntry();
            if (key != null) {
                feedEntry.setId(key.toString());
            }
            feedEntry.setTitle(item.getTitle());
            feedEntry.setContentAsHtml(item.getContents());
   
            String href = item.getLink();
            if (href == null && key != null) {
                href = key.toString();
            }
   
            if (href != null) {
                feedEntry.addLink(href);
            }
            String related = item.getRelated();
            if (related != null) {
                feedEntry.addLink(related, "related");
            }
            String alternate = item.getAlternate();
            if (alternate != null) {
                feedEntry.addLink(alternate, "alternate");
            }
               
            Date date = item.getDate();
            if (date != null) {
                feedEntry.setUpdated(date);
            }
            return feedEntry;
           
View Full Code Here

        // Get the list of contributions in the workspace
        Entry<String, Item>[] contributionEntries = contributionCollection.getAll();

        // Read contribution metadata
        for (Entry<String, Item> contributionEntry: contributionEntries) {
            Item contributionItem = contributionEntry.getData();
            Contribution contribution;
            try {
                contribution = contribution(contributionEntry.getKey(), contributionItem.getAlternate());
            } catch (ContributionReadException e) {
                continue;
            }

            // Create entries for the deployable composites
View Full Code Here

    public Item get(String key) throws NotFoundException {
        logger.info("get " + key);

        // Get the specified contribution info
        String contributionURI = contributionURI(key);
        Item contributionItem = contributionCollection.get(contributionURI);
       
        // Read the contribution
        Contribution contribution;
        try {
            contribution = contribution(contributionURI, contributionItem.getAlternate());
        } catch (ContributionReadException e) {
            throw new NotFoundException(key);
        }

        // Find the specified deployable composite
View Full Code Here

            // contribution
            List<Entry<String, Item>> entries = new ArrayList<Entry<String, Item>>();

            // Get the specified contribution info
            String contributionURI = queryString.substring(queryString.indexOf('=') + 1);
            Item contributionItem;
            try {
                contributionItem = contributionCollection.get(contributionURI);
            } catch (NotFoundException e) {
                return entries.toArray(new Entry[entries.size()]);
            }
           
            // Read the contribution
            Contribution contribution;
            try {
                contribution = contribution(contributionURI, contributionItem.getAlternate());
            } catch (ContributionReadException e) {
                return entries.toArray(new Entry[entries.size()]);
            }

            // Create entries for the deployable composites
View Full Code Here

            if (contribution == null) {
               
                // The contribution has not been loaded yet, load it with all its dependencies
                Entry<String, Item>[] entries = contributionCollection.query("alldependencies=" + contributionURI);
                for (Entry<String, Item> entry: entries) {
                    Item contributionItem = entry.getData();
   
                    // Read the contribution
                    Contribution c;
                    try {
                        c = contribution(loadedContributions, entry.getKey(), contributionItem.getAlternate());
                    } catch (ContributionReadException e) {
                        continue;
                    }
                    loadedContributions.add(c);
                    if (contributionURI.equals(entry.getKey())) {
View Full Code Here

            QName qname = compositeQName(key);

            // Load the contribution
            Contribution contribution = contributionMap.get(contributionURI);
            if (contribution == null) {
                Item contributionItem = contributionCollection.get(contributionURI);
               
                // Read the contribution
                try {
                    contribution = contribution(loadedContributions, contributionURI, contributionItem.getAlternate());
                } catch (ContributionReadException e) {
                    continue;
                }
                loadedContributions.add(contribution);
                contributionMap.put(contributionURI, contribution);
View Full Code Here

    private static Item item(Contribution contribution, Composite deployable) {
        String contributionURI = contribution.getURI();
        String contributionLocation = contribution.getLocation();
        QName qname = deployable.getName();
        String deployableURI = deployable.getURI();
        Item item = new Item();
        item.setTitle(compositeTitle(contributionURI, qname));
        item.setContents(content(deployable));
        item.setLink(compositeSourceLink(contributionURI, qname));
        item.setAlternate(compositeAlternateLink(contributionLocation, deployableURI));
        item.setRelated(relatedLink(deployable));
        return item;
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.implementation.data.collection.Item

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.