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

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


   
    LinkedList<Contribution> contributions = new LinkedList<Contribution>();

    // 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;
      }
View Full Code Here


  public Item get(String key) throws NotFoundException {
    logger.fine("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);
    }
View Full Code Here

      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()]);
      }
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

        // 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

     */
    private SyndEntry createFeedEntry(org.apache.tuscany.sca.data.collection.Entry<Object, Object> entry) {
        Object key = entry.getKey();
        Object data = entry.getData();
        if (data instanceof Item) {
            Item item = (Item)data;
           
            SyndEntry feedEntry = new SyndEntryImpl();
            feedEntry.setUri(key.toString());
            feedEntry.setTitle(item.getTitle());
   
            String value = item.getContents();
            if (value != null) {
                SyndContent content = new SyndContentImpl();
                content.setType("text/xml");
                content.setValue(value);
                List<SyndContent> contents = new ArrayList<SyndContent>();
                contents.add(content);
                feedEntry.setContents(contents);
            }
   
            String href = item.getLink();
            if (href == null) {
                href = key.toString();
            }
            SyndLink link = new SyndLinkImpl();
            link.setRel("edit");
            link.setHref(href);
            feedEntry.getLinks().add(link);
            link = new SyndLinkImpl();
            link.setRel("alternate");
            link.setHref(href);
            feedEntry.getLinks().add(link);
            feedEntry.setLink(href);
   
            Date date = item.getDate();
            if (date == null) {
                date = new Date();
            }
            feedEntry.setPublishedDate(date);
            return feedEntry;
View Full Code Here

    private org.apache.tuscany.sca.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.data.collection.Entry<Object, Object>(key, item);
               
            } else {
                String key = feedEntry.getUri();
View Full Code Here

     * @param contribution
     * @return
     */
    private static Item item(Workspace workspace, Contribution contribution) {
        String contributionURI = contribution.getURI();
        Item item = new Item();
        item.setTitle(title(contributionURI));
        item.setLink(link(contributionURI));
        item.setAlternate(contribution.getLocation());
       
        // List the contribution dependencies in the item contents
        final List<String> problems = new ArrayList<String>();
        Monitor monitor = new Monitor() {
            public void problem(Problem problem) {
                problems.add(problem.getMessageId() + " " + problem.getProblemObject().toString());
            }
           
            public List<Problem> getProblems() {
                return null;
            }
            public Problem createProblem(String sourceClassName, String bundleName,
              Severity severity, Object problemObject, String messageId,
              Exception cause) {
            return new ProblemImpl(sourceClassName, bundleName, severity,
                problemObject, messageId, cause);
          }

          public Problem createProblem(String sourceClassName, String bundleName,
              Severity severity, Object problemObject, String messageId,
              Object... messageParams) {
            return new ProblemImpl(sourceClassName, bundleName, severity,
                problemObject, messageId, messageParams);
          }            
        };
       
        StringBuffer sb = new StringBuffer();
        ContributionDependencyBuilderImpl analyzer = new ContributionDependencyBuilderImpl(monitor);
        List<Contribution> dependencies = analyzer.buildContributionDependencies(contribution, workspace);
        if (dependencies.size() > 1) {
            sb.append("Dependencies: <span id=\"dependencies\">");
            for (int i = 0, n = dependencies.size(); i < n ; i++) {
                if (i > 0) {
                    sb.append("  ");
                }
                Contribution dependency = dependencies.get(i);
                if (dependency != contribution) {
                    String dependencyURI = dependency.getURI();
                    sb.append("<a href=\""+ link(dependencyURI) +"\">" + title(dependencyURI) + "</a>");
                }
            }
            sb.append("</span><br>");
        }
       
        // List the deployables
        List<Composite> deployables = contribution.getDeployables();
        if (!deployables.isEmpty()) {
            sb.append("Deployables: <span id=\"deployables\">");
            for (int i = 0, n = deployables.size(); i < n ; i++) {
                if (i > 0) {
                    sb.append("  ");
                }
                Composite deployable = deployables.get(i);
                QName qname = deployable.getName();
                sb.append("<a href=\""+ compositeSourceLink(contributionURI, qname) +"\">" + compositeSimpleTitle(contributionURI, qname) + "</a>");
            }
            sb.append("</span><br>");
        }
       
        // List the dependency problems
        if (contribution.isUnresolved()) {
            problems.add("Contribution not found");
        }
        if (problems.size() > 0) {
            sb.append("<span id=\"problems\" style=\"color: red\">");
            for (int i = 0, n = problems.size(); i < n ; i++) {
                sb.append("Problem: "+ problems.get(i) + "<br>");
            }
            sb.append("</span>");
        }
       
        // Store in the item contents
        item.setContents(sb.toString());
       
        return item;
    }
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

                                       Mediator mediator) {
        if (feedEntry != null) {
            if (itemClassType.getPhysical() == Item.class) {
                String key = feedEntry.getId().toString();

                Item item = new Item();
                item.setTitle(feedEntry.getTitle().toString());
                TextContent content = (TextContent)feedEntry.getContent();
                item.setContents(content.getContent().getPlainText());

                for (com.google.gdata.data.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());
                    }
                }

                Date date = new Date(feedEntry.getUpdated().getValue());
                item.setDate(date);
                return new Entry<Object, Object>(key, item);

            } else {
                String key = null;
                if (feedEntry.getId() != null) {
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.