use of org.eclipse.epp.internal.mpc.core.model.Node in project epp.mpc by eclipse.
the class NodeContentHandler method startElement.
@Override
public void startElement(String uri, String localName, Attributes attributes) {
if (localName.equals("node")) {
// $NON-NLS-1$
model = new Node();
// $NON-NLS-1$
model.setId(attributes.getValue(NS_URI, "id"));
// $NON-NLS-1$
model.setName(attributes.getValue(NS_URI, "name"));
// $NON-NLS-1$
model.setUrl(attributes.getValue(NS_URI, "url"));
} else if (localName.equals("favorited")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("installstotal")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("installsrecent")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("type")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("categories")) {
// $NON-NLS-1$
CategoriesContentHandler childHandler = new CategoriesContentHandler();
childHandler.setParentModel(model);
childHandler.setParentHandler(this);
childHandler.setUnmarshaller(getUnmarshaller());
getUnmarshaller().setCurrentHandler(childHandler);
childHandler.startElement(uri, localName, attributes);
} else if (localName.equals("tags")) {
// $NON-NLS-1$
TagsContentHandler childHandler = new TagsContentHandler();
childHandler.setParentModel(model);
childHandler.setParentHandler(this);
childHandler.setUnmarshaller(getUnmarshaller());
getUnmarshaller().setCurrentHandler(childHandler);
childHandler.startElement(uri, localName, attributes);
} else if (localName.equals("owner")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("shortdescription")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("body")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("created")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("changed")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("foundationmember")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("homepageurl")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("image")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("screenshot")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("version")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("license")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("companyname")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("status")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("eclipseversion")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("supporturl")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("updateurl")) {
// $NON-NLS-1$
capturingContent = true;
} else if (localName.equals("ius")) {
// $NON-NLS-1$
IusContentHandler childHandler = new IusContentHandler();
childHandler.setParentModel(model);
childHandler.setParentHandler(this);
childHandler.setUnmarshaller(getUnmarshaller());
getUnmarshaller().setCurrentHandler(childHandler);
childHandler.startElement(uri, localName, attributes);
} else if (localName.equals("platforms")) {
// $NON-NLS-1$
PlatformsContentHandler childHandler = new PlatformsContentHandler();
childHandler.setParentModel(model);
childHandler.setParentHandler(this);
childHandler.setUnmarshaller(getUnmarshaller());
getUnmarshaller().setCurrentHandler(childHandler);
childHandler.startElement(uri, localName, attributes);
}
}
use of org.eclipse.epp.internal.mpc.core.model.Node in project epp.mpc by eclipse.
the class DefaultMarketplaceService method getNodesByUrl.
private void getNodesByUrl(Collection<? extends INode> nodes, Map<INode, INode> resolvedNodeMapping, IProgressMonitor monitor) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, nodes.size());
int remaining = nodes.size();
for (INode node : nodes) {
if (node.getId() == null && node.getUrl() != null) {
Node resolvedNode = getNode(node, progress.newChild(1));
resolvedNodeMapping.put(node, resolvedNode);
}
progress.setWorkRemaining(--remaining);
}
}
use of org.eclipse.epp.internal.mpc.core.model.Node in project epp.mpc by eclipse.
the class DefaultMarketplaceService method getNodesById.
private void getNodesById(Collection<? extends INode> nodes, Map<INode, INode> resolvedNodeMapping, IProgressMonitor monitor) throws CoreException {
StringBuilder nodeIdQuery = new StringBuilder();
Map<String, INode> nodeIds = new HashMap<String, INode>(nodes.size());
for (INode node : nodes) {
if (node.getId() == null) {
continue;
}
nodeIds.put(node.getId(), node);
String encodedId = urlEncode(node.getId());
if (nodeIdQuery.length() > 0) {
// $NON-NLS-1$
nodeIdQuery.append(",");
}
nodeIdQuery.append(encodedId);
}
Marketplace marketplace = processRequest(API_NODE_URI + '/' + nodeIdQuery + '/' + API_URI_SUFFIX, monitor);
List<Node> resolvedNodes = marketplace.getNode();
for (Node node : resolvedNodes) {
INode inputNode = nodeIds.get(node.getId());
if (inputNode != null) {
resolvedNodeMapping.put(inputNode, node);
} else {
throw new CoreException(createErrorStatus(Messages.DefaultMarketplaceService_unexpectedResponse, nodeIdQuery));
}
}
}
use of org.eclipse.epp.internal.mpc.core.model.Node in project epp.mpc by eclipse.
the class DefaultMarketplaceService method processSearchRequest.
private SearchResult processSearchRequest(String relativeUrl, String queryText, IProgressMonitor monitor) throws CoreException {
SearchResult result = new SearchResult();
if (relativeUrl == null) {
// empty search
result.setMatchCount(0);
result.setNodes(new ArrayList<Node>());
} else {
Marketplace marketplace;
try {
marketplace = processRequest(relativeUrl, monitor);
} catch (CoreException ex) {
Throwable cause = ex.getCause();
if (cause instanceof FileNotFoundException) {
throw new CoreException(createErrorStatus(NLS.bind(Messages.DefaultMarketplaceService_UnsupportedSearchString, queryText), cause));
}
throw ex;
}
Search search = marketplace.getSearch();
if (search != null) {
result.setMatchCount(search.getCount());
result.setNodes(search.getNode());
} else if (marketplace.getCategory().size() == 1) {
Category category = marketplace.getCategory().get(0);
result.setMatchCount(category.getNode().size());
result.setNodes(category.getNode());
} else {
throw new CoreException(createErrorStatus(Messages.DefaultMarketplaceService_unexpectedResponse, relativeUrl));
}
}
return result;
}
use of org.eclipse.epp.internal.mpc.core.model.Node in project epp.mpc by eclipse.
the class MarketplaceUrlHandler method handleNode.
private boolean handleNode(CatalogDescriptor descriptor, String url) {
Matcher matcher = NODE_URL_PATTERN.matcher(url);
String id = null;
if (matcher.find()) {
id = matcher.group(1);
}
Node node = new Node();
node.setId(id);
return handleNode(descriptor, url, node);
}
Aggregations