Search in sources :

Example 6 with Marketplace

use of org.eclipse.epp.internal.mpc.core.model.Marketplace in project epp.mpc by eclipse.

the class MarketplaceContentHandler method startElement.

@Override
public void startElement(String uri, String localName, Attributes attributes) throws SAXException {
    if (localName.equals("marketplace")) {
        // $NON-NLS-1$
        model = new Marketplace();
    } else {
        Unmarshaller unmarshaller = getUnmarshaller();
        UnmarshalContentHandler childHandler = unmarshaller == null ? null : unmarshaller.getHandler(localName);
        if (unmarshaller != null && childHandler != null) {
            childHandler.setParentModel(model);
            childHandler.setParentHandler(this);
            childHandler.setUnmarshaller(unmarshaller);
            unmarshaller.setCurrentHandler(childHandler);
            childHandler.startElement(uri, localName, attributes);
        }
    }
}
Also used : Marketplace(org.eclipse.epp.internal.mpc.core.model.Marketplace)

Example 7 with Marketplace

use of org.eclipse.epp.internal.mpc.core.model.Marketplace in project epp.mpc by eclipse.

the class DefaultMarketplaceService method related.

public SearchResult related(List<? extends INode> basedOn, IProgressMonitor monitor) throws CoreException {
    // $NON-NLS-1$
    String basedOnQuery = "";
    if (basedOn != null && !basedOn.isEmpty()) {
        StringBuilder sb = new StringBuilder().append('?').append(PARAM_BASED_ON_NODES).append('=');
        boolean first = true;
        for (INode node : basedOn) {
            if (!first) {
                sb.append('+');
            }
            sb.append(node.getId());
            first = false;
        }
        basedOnQuery = sb.toString();
    }
    Marketplace marketplace = processRequest(API_RELATED_URI + '/' + API_URI_SUFFIX + basedOnQuery, monitor);
    return createSearchResult(marketplace.getRelated());
}
Also used : INode(org.eclipse.epp.mpc.core.model.INode) Marketplace(org.eclipse.epp.internal.mpc.core.model.Marketplace)

Example 8 with Marketplace

use of org.eclipse.epp.internal.mpc.core.model.Marketplace in project epp.mpc by eclipse.

the class DefaultMarketplaceService method getNode.

public Node getNode(INode node, IProgressMonitor monitor) throws CoreException {
    Marketplace marketplace;
    String query;
    if (node.getId() != null) {
        // bug 304928: prefer the id method rather than the URL, since the id provides a stable URL and the
        // URL is based on the name, which could change.
        query = node.getId();
        String encodedId = urlEncode(node.getId());
        marketplace = processRequest(API_NODE_URI + '/' + encodedId + '/' + API_URI_SUFFIX, monitor);
    } else {
        query = node.getUrl();
        marketplace = processRequest(node.getUrl(), API_URI_SUFFIX, monitor);
    }
    if (marketplace.getNode().isEmpty()) {
        throw new CoreException(createErrorStatus(Messages.DefaultMarketplaceService_nodeNotFound, query));
    } else if (marketplace.getNode().size() > 1) {
        throw new CoreException(createErrorStatus(Messages.DefaultMarketplaceService_unexpectedResponse, query));
    }
    Node resolvedNode = marketplace.getNode().get(0);
    return resolvedNode;
}
Also used : Marketplace(org.eclipse.epp.internal.mpc.core.model.Marketplace) CoreException(org.eclipse.core.runtime.CoreException) Node(org.eclipse.epp.internal.mpc.core.model.Node) INode(org.eclipse.epp.mpc.core.model.INode)

Example 9 with Marketplace

use of org.eclipse.epp.internal.mpc.core.model.Marketplace in project epp.mpc by eclipse.

the class DefaultMarketplaceService method featured.

