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

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


                                  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


     * @param content Contents of the feed entry
     * @param link Link for the feed entry
     * @return A new feed entry.
     */
    private Entry<Object, Object> createFeedEntry(String title, String content, String link) {
        final Item item = new Item(title, content, link, null, new Date());
        final Entry<Object, Object> entry = new Entry<Object, Object>(nextFeedID(), item);
        return entry;
    }
View Full Code Here

        entriesArray = (Entry<String,Item>[])entries.toArray(entriesArray);
        Arrays.sort(entriesArray, new Comparator() {
            public int compare(final Object xObj, final Object yObj) {
                Entry x = (Entry) xObj;
                Entry y = (Entry) yObj;
                Item xItem = (Item) x.getData();
                Item yItem = (Item) y.getData();
                Date xDate = xItem.getDate();
                Date yDate = yItem.getDate();
                if (xDate == null)
                    return -1;
                if (newFirst)
                    return yDate.compareTo(xDate);
                else
View Full Code Here

     *
     * @param vm
     * @return
     */
    private static Item item(SCANodeVM vm) {
        Item item = new Item();
        String key = vm.getNodeName();
        item.setTitle(title(key));
        item.setLink("/node-config/" + vm.getNodeName());
        item.setContents("<span id=\"log\" style=\"white-space: nowrap; font-size: small\">" + vm.getLog().toString() + "</span>");
        return item;
    }
View Full Code Here

        // The key is the contribution URI
        String key = path.startsWith("/")? path.substring(1) : path;
        logger.fine("get " + key);
       
        // Get the item describing the composite
        Item item;
        try {
            item = contributionCollection.get(key);
        } catch (NotFoundException e) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND, key);
            return;
        }

        // Redirect to the actual contribution location
        response.sendRedirect("/files/" + item.getAlternate());
    }
View Full Code Here

        Composite compositeCollection = readCompositeCollection();
        for (Composite composite: compositeCollection.getIncludes()) {
            String contributionURI = composite.getURI();
            QName qname = composite.getName();
            String key = compositeKey(contributionURI, qname);
            Item item;
            try {
                item = deployableCollection.get(key);
            } catch (NotFoundException e) {
                item = new Item();
                item.setTitle(compositeTitle(contributionURI, qname));
                item.setLink(compositeSourceLink(contributionURI, qname));
                item.setContents("<span id=\"problem\" style=\"color: red\">Problem: Composite not found</span>");
            }
            Entry<String, Item> entry = new Entry<String, Item>();
            entry.setKey(key);
            entry.setData(item);
            entries.add(entry);
View Full Code Here

        String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
        String key = path.startsWith("/")? path.substring(1) : path;
        logger.fine("get " + key);
       
        // Get the item describing the composite
        Item item;
        try {
            item = deployableCollection.get(key);
        } catch (NotFoundException e) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND, key);
            return;
        }

        // Read the composite file and write to response
        String uri = item.getAlternate();
        InputStream is;
        try {
            URLConnection connection = new URL(uri).openConnection();
            connection.setUseCaches(false);
            connection.connect();
View Full Code Here

        String key = path.startsWith("/")? path.substring(1) : path;
        logger.fine("get " + key);
       
        // Get the specified contribution info
        String contributionURI = contributionURI(key);
        Item contributionItem;
        try {
            contributionItem = contributionCollection.get(contributionURI);
        } catch (NotFoundException e) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND, key);
            return;
        }
       
        // Read the contribution
        Contribution contribution;
        try {
            contribution = contribution(contributionURI, contributionItem.getAlternate());
        } catch (ContributionReadException e) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND, key);
            return;
        }
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

                                  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

TOP

Related Classes of org.apache.tuscany.sca.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.