Search in sources :

Example 21 with CatalogItem

use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.

the class ProvisioningJobListener method done.

@Override
public void done(IJobChangeEvent event) {
    if (event.getResult().isOK()) {
        Job job = new Job(Messages.ProvisioningJobListener_notificationTaskName) {

            {
                setPriority(Job.LONG);
                setSystem(true);
                setUser(true);
            }

            @Override
            protected IStatus run(final IProgressMonitor monitor) {
                ConcurrentTaskManager taskManager = new ConcurrentTaskManager(installItems.size(), Messages.ProvisioningJobListener_notificationTaskName);
                for (CatalogItem item : installItems) {
                    if (item instanceof MarketplaceNodeCatalogItem) {
                        final MarketplaceNodeCatalogItem nodeItem = (MarketplaceNodeCatalogItem) item;
                        taskManager.submit(new Runnable() {

                            public void run() {
                                INode node = nodeItem.getData();
                                URL marketplaceUrl = nodeItem.getMarketplaceUrl();
                                IMarketplaceService marketplaceService = ServiceHelper.getMarketplaceServiceLocator().getMarketplaceService(marketplaceUrl.toString());
                                marketplaceService.reportInstallSuccess(node, new NullProgressMonitor() {

                                    @Override
                                    public boolean isCanceled() {
                                        return monitor.isCanceled();
                                    }
                                });
                            }
                        });
                    }
                }
                try {
                    taskManager.waitUntilFinished(monitor);
                } catch (CoreException e) {
                    return e.getStatus();
                }
                return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
            }
        };
        job.schedule();
    }
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) INode(org.eclipse.epp.mpc.core.model.INode) CoreException(org.eclipse.core.runtime.CoreException) ConcurrentTaskManager(org.eclipse.epp.internal.mpc.ui.util.ConcurrentTaskManager) Job(org.eclipse.core.runtime.jobs.Job) IMarketplaceService(org.eclipse.epp.mpc.core.service.IMarketplaceService) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem) URL(java.net.URL)

Example 22 with CatalogItem

use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.

the class SelectionModel method getCatalogItemEntries.

public List<CatalogItemEntry> getCatalogItemEntries() {
    if (entries == null) {
        List<CatalogItemEntry> entries = new ArrayList<CatalogItemEntry>();
        for (Entry<CatalogItem, Operation> entry : itemToOperation.entrySet()) {
            CatalogItem item = entry.getKey();
            Operation operation = entry.getValue();
            CatalogItemEntry itemEntry = createItemEntry(item, operation);
            entries.add(itemEntry);
        }
        this.entries = entries;
    }
    return entries;
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem) ArrayList(java.util.ArrayList) Operation(org.eclipse.epp.mpc.ui.Operation)

Example 23 with CatalogItem

use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.

the class SelectionModelStateSerializer method serialize.

public String serialize() {
    StringBuilder state = new StringBuilder(1024);
    for (Map.Entry<CatalogItem, Operation> entry : selectionModel.getItemToSelectedOperation().entrySet()) {
        if (entry.getValue() != Operation.NONE) {
            if (state.length() > 0) {
                state.append(' ');
            }
            INode data = (INode) entry.getKey().getData();
            state.append(data.getId());
            state.append('=');
            state.append(entry.getValue().name());
        }
    }
    return state.toString();
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem) INode(org.eclipse.epp.mpc.core.model.INode) Operation(org.eclipse.epp.mpc.ui.Operation) Map(java.util.Map) HashMap(java.util.HashMap)

Example 24 with CatalogItem

use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.

the class SelectionModelStateSerializer method deserialize.

/**
 * @param state
 *            the state to restore
 * @param operationByNodeExtras
 *            additional operations to include
 * @param monitor
 */
public void deserialize(String state, Map<String, Operation> operationByNodeExtras, IProgressMonitor monitor) {
    Map<String, Operation> operationByNodeId = new HashMap<String, Operation>();
    if (state != null && state.length() > 0) {
        // $NON-NLS-1$
        Pattern pattern = Pattern.compile("([^\\s=]+)=(\\S+)");
        Matcher matcher = pattern.matcher(state);
        while (matcher.find()) {
            String nodeId = matcher.group(1);
            String operationName = matcher.group(2);
            Operation operation = Operation.valueOf(operationName);
            operationByNodeId.put(nodeId, operation);
        }
    }
    if (operationByNodeExtras != null) {
        operationByNodeId.putAll(operationByNodeExtras);
    }
    if (!operationByNodeId.isEmpty()) {
        catalog.performQuery(monitor, operationByNodeId.keySet());
        for (CatalogItem item : catalog.getItems()) {
            if (item instanceof MarketplaceNodeCatalogItem) {
                MarketplaceNodeCatalogItem nodeItem = (MarketplaceNodeCatalogItem) item;
                Operation operation = operationByNodeId.get(nodeItem.getData().getId());
                if (operation != null && operation != Operation.NONE) {
                    if (nodeItem.isInstalled() && operation == Operation.INSTALL) {
                        operation = Operation.UPDATE;
                    }
                    selectionModel.select(nodeItem, operation);
                }
            }
        }
    }
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem) Pattern(java.util.regex.Pattern) HashMap(java.util.HashMap) Matcher(java.util.regex.Matcher) Operation(org.eclipse.epp.mpc.ui.Operation) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem)

Example 25 with CatalogItem

use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.

the class MarketplaceDiscoveryStrategy method installErrorReport.

public void installErrorReport(IProgressMonitor monitor, IStatus result, Set<CatalogItem> items, IInstallableUnit[] operationIUs, String resolutionDetails) throws CoreException {
    SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceDiscoveryStrategy_sendingErrorNotification, 100);
    try {
        Set<Node> nodes = new HashSet<Node>();
        for (CatalogItem item : items) {
            Object data = item.getData();
            if (data instanceof INode) {
                nodes.add((Node) data);
            }
        }
        Set<String> iuIdsAndVersions = new HashSet<String>();
        for (IInstallableUnit iu : operationIUs) {
            String id = iu.getId();
            String version = iu.getVersion() == null ? null : iu.getVersion().toString();
            // $NON-NLS-1$
            iuIdsAndVersions.add(id + "," + version);
        }
        marketplaceService.reportInstallError(result, nodes, iuIdsAndVersions, resolutionDetails, progress);
    } finally {
        progress.done();
    }
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) INode(org.eclipse.epp.mpc.core.model.INode) Node(org.eclipse.epp.internal.mpc.core.model.Node) INode(org.eclipse.epp.mpc.core.model.INode) SubMonitor(org.eclipse.core.runtime.SubMonitor) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) HashSet(java.util.HashSet)

Aggregations

CatalogItem (org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)30 ArrayList (java.util.ArrayList)10 MarketplaceNodeCatalogItem (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem)9 Operation (org.eclipse.epp.mpc.ui.Operation)9 HashSet (java.util.HashSet)7 INode (org.eclipse.epp.mpc.core.model.INode)7 CoreException (org.eclipse.core.runtime.CoreException)6 IStatus (org.eclipse.core.runtime.IStatus)6 HashMap (java.util.HashMap)5 SubMonitor (org.eclipse.core.runtime.SubMonitor)5 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 Status (org.eclipse.core.runtime.Status)4 FeatureEntry (org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry)4 URISyntaxException (java.net.URISyntaxException)3 Entry (java.util.Map.Entry)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 CatalogCategory (org.eclipse.equinox.internal.p2.discovery.model.CatalogCategory)3 ProfileChangeOperation (org.eclipse.equinox.p2.operations.ProfileChangeOperation)3