public long getSize( IProvisioningPlan provisioningPlan, IProfile profile, IEngine engine, ProvisioningContext context, IProgressMonitor monitor) { // If there is nothing to size, return 0 if (provisioningPlan == null) { return SIZE_NOTAPPLICABLE; } if (((ProvisioningPlan) provisioningPlan).getOperands().length == 0) { return 0; } long installPlanSize = 0; if (provisioningPlan.getInstallerPlan() != null) { SizingPhaseSet set = new SizingPhaseSet(new Sizing(100)); IStatus status = engine.perform(provisioningPlan, set, null); if (status.isOK()) { installPlanSize = set.getSizing().getDiskSize(); } } SizingPhaseSet set = new SizingPhaseSet(new Sizing(100)); IStatus status = engine.perform(provisioningPlan, set, null); if (status.isOK()) { return installPlanSize + set.getSizing().getDiskSize(); } return SIZE_UNAVAILABLE; }
public void testExtractRootCauseErrorStatusWithException() throws Exception { IStatus status = extractRootCause(new Status(IStatus.ERROR, "id1", "Test", new IOException("IO"))); assertNotNull(status); assertEquals("id1", status.getPlugin()); assertEquals("Test", status.getMessage()); assertEquals("IO", status.getException().getMessage()); }
private static int collectStatus(OutputStream stream, ArrayList<IStatus> list) { IStatus status = getStatus(stream); list.add(status); OutputStream destination = getDestination(stream); if (destination == null || !(destination instanceof IStateful)) return status.getSeverity(); int result = collectStatus(destination, list); // TODO greater than test here is a little brittle but it is very unlikely that we will add // a new status severity. return status.getSeverity() > result ? status.getSeverity() : result; }
@Override public String getToolTipText() { if (status != null && !status.isOK()) { return status.getMessage(); } if (gotoAction != null) { return gotoAction.getToolTipText(); } return Utils.shortenText( SynchronizeView.MAX_NAME_LENGTH, RefreshParticipantJob.this.getName()); }
public void testGetAction() { final ArrayList actionsList1 = new ArrayList(); InstallableUnitPhase phase1 = new InstallableUnitPhase("test", 1) { protected List<ProvisioningAction> getActions(InstallableUnitOperand operand) { List<ProvisioningAction> actions = getActions(operand.second(), "test1"); actionsList1.addAll(actions); return actions; } }; final ArrayList actionsList2 = new ArrayList(); InstallableUnitPhase phase2 = new InstallableUnitPhase("test", 1) { protected List<ProvisioningAction> getActions(InstallableUnitOperand operand) { List<ProvisioningAction> actions = getActions(operand.second(), "test2"); actionsList2.addAll(actions); return actions; } }; PhaseSet phaseSet = new TestPhaseSet(new Phase[] {phase1, phase2}); IProfile profile = createProfile("PhaseTest"); Map instructions = new HashMap(); instructions.put("test1", MetadataFactory.createTouchpointInstruction("test1.test()", null)); instructions.put("test2", MetadataFactory.createTouchpointInstruction("test2.test()", null)); ITouchpointData touchpointData = MetadataFactory.createTouchpointData(instructions); IInstallableUnit unit = createIU( "test", Version.create("1.0.0"), null, NO_REQUIRES, new IProvidedCapability[0], NO_PROPERTIES, ITouchpointType.NONE, touchpointData, false); IProvisioningPlan plan = engine.createPlan(profile, null); plan.addInstallableUnit(unit); IStatus status = engine.perform(plan, phaseSet, new NullProgressMonitor()); if (!status.isOK()) { fail(status.toString()); } assertEquals( TestAction.class, ((ParameterizedProvisioningAction) actionsList1.get(0)).getAction().getClass()); assertEquals( TestAction.class, ((ParameterizedProvisioningAction) actionsList2.get(0)).getAction().getClass()); }
/** * Tests a JDT feature bundle container contains the appropriate bundles for a specific OS. * * @throws Exception */ public void testMacOSFeatureBundleContainer() throws Exception { // extract the feature IPath location = extractModifiedFeatures(); ITargetDefinition definition = getNewTarget(); definition.setOS(Platform.OS_MACOSX); ITargetLocation container = getTargetService().newFeatureLocation(location.toOSString(), "org.eclipse.jdt", null); container.resolve(definition, null); TargetBundle[] bundles = container.getBundles(); List expected = new ArrayList(); expected.add("org.eclipse.jdt"); expected.add("org.eclipse.jdt.launching"); // 2 versions of JUnit expected.add("org.junit"); expected.add("org.junit"); expected.add("org.junit4"); expected.add("org.eclipse.jdt.launching.macosx"); assertEquals("Wrong number of bundles in JDT feature", expected.size(), bundles.length); for (int i = 0; i < bundles.length; i++) { String symbolicName = bundles[i].getBundleInfo().getSymbolicName(); expected.remove(symbolicName); if (symbolicName.equals("org.eclipse.jdt.launching.macosx")) { // the bundle should be missing unless on Mac IStatus status = bundles[i].getStatus(); if (Platform.getOS().equals(Platform.OS_MACOSX)) { assertTrue("Mac bundle should be present", status.isOK()); } else { assertFalse("Mac bundle should be missing", status.isOK()); assertEquals( "Mac bundle should be mssing", TargetBundle.STATUS_PLUGIN_DOES_NOT_EXIST, status.getCode()); } } } Iterator iterator = expected.iterator(); while (iterator.hasNext()) { String name = (String) iterator.next(); System.err.println("Missing: " + name); } assertTrue("Wrong bundles in JDT feature", expected.isEmpty()); // should be no source bundles for (int i = 0; i < bundles.length; i++) { TargetBundle bundle = bundles[i]; assertFalse("Should be no source bundles", bundle.isSourceBundle()); } }
public void testExtractRootCauseFromNestedMultiStatus() throws Exception { MultiStatus multiStatus = new MultiStatus("id0", 0, "Message", new FileNotFoundException("FNFE")); Status status1 = new Status(IStatus.WARNING, "id1", "Test", new IOException("IO")); Status status2 = new Status(IStatus.ERROR, "id2", "Test", new IOException("IO")); Status status3 = new Status(IStatus.ERROR, "id3", "Test", null); multiStatus.add(status1); multiStatus.add(status2); multiStatus.add(status3); IStatus status = extractRootCause(multiStatus); assertNotNull(status); assertEquals("id2", status.getPlugin()); }
private void update(int i, int sleepTime) { // Now we do the job requested by the app client. // called with: record.getPosIndex() == endOfCycle // where endOfCycle = maxPosIndex for forward and 0 for reverse aRecord = dbManager.getRecord(i); // Reset the posIndex aRecord.setPosIndex(0); // depending on direction // increment the colour index aRecord.incColorIndex(); if (aRecord.getColorIndex() == aStatus.getMaxColorIndex()) { // also may depend on app // if all colours done, start again aRecord.setColorIndex(0); // if ((record).incCount|2 == 0){ // (record).setDirection(true)} // else (record).setDirection(false); } try { Thread.sleep(sleepTime); } catch (InterruptedException e) { System.out.println("Interrupted sleep"); } dbManager.setRecord(i, aRecord); System.out.println("appServer cycleEnded: " + i); }
public void testTransferError() throws Exception { File simpleRepo = getTestData("simple repository", "testData/artifactRepo/transferTestRepo"); IArtifactRepository source = null; IArtifactRepository target = null; try { source = getArtifactRepositoryManager() .loadRepository(simpleRepo.toURI(), new NullProgressMonitor()); target = createArtifactRepository(new File(getTempFolder(), getName()).toURI(), null); } catch (ProvisionException e) { fail("failing setting up the tests", e); } IArtifactDescriptor sourceDescriptor = getArtifactKeyFor( source, "osgi.bundle", "missingFromFileSystem", Version.createOSGi(1, 0, 0))[0]; SimpleArtifactDescriptor targetDescriptor = new SimpleArtifactDescriptor(sourceDescriptor); targetDescriptor.setRepositoryProperty("artifact.folder", "true"); class TestRequest extends MirrorRequest { public TestRequest( IArtifactKey key, IArtifactRepository targetRepository, Map<String, String> targetDescriptorProperties, Map<String, String> targetRepositoryProperties) { super( key, targetRepository, targetDescriptorProperties, targetRepositoryProperties, getTransport()); } public void setSource(IArtifactRepository source) { super.setSourceRepository(source); } } TestRequest request = new TestRequest( new ArtifactKey("osgi.bundle", "missingFromFileSystem", Version.createOSGi(1, 0, 0)), target, null, null); request.setSource(source); IStatus s = transferSingle(request, targetDescriptor, sourceDescriptor, new NullProgressMonitor()); assertTrue(s.toString(), s.getException().getClass() == FileNotFoundException.class); }
public ProvisioningJob getProvisioningJob(IProgressMonitor monitor) { IStatus status = getResolutionResult(); if (status.getSeverity() != IStatus.CANCEL && status.getSeverity() != IStatus.ERROR) { if (job.getProvisioningPlan() != null) { ProfileModificationJob pJob = new ProfileModificationJob( getProvisioningJobName(), session, profileId, job.getProvisioningPlan(), job.getActualProvisioningContext()); pJob.setAdditionalProgressMonitor(monitor); return pJob; } } return null; }
@Override protected IStatus performJob() { IStatus result = doClone(); if (result.isOK()) { return result; } else { try { if (project != null) GitCloneHandlerV1.removeProject(user, project); else FileUtils.delete(URIUtil.toFile(clone.getContentLocation()), FileUtils.RECURSIVE); } catch (IOException e) { String msg = "An error occured when cleaning up after a clone failure"; result = new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg, e); } return result; } }
@Override public void run() { if (status != null && !status.isOK()) { ErrorDialog.openError( Utils.getShell(null), null, TeamUIMessages.RefreshSubscriberJob_3, status); } else if (gotoAction != null) { gotoAction.run(); } }
private void createInconsistentBuildMarker(CoreException coreException) throws CoreException { String message = null; IStatus status = coreException.getStatus(); if (status.isMultiStatus()) { IStatus[] children = status.getChildren(); if (children != null && children.length > 0) message = children[0].getMessage(); } if (message == null) message = coreException.getMessage(); IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); marker.setAttributes( new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID, IMarker.SOURCE_ID }, new Object[] { Messages.bind(Messages.build_inconsistentProject, message), new Integer(IMarker.SEVERITY_ERROR), new Integer(CategorizedProblem.CAT_BUILDPATH), JavaBuilder.SOURCE_ID }); }
private IStatus initializeTouchpointParameters( IProfile profile, Operand operand, Touchpoint touchpoint, IProgressMonitor monitor) { if (touchpointToTouchpointOperandParameters.containsKey(touchpoint)) return Status.OK_STATUS; Map<String, Object> touchpointPhaseParameters = touchpointToTouchpointPhaseParameters.get(touchpoint); if (touchpointPhaseParameters == null) { touchpointPhaseParameters = new HashMap<String, Object>(phaseParameters); IStatus status = touchpoint.initializePhase(monitor, profile, phaseId, touchpointPhaseParameters); if (status != null && status.matches(IStatus.ERROR | IStatus.CANCEL)) return status; touchpointToTouchpointPhaseParameters.put(touchpoint, touchpointPhaseParameters); } Map<String, Object> touchpointOperandParameters = new HashMap<String, Object>(touchpointPhaseParameters); touchpointOperandParameters.putAll(operandParameters); IStatus status = touchpoint.initializeOperand(profile, touchpointOperandParameters); if (status != null && status.matches(IStatus.ERROR | IStatus.CANCEL)) return status; touchpointToTouchpointOperandParameters.put(touchpoint, touchpointOperandParameters); return Status.OK_STATUS; }
public boolean execute(IProgressMonitor pm, IOperationListener listener) throws CoreException { IStatus status = OperationsManager.getValidator().validatePendingConfig(feature); if (status != null && status.getCode() == IStatus.ERROR) { throw new CoreException(status); } try { targetSite.configure(feature); // ensureUnique(); // Restart not needed boolean restartNeeded = false; // Check if this operation is cancelling one that's already pending IOperation pendingOperation = OperationsManager.findPendingOperation(feature); if (pendingOperation instanceof IUnconfigFeatureOperation) { // no need to do either pending change OperationsManager.removePendingOperation(pendingOperation); } else { OperationsManager.addPendingOperation(this); } markProcessed(); if (listener != null) listener.afterExecute(this, null); restartNeeded = SiteManager.getLocalSite().save() && restartNeeded; // notify the model OperationsManager.fireObjectChanged(feature, null); return restartNeeded; } catch (CoreException e) { undo(); UpdateUtils.logException(e); throw e; } }
private static int collectErrorStatus(OutputStream stream, ArrayList<IStatus> list) { IStatus status = getStatus(stream); if (!status.isOK()) list.add(status); if (status.matches(IStatus.ERROR)) // Errors past this should be bogus as they rely on output from this step return status.getSeverity(); OutputStream destination = getDestination(stream); if (destination == null || !(destination instanceof IStateful)) return status.getSeverity(); int result = collectErrorStatus(destination, list); // TODO greater than test here is a little brittle but it is very unlikely that we will add // a new status severity. return status.getSeverity() > result ? status.getSeverity() : result; }
/** Sends given response to the socket. */ protected void send(OutputStream outputStream) { String mime = mimeType; SimpleDateFormat gmtFrmt = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss 'GMT'", Locale.US); gmtFrmt.setTimeZone(TimeZone.getTimeZone("GMT")); try { if (status == null) { throw new Error("sendResponse(): Status can't be null."); } PrintWriter pw = new PrintWriter(outputStream); pw.print("HTTP/1.1 " + status.getDescription() + " \r\n"); if (mime != null) { pw.print("Content-Type: " + mime + "\r\n"); } if (header == null || header.get("Date") == null) { pw.print("Date: " + gmtFrmt.format(new Date()) + "\r\n"); } if (header != null) { for (String key : header.keySet()) { String value = header.get(key); pw.print(key + ": " + value + "\r\n"); } } sendConnectionHeaderIfNotAlreadyPresent(pw, header); if (requestMethod != Method.HEAD && chunkedTransfer) { sendAsChunked(outputStream, pw); } else { int pending = data != null ? data.available() : 0; sendContentLengthHeaderIfNotAlreadyPresent(pw, header, pending); pw.print("\r\n"); pw.flush(); sendAsFixedLength(outputStream, pending); } outputStream.flush(); safeClose(data); } catch (IOException ioe) { // Couldn't write? No can do. } }
/** * Add this exception to the collector. If a log was specified in the constructor then the * exception will be output to the log. You can retreive exceptions using <code>getStatus</code>. * * @param exception the exception to collect */ public void handleException(CoreException exception) { // log the exception if we have a log if (log != null) { log.log(new Status(severity, pluginId, 0, message, exception)); } // Record each status individually to flatten the resulting multi-status IStatus exceptionStatus = exception.getStatus(); // Wrap the exception so the stack trace is not lost. IStatus status = new Status( exceptionStatus.getSeverity(), exceptionStatus.getPlugin(), exceptionStatus.getCode(), exceptionStatus.getMessage(), exception); recordStatus(status); IStatus[] children = status.getChildren(); for (int i = 0; i < children.length; i++) { IStatus status2 = children[i]; recordStatus(status2); } }
public IStatus getStartupStatus(int i) { IStatus status = new Status(); status = dbManager.getStatus(i); System.out.println("appServer getStartupStatus: " + status.getId()); return status; }
public void makeSetup(int i) { // make aStatus aStatus.makeStatus(i, sysMode); // make runningRecord aRecord.setRecord(i); }
/** * Returns the cause of this exception, or <code>null</code> if none. * * @return the cause for this exception */ public Throwable getCause() { return status.getException(); }
/* (non-Javadoc) * @see org.eclipse.core.runtime.ProgressMonitorWrapper#setBlocked(org.eclipse.core.runtime.IStatus) */ public void setBlocked(IStatus reason) { subTask(reason.getMessage()); }
/** * This is run by the job scheduler. A list of subscribers will be refreshed, errors will not stop * the job and it will continue to refresh the other subscribers. */ @Override public IStatus run(IProgressMonitor monitor) { // Perform a pre-check for auto-build or manual build jobs // when auto-refreshing if (shouldReschedule() && (isJobInFamilyRunning(ResourcesPlugin.FAMILY_AUTO_BUILD) || isJobInFamilyRunning(ResourcesPlugin.FAMILY_MANUAL_BUILD))) { return POSTPONED; } // Only allow one refresh job at a time // NOTE: It would be cleaner if this was done by a scheduling // rule but at the time of writing, it is not possible due to // the scheduling rule containment rules. // Acquiring lock to ensure only one refresh job is running at a particular time boolean acquired = false; try { while (!acquired) { try { acquired = lock.acquire(1000); } catch (InterruptedException e1) { acquired = false; } Policy.checkCanceled(monitor); } IChangeDescription changeDescription = createChangeDescription(); RefreshEvent event = new RefreshEvent( reschedule ? IRefreshEvent.SCHEDULED_REFRESH : IRefreshEvent.USER_REFRESH, participant, changeDescription); IStatus status = null; NonblockingProgressMonitor wrappedMonitor = null; try { event.setStartTime(System.currentTimeMillis()); if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } // Pre-Notify notifyListeners(STARTED, event); // Perform the refresh monitor.setTaskName(getName()); wrappedMonitor = new NonblockingProgressMonitor(monitor, this); doRefresh(changeDescription, wrappedMonitor); // Prepare the results setProperty(IProgressConstants.KEEPONE_PROPERTY, Boolean.valueOf(!isJobModal())); } catch (OperationCanceledException e2) { if (monitor.isCanceled()) { // The refresh was canceled by the user status = Status.CANCEL_STATUS; } else { // The refresh was canceled due to a blockage or a canceled authentication if (wrappedMonitor != null && wrappedMonitor.wasBlocking()) { status = POSTPONED; } else { status = Status.CANCEL_STATUS; } } } catch (CoreException e) { // Determine the status to be returned and the GOTO action status = e.getStatus(); if (!isUser()) { // Use the GOTO action to show the error and return OK Object prop = getProperty(IProgressConstants.ACTION_PROPERTY); if (prop instanceof GotoActionWrapper) { GotoActionWrapper wrapper = (GotoActionWrapper) prop; wrapper.setStatus(e.getStatus()); status = new Status(IStatus.OK, TeamUIPlugin.ID, IStatus.OK, e.getStatus().getMessage(), e); } } if (!isUser() && status.getSeverity() == IStatus.ERROR) { // Never prompt for errors on non-user jobs setProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY, Boolean.TRUE); } } finally { event.setStopTime(System.currentTimeMillis()); } // Post-Notify if (status == null) { status = calculateStatus(event); } event.setStatus(status); notifyListeners(DONE, event); if (event.getChangeDescription().getChangeCount() > 0) { if (participant instanceof AbstractSynchronizeParticipant) { AbstractSynchronizeParticipant asp = (AbstractSynchronizeParticipant) participant; asp.firePropertyChange( participant, ISynchronizeParticipant.P_CONTENT, null, event.getChangeDescription()); } } return event.getStatus(); } finally { if (acquired) lock.release(); monitor.done(); } }
private void mainPerform( MultiStatus status, EngineSession session, Operand[] operands, SubMonitor subMonitor) { IProfile profile = session.getProfile(); subMonitor.beginTask(null, operands.length); for (int i = 0; i < operands.length; i++) { subMonitor.setWorkRemaining(operands.length - i); if (subMonitor.isCanceled()) throw new OperationCanceledException(); Operand operand = operands[i]; if (!isApplicable(operand)) continue; session.recordOperandStart(operand); List<ProvisioningAction> actions = getActions(operand); operandParameters = new HashMap<String, Object>(phaseParameters); operandParameters.put(PARM_OPERAND, operand); mergeStatus(status, initializeOperand(profile, operand, operandParameters, subMonitor)); if (status.matches(IStatus.ERROR | IStatus.CANCEL)) { operandParameters = null; return; } Touchpoint operandTouchpoint = (Touchpoint) operandParameters.get(PARM_TOUCHPOINT); if (operandTouchpoint != null) { mergeStatus( status, initializeTouchpointParameters(profile, operand, operandTouchpoint, subMonitor)); if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return; operandParameters = touchpointToTouchpointOperandParameters.get(operandTouchpoint); } operandParameters = Collections.unmodifiableMap(operandParameters); if (actions != null) { for (int j = 0; j < actions.size(); j++) { ProvisioningAction action = actions.get(j); Map<String, Object> parameters = operandParameters; Touchpoint touchpoint = action.getTouchpoint(); if (touchpoint != null) { mergeStatus( status, initializeTouchpointParameters(profile, operand, touchpoint, subMonitor)); if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return; parameters = touchpointToTouchpointOperandParameters.get(touchpoint); } IStatus actionStatus = null; try { session.recordActionExecute(action, parameters); actionStatus = action.execute(parameters); } catch (RuntimeException e) { if (!forced) throw e; // "action.execute" calls user code and might throw an unchecked exception // we catch the error here to gather information on where the problem occurred. actionStatus = new Status( IStatus.ERROR, EngineActivator.ID, NLS.bind(Messages.forced_action_execute_error, action.getClass().getName()), e); } catch (LinkageError e) { if (!forced) throw e; // Catch linkage errors as these are generally recoverable but let other Errors // propagate (see bug 222001) actionStatus = new Status( IStatus.ERROR, EngineActivator.ID, NLS.bind(Messages.forced_action_execute_error, action.getClass().getName()), e); } if (forced && actionStatus != null && actionStatus.matches(IStatus.ERROR)) { MultiStatus result = new MultiStatus(EngineActivator.ID, IStatus.ERROR, getProblemMessage(), null); result.add( new Status( IStatus.ERROR, EngineActivator.ID, session.getContextString(this, operand, action), null)); LogHelper.log(result); actionStatus = Status.OK_STATUS; } mergeStatus(status, actionStatus); if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return; } } mergeStatus( status, touchpointCompleteOperand(profile, operand, operandParameters, subMonitor)); mergeStatus(status, completeOperand(profile, operand, operandParameters, subMonitor)); if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return; operandParameters = null; session.recordOperandEnd(operand); subMonitor.worked(1); } }
public boolean performFinish() { if (currentFragment != null) currentFragment.exit(); final WizardFragment cFragment = currentFragment; status = Status.OK_STATUS; final List<WizardFragment> list = getAllWizardFragments(); IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { // enter & exit the remaining pages int index = list.indexOf(cFragment); while (index > 0 && index < list.size() - 1) { final WizardFragment fragment = (WizardFragment) list.get(++index); try { Display.getDefault() .syncExec( new Runnable() { public void run() { FragmentedWizardPage page = getFragmentData(fragment); if (page.getControl() == null && pageContainerHook != null) { page.createControl(pageContainerHook); } fragment.enter(); fragment.exit(); } }); } catch (Exception e) { PHPUiPlugin.log( new Status( IStatus.ERROR, PHPUiPlugin.ID, 0, "Could not enter/exit page", e)); //$NON-NLS-1$ } } if (useJob()) { class FinishWizardJob extends Job { public FinishWizardJob() { super(getJobTitle()); } public boolean belongsTo(Object family) { return "org.eclipse.wst.server.ui.family".equals(family); // $NON-NLS-1$ } public IStatus run(IProgressMonitor monitor2) { try { Iterator<WizardFragment> iterator = list.iterator(); while (iterator.hasNext()) executeTask(iterator.next(), FINISH, monitor2); } catch (CoreException ce) { Status status = new Status( IStatus.ERROR, PHPUiPlugin.ID, 0, ce.getLocalizedMessage(), null); PHPUiPlugin.log(status); return status; } return Status.OK_STATUS; } } FinishWizardJob job = new FinishWizardJob(); job.setUser(true); job.schedule(); } else { Iterator<WizardFragment> iterator = list.iterator(); while (iterator.hasNext()) try { WizardFragment fragment = (WizardFragment) iterator.next(); if (!executeTask(fragment, FINISH, monitor)) { status = new Status( IStatus.ERROR, PHPUiPlugin.ID, "Error during wizard page execution."); //$NON-NLS-1$ } } catch (CoreException e) { PHPUiPlugin.log(e); } } } }; Throwable t = null; try { if (getContainer() != null) getContainer().run(true, true, runnable); else runnable.run(new NullProgressMonitor()); if (status.getSeverity() != IStatus.OK) { return false; } return true; } catch (InvocationTargetException te) { PHPUiPlugin.log( new Status( IStatus.ERROR, PHPUiPlugin.ID, 0, "Error finishing task wizard", te)); // $NON-NLS-1$ t = te.getCause(); } catch (Exception e) { PHPUiPlugin.log( new Status( IStatus.ERROR, PHPUiPlugin.ID, 0, "Error finishing task wizard 2", e)); // $NON-NLS-1$ t = e; } if (t instanceof CoreException) { openError(t.getLocalizedMessage(), ((CoreException) t).getStatus()); } else if (t instanceof NullPointerException) openError(PHPUIMessages.FragmentedWizard_7); else openError(t.getLocalizedMessage()); return false; }
/** * Creates a new exception with the given status object. The message of the given status is used * as the exception message. * * @param status the status object to be associated with this exception */ public CoreException(IStatus status) { super(status.getMessage()); this.status = status; }
/** Merges a given IStatus into a MultiStatus */ protected static void mergeStatus(MultiStatus multi, IStatus status) { if (status != null && !status.isOK()) multi.merge(status); }
void undo( MultiStatus status, EngineSession session, IProfile profile, Operand operand, ProvisioningAction[] actions, ProvisioningContext context) { if (operandParameters == null) { operandParameters = new HashMap<String, Object>(phaseParameters); operandParameters.put(PARM_OPERAND, operand); mergeStatus( status, initializeOperand(profile, operand, operandParameters, new NullProgressMonitor())); Touchpoint operandTouchpoint = (Touchpoint) operandParameters.get(PARM_TOUCHPOINT); if (operandTouchpoint != null) { mergeStatus( status, initializeTouchpointParameters( profile, operand, operandTouchpoint, new NullProgressMonitor())); if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return; operandParameters = touchpointToTouchpointOperandParameters.get(operandTouchpoint); } operandParameters = Collections.unmodifiableMap(operandParameters); } for (int j = 0; j < actions.length; j++) { ProvisioningAction action = actions[j]; Map<String, Object> parameters = operandParameters; Touchpoint touchpoint = action.getTouchpoint(); if (touchpoint != null) { mergeStatus( status, initializeTouchpointParameters( profile, operand, touchpoint, new NullProgressMonitor())); if (status.matches(IStatus.ERROR)) return; parameters = touchpointToTouchpointOperandParameters.get(touchpoint); } IStatus actionStatus = null; try { session.recordActionUndo(action, parameters); actionStatus = action.undo(parameters); } catch (RuntimeException e) { // "action.undo" calls user code and might throw an unchecked exception // we catch the error here to gather information on where the problem occurred. actionStatus = new Status( IStatus.ERROR, EngineActivator.ID, NLS.bind(Messages.action_undo_error, action.getClass().getName()), e); } catch (LinkageError e) { // Catch linkage errors as these are generally recoverable but let other Errors propagate // (see bug 222001) actionStatus = new Status( IStatus.ERROR, EngineActivator.ID, NLS.bind(Messages.action_undo_error, action.getClass().getName()), e); } if (actionStatus != null && actionStatus.matches(IStatus.ERROR)) { MultiStatus result = new MultiStatus(EngineActivator.ID, IStatus.ERROR, getProblemMessage(), null); result.add( new Status( IStatus.ERROR, EngineActivator.ID, session.getContextString(this, operand, action), null)); result.merge(actionStatus); } } mergeStatus( status, touchpointCompleteOperand(profile, operand, operandParameters, new NullProgressMonitor())); mergeStatus( status, completeOperand(profile, operand, operandParameters, new NullProgressMonitor())); operandParameters = null; }
public void update(Observable o, Object arg) { final IWorkspace workspace = DLTKUIPlugin.getWorkspace(); final String name = fNameGroup.getName(); // check whether the project name field is empty if (name.length() == 0) { setErrorMessage(null); setMessage(NewWizardMessages.ScriptProjectWizardFirstPage_Message_enterProjectName); setPageComplete(false); return; } // check whether the project name is valid final IStatus nameStatus = workspace.validateName(name, IResource.PROJECT); if (!nameStatus.isOK()) { setErrorMessage(nameStatus.getMessage()); setPageComplete(false); return; } // check whether project already exists final IProject handle = getProjectHandle(); if (!isInLocalServer()) { if (handle.exists()) { setErrorMessage( NewWizardMessages.ScriptProjectWizardFirstPage_Message_projectAlreadyExists); setPageComplete(false); return; } } IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); String newProjectNameLowerCase = name.toLowerCase(); for (IProject currentProject : projects) { String existingProjectName = currentProject.getName(); if (existingProjectName.toLowerCase().equals(newProjectNameLowerCase)) { setErrorMessage( NewWizardMessages.ScriptProjectWizardFirstPage_Message_projectAlreadyExists); setPageComplete(false); return; } } final String location = fPHPLocationGroup.getLocation().toOSString(); // check whether location is empty if (location.length() == 0) { setErrorMessage(null); setMessage(NewWizardMessages.ScriptProjectWizardFirstPage_Message_enterLocation); setPageComplete(false); return; } // check whether the location is a syntactically correct path if (!Path.EMPTY.isValidPath(location)) { setErrorMessage(NewWizardMessages.ScriptProjectWizardFirstPage_Message_invalidDirectory); setPageComplete(false); return; } // check whether the location has the workspace as prefix IPath projectPath = Path.fromOSString(location); if (!fPHPLocationGroup.isInWorkspace() && Platform.getLocation().isPrefixOf(projectPath)) { setErrorMessage( NewWizardMessages.ScriptProjectWizardFirstPage_Message_cannotCreateInWorkspace); setPageComplete(false); return; } // If we do not place the contents in the workspace validate the // location. if (!fPHPLocationGroup.isInWorkspace()) { IEnvironment environment = getEnvironment(); if (EnvironmentManager.isLocal(environment)) { final IStatus locationStatus = workspace.validateProjectLocation(handle, projectPath); File file = projectPath.toFile(); if (!locationStatus.isOK()) { setErrorMessage(locationStatus.getMessage()); setPageComplete(false); return; } if (!canCreate(projectPath.toFile())) { setErrorMessage( NewWizardMessages.ScriptProjectWizardFirstPage_Message_invalidDirectory); setPageComplete(false); return; } } } if (fragment != null) { fragment.getWizardModel().putObject("ProjectName", fNameGroup.getName()); if (!fragment.isComplete()) { setErrorMessage((String) fragment.getWizardModel().getObject(ERROR_MESSAGE)); setPageComplete(false); return; } } setPageComplete(true); setErrorMessage(null); setMessage(null); }