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