public SearchResult featured(IMarket market, ICategory category, IProgressMonitor monitor) throws CoreException {
    // $NON-NLS-1$
    String nodePart = "";
    if (market != null) {
        nodePart += urlEncode(market.getId());
    }
    if (category != null) {
        if (nodePart.length() > 0) {
            // $NON-NLS-1$
            nodePart += ",";
        }
        nodePart += urlEncode(category.getId());
    }
    String uri = API_FEATURED_URI + '/';
    if (nodePart.length() > 0) {
        uri += nodePart + '/';
    }
    Marketplace marketplace = processRequest(uri + API_URI_SUFFIX, monitor);
    return createSearchResult(marketplace.getFeatured());
}
Also used : Marketplace(org.eclipse.epp.internal.mpc.core.model.Marketplace)

Example 10 with Marketplace

use of org.eclipse.epp.internal.mpc.core.model.Marketplace in project epp.mpc by eclipse.

the class UnmarshallerTest method featured.

@Test
public void featured() throws IOException, UnmarshalException {
    // from http://www.eclipseplugincentral.net/api/v2/featured
    Object model = processResource("resources/featured.xml");
    assertNotNull(model);
    assertTrue(model instanceof Marketplace);
    Marketplace marketplace = (Marketplace) model;
    Featured featured = marketplace.getFeatured();
    assertNotNull(featured);
    assertEquals(Integer.valueOf(6), featured.getCount());
    assertEquals(6, featured.getNode().size());
    INode node = featured.getNode().get(0);
    assertEquals("248", node.getId());
    assertEquals("eUML2 free edition", node.getName());
    assertEquals("http://www.eclipseplugincentral.net/content/euml2-free-edition", node.getUrl());
    assertEquals("resource", node.getType());
    ICategories categories = node.getCategories();
    assertNotNull(categories);
    assertEquals(1, categories.getCategory().size());
    ICategory category = categories.getCategory().get(0);
    assertEquals("19", category.getId());
    assertEquals("UML", category.getName());
    assertEquals("http://www.eclipseplugincentral.net/taxonomy/term/19", category.getUrl());
    assertEquals("Yves YANG", node.getOwner());
    assertEquals(Integer.valueOf(0), node.getFavorited());
    assertNotNull(node.getBody());
    // bug 303149		assertTrue(node.getBody().startsWith("<P><STRONG>eUML2 for Java<"));
    // bug 303149		assertTrue(node.getBody().endsWith("</LI></UL>"));
    assertTrue(node.getFoundationmember());
    assertEquals("http://www.soyatec.com/", node.getHomepageurl());
    assertEquals("http://www.soyatec.com/euml2/images/product_euml2_110x80.png", node.getImage());
    assertEquals("3.4", node.getVersion());
    assertEquals("Free for non-commercial use", node.getLicense());
    assertEquals("Soyatec", node.getCompanyname());
    assertEquals("Mature", node.getStatus());
    assertEquals("3.4.x/3.5.x", node.getEclipseversion());
    assertEquals("http://www.soyatec.com/forum", node.getSupporturl());
    assertEquals("http://www.soyatec.com/update", node.getUpdateurl());
}
Also used : Marketplace(org.eclipse.epp.internal.mpc.core.model.Marketplace) INode(org.eclipse.epp.mpc.core.model.INode) ICategories(org.eclipse.epp.mpc.core.model.ICategories) ICategory(org.eclipse.epp.mpc.core.model.ICategory) Featured(org.eclipse.epp.internal.mpc.core.model.Featured) Test(org.junit.Test)

Aggregations

Marketplace (org.eclipse.epp.internal.mpc.core.model.Marketplace)18 INode (org.eclipse.epp.mpc.core.model.INode)11 ICategory (org.eclipse.epp.mpc.core.model.ICategory)9 Test (org.junit.Test)9 CoreException (org.eclipse.core.runtime.CoreException)4 ICategories (org.eclipse.epp.mpc.core.model.ICategories)4 Node (org.eclipse.epp.internal.mpc.core.model.Node)3 Category (org.eclipse.epp.internal.mpc.core.model.Category)2 Search (org.eclipse.epp.internal.mpc.core.model.Search)2 IMarket (org.eclipse.epp.mpc.core.model.IMarket)2 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 Favorites (org.eclipse.epp.internal.mpc.core.model.Favorites)1 Featured (org.eclipse.epp.internal.mpc.core.model.Featured)1 Market (org.eclipse.epp.internal.mpc.core.model.Market)1 News (org.eclipse.epp.internal.mpc.core.model.News)1