List of usage examples for java.lang.reflect InvocationTargetException InvocationTargetException
public InvocationTargetException(Throwable target)
From source file:com.headwire.aem.tooling.intellij.communication.ImportRepositoryContentManager.java
public void doImport(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException, SerializationException, CoreException { // // TODO: We should try to make this give 'nice' progress feedback (aka here's what I'm processing) // monitor.beginTask("Repository import", IProgressMonitor.UNKNOWN); // this.monitor = monitor; MessageManager messageManager = project.getModule().getProject().getComponent(MessageManager.class); repository = ServerUtil.getConnectedRepository(server, monitor, messageManager); if (repository != null) { File syncDirectory = ProjectUtil.getSyncDirectoryFile(project); this.builder = serializationManager.newBuilder(repository, syncDirectory); SerializationKindManager skm;/*from w w w .j a v a 2 s . c om*/ try { skm = new SerializationKindManager(); skm.init(repository); } catch (RepositoryException e1) { throw new InvocationTargetException(e1); } filter = ProjectUtil.loadFilter(project); // ProgressUtils.advance(monitor, 1); try { contentSyncRootDir = ProjectUtil.getSyncDirectory(project); //AS TODO: The Repository Import Root needs to be a path that points from the /jcr_root to the folder where the import started with. // repositoryImportRoot = projectRelativePath // .makeRelativeTo(contentSyncRootDir.getProjectRelativePath()) // .makeAbsolute(); contentSyncRoot = ProjectUtil.getSyncDirectoryFullPath(project).toFile(); String relativeFromSyncRoot = projectRelativePath.toOSString(); int index = relativeFromSyncRoot.indexOf("/" + JCR_ROOT_FOLDER_NAME + "/"); relativeFromSyncRoot = relativeFromSyncRoot .substring(index + ("/" + JCR_ROOT_FOLDER_NAME + "/").length()); repositoryImportRoot = new IPath(new IPath(contentSyncRoot), relativeFromSyncRoot); readVltIgnoresNotUnderImportRoot(contentSyncRootDir, repositoryImportRoot); // ProgressUtils.advance(monitor, 1); Activator.getDefault().getPluginLogger().trace( "Starting import; repository start point is {0}, workspace start point is {1}", repositoryImportRoot, projectRelativePath); recordNotIgnoredResources(); // ProgressUtils.advance(monitor, 1); String contentPath = repositoryImportRoot.toPortableString(); if (!contentPath.startsWith("/")) { contentPath = "/" + contentPath; } crawlChildrenAndImport(contentPath); removeNotIgnoredAndNotUpdatedResources(new NullProgressMonitor()); // ProgressUtils.advance(monitor, 1); // } catch (OperationCanceledException e) { // throw e; } catch (Exception e) { throw new InvocationTargetException(e); } finally { if (builder != null) { builder.destroy(); builder = null; } monitor.done(); } } }
From source file:es.bsc.servicess.ide.editors.deployers.GridDeployer.java
@Override public void deploy() { final Element master = resGRFile.getMasterResource(); if (master != null) { final Element[] workers = resGRFile.getWorkerResources(); if (workers != null && workers.length > 0) { ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try { dialog.run(false, false, new IRunnableWithProgress() { @Override//from ww w . j a v a 2 s.c o m public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { executeDeployment(master, workers, monitor); } catch (Exception e) { throw (new InvocationTargetException(e)); } } }); } catch (InterruptedException e) { String message = e.getMessage(); System.err.println("Error message: " + message); ErrorDialog.openError(super.getShell(), "Error", "Deploying the service", new StatusInfo(IStatus.ERROR, message)); e.printStackTrace(); } catch (InvocationTargetException e) { String message = e.getMessage(); System.err.println("Error message: " + message); ErrorDialog.openError(super.getShell(), "Error", "Deploying the service", new StatusInfo(IStatus.ERROR, message)); e.printStackTrace(); } } else { ErrorDialog.openError(super.getShell(), "Error", "Deploying the service", new StatusInfo(IStatus.ERROR, "Worker resources not defined")); } } else { ErrorDialog.openError(super.getShell(), "Error", "Deploying the service", new StatusInfo(IStatus.ERROR, "Master resource not defined")); } }
From source file:es.bsc.servicess.ide.PackagingUtils.java
/** Build Service Packages. * //from w w w . ja v a 2s . c o m * @param project Java Project where the service is built * @param pr_meta Project Metadata where the project is described * @param monitor Eclipse progress monitor * @throws Exception */ public static void buildPackages(IJavaProject project, ProjectMetadata pr_meta, IProgressMonitor monitor) throws Exception { monitor.beginTask("Building project classes...", 100); IFolder output = project.getProject().getFolder(ProjectMetadata.OUTPUT_FOLDER); if (output == null || !output.exists()) { output.create(true, true, monitor); } project.getProject().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); monitor.done(); monitor.beginTask("Creating packages...", 2); // Create folders to store packages IFolder packagesFolder = output.getFolder(ProjectMetadata.PACKAGES_FOLDER); if (packagesFolder != null && packagesFolder.exists()) { log.debug("Deleting current packages folder"); packagesFolder.delete(true, monitor); } log.debug("Creating packages folder"); packagesFolder.create(true, true, monitor); IFolder srcFolder = project.getProject().getFolder(pr_meta.getSourceDir()); //Get parameters to perform the package creation //String[] packs = pr_meta.getPackages(); String runtime = pr_meta.getRuntimeLocation(); //TODO Chak if should be all orchestration or only internal String[] orchClasses = pr_meta.getAllOrchestrationClasses(); String[] extOrchClasses = pr_meta.getExternalOrchestrationClasses(); IPackageFragmentRoot source = project.findPackageFragmentRoot(srcFolder.getFullPath()); IPackageFragmentRoot generated = project.findPackageFragmentRoot( project.getProject().getFolder(ProjectMetadata.GENERATED_FOLDER).getFullPath()); if (source != null && source.exists()) { HashMap<String, ServiceElement> constraintsElements = CommonFormPage.getElements(orchClasses, ProjectMetadata.CORE_TYPE, project, pr_meta); //Create Core Element packages String[] corePacks = pr_meta.getPackagesWithCores(); if (corePacks != null && corePacks.length > 0) { log.debug("Creating core elements packages"); monitor.subTask("Create Core Element packages"); monitor.beginTask("Creating packages...", corePacks.length); for (String p : corePacks) { String[] elements = pr_meta.getElementsInPackage(p); if (elements != null && elements.length > 0) { PackagingUtils.createCorePackage(runtime, p, elements, pr_meta.getDependencies(elements), constraintsElements, source, output, packagesFolder, monitor); } monitor.worked(1); } monitor.done(); } else { log.warn("Warning: No core packages built"); monitor.setCanceled(true); throw (new InvocationTargetException(new Exception("No packages built"))); } if (orchClasses != null && orchClasses.length > 0) { String[] orchPacks = pr_meta.getPackagesWithOrchestration(); if (orchPacks != null && orchPacks.length > 0) { log.debug("Creating orchestration elements packages"); for (String p : orchPacks) { String[] allElements = pr_meta.getElementsInPackage(p); Map<String, List<String>> extElements = pr_meta .getOrchestrationClassesAndElements(allElements, true); Map<String, List<String>> intElements = pr_meta .getOrchestrationClassesAndElements(allElements, false); if (intElements != null && intElements.size() > 0) { PackagingUtils.createInternalOrchestrationPackage(runtime, PackagingUtils.getClasspath(project), p, intElements, pr_meta.getDependencies(intElements), source, generated, output, packagesFolder, monitor, pr_meta.shouldBeWarFile(p)); monitor.done(); } if (extElements != null && extElements.size() > 0) { PackagingUtils.createExternalOrchestrationPackage(runtime, PackagingUtils.getClasspath(project), p, extElements, source, generated, output, packagesFolder, monitor, pr_meta); monitor.done(); } } } else { log.debug("Creating all orchestration element package"); // Create All Orchestration packages (front-end) String[] allElements = CommonFormPage.getOrchestrationElementsLabels(orchClasses, project, pr_meta); Map<String, List<String>> extElements = pr_meta.getOrchestrationClassesAndElements(allElements, true); Map<String, List<String>> intElements = pr_meta.getOrchestrationClassesAndElements(allElements, false); if (intElements != null && intElements.size() > 0) { PackagingUtils.createInternalOrchestrationPackage(runtime, PackagingUtils.getClasspath(project), project.getProject().getName(), intElements, pr_meta.getDependencies(intElements), source, generated, output, packagesFolder, monitor, ProjectMetadata.shouldBeWarFile(pr_meta.getOrchestrationClassesTypes())); monitor.done(); } if (extElements != null && extElements.size() > 0) { PackagingUtils.createExternalOrchestrationPackage(runtime, PackagingUtils.getClasspath(project), project.getProject().getName(), extElements, source, generated, output, packagesFolder, monitor, pr_meta); monitor.done(); } } } else { log.warn("Warning: No orchestration element packages built"); monitor.setCanceled(true); throw (new InvocationTargetException(new Exception("No orchestration packages built"))); } } else { log.error("Source dir not found"); monitor.setCanceled(true); throw (new InvocationTargetException( new Exception("Source dir " + srcFolder.getFullPath() + " not found"))); } }
From source file:com.jaspersoft.studio.server.action.resource.PasteResourceAction.java
@Override public void run() { final ANode parent = getSelected(); final List<?> list = (List<?>) Clipboard.getDefault().getContents(); if (list == null) return;//from www .ja va2 s .c o m ProgressMonitorDialog pm = new ProgressMonitorDialog(UIUtils.getShell()); try { pm.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { INode root = parent.getRoot(); final String puri = parent instanceof MResource ? ((MResource) parent).getValue().getUriString() : ""; //$NON-NLS-1$ doWork(monitor, parent, list); ANode p = parent; if (parent instanceof MResource) p = new ModelVisitor<ANode>(root) { @Override public boolean visit(INode n) { if (n instanceof MResource) { MResource mres = (MResource) n; if (mres.getValue() != null && mres.getValue().getUriString().equals(puri)) { setObject(mres); stop(); } } return true; } }.getObject(); if (!p.getChildren().isEmpty()) p = (ANode) p.getChildren().get(0); s = new TreeSelection(new TreePath(new Object[] { p })); UIUtils.getDisplay().asyncExec(new Runnable() { public void run() { treeViewer.refresh(true); treeViewer.setSelection(s); } }); } catch (Throwable e) { throw new InvocationTargetException(e); } finally { monitor.done(); } } }); } catch (InvocationTargetException e) { UIUtils.showError(e.getCause()); } catch (InterruptedException e) { UIUtils.showError(e); } }
From source file:net.geoprism.data.importer.ShapefileImporter.java
/** * Imports the entities from the shapefile * //from ww w .ja v a 2 s . c om * @param writer * Log file writer * @throws InvocationTargetException */ @Transaction private void createFeatures(URL url) throws InvocationTargetException { try { ShapefileDataStore store = new ShapefileDataStore(url); try { String[] typeNames = store.getTypeNames(); for (String typeName : typeNames) { FeatureSource<SimpleFeatureType, SimpleFeature> source = store.getFeatureSource(typeName); SimpleFeatureType schema = source.getSchema(); List<AttributeDescriptor> descriptors = schema.getAttributeDescriptors(); /* * Iterate over the features */ FeatureCollection<SimpleFeatureType, SimpleFeature> features = source.getFeatures(); FeatureIterator<SimpleFeature> iterator = features.features(); try { while (iterator.hasNext()) { SimpleFeature feature = iterator.next(); this.createFeature(descriptors, feature); } } finally { iterator.close(); } } } finally { store.dispose(); } } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new InvocationTargetException(e); } }
From source file:de.jcup.egradle.eclipse.ide.execution.GradleExecutionDelegate.java
/** * Execute and give output by given progress monitor * /*from w w w. j a v a2 s .c o m*/ * @param monitor * - progress monitor * @throws Exception */ public void execute(IProgressMonitor monitor) throws Exception { processExecutionResult = new ProcessExecutionResult(); try { GradleRootProject rootProject = context.getRootProject(); String commandString = context.getCommandString(); String progressDescription = "Executing gradle commands:" + commandString + " in " + context.getRootProject().getFolder().getAbsolutePath(); File folder = rootProject.getFolder(); String rootProjectFolderName = folder.getName(); String executionStartTime = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT) .format(new Date()); monitor.beginTask(progressDescription, context.getAmountOfWorkToDo()); if (monitor.isCanceled()) { return; } beforeExecutionDone(monitor); if (monitor.isCanceled()) { return; } outputHandler.output("\n" + executionStartTime + " " + progressDescription); outputHandler.output("Root project '" + rootProjectFolderName + "' executing " + commandString); if (monitor.isCanceled()) { outputHandler.output("[CANCELED]"); processExecutionResult.setCanceledByuser(true); return; } ProgressMonitorCancelStateProvider cancelStateProvider = new ProgressMonitorCancelStateProvider( monitor); context.register(cancelStateProvider); processExecutionResult = executor.execute(context); if (processExecutionResult.isOkay()) { outputHandler.output("[OK]"); } else { outputHandler.output("[FAILED]"); } afterExecutionDone(monitor); } catch (Exception e) { throw new InvocationTargetException(e); } finally { monitor.done(); } }
From source file:net.rim.ejde.internal.ui.wizards.BasicBlackBerryProjectWizardPageTwo.java
private IStatus changeToNewProject() { class UpdateRunnable implements IRunnableWithProgress { public IStatus infoStatus = Status.OK_STATUS; public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { if (fIsAutobuild == null) { fIsAutobuild = Boolean.valueOf(CoreUtility.setAutoBuilding(false)); }//w w w . jav a 2s. co m infoStatus = updateProject(monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } catch (OperationCanceledException e) { throw new InterruptedException(); } finally { monitor.done(); } } } UpdateRunnable op = new UpdateRunnable(); try { getContainer().run(true, false, new WorkspaceModifyDelegatingOperation(op)); return op.infoStatus; } catch (InvocationTargetException e) { final String title = Messages.NewBlackBerryProjectWizardPageTwo_error_title; final String message = Messages.NewBlackBerryProjectWizardPageTwo_error_message; ExceptionHandler.handle(e, getShell(), title, message); } catch (InterruptedException e) { // cancel pressed } return null; }
From source file:de.blizzy.backup.check.CheckRun.java
@Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { database = new Database(settings, false); final boolean[] ok = { true }; List<StorageInterceptorDescriptor> descs = BackupPlugin.getDefault().getStorageInterceptors(); for (final StorageInterceptorDescriptor desc : descs) { final IStorageInterceptor interceptor = desc.getStorageInterceptor(); SafeRunner.run(new ISafeRunnable() { @Override// w w w .java 2s. com public void run() { IDialogSettings settings = Utils.getChildSection(Utils.getSection("storageInterceptors"), //$NON-NLS-1$ desc.getId()); if (!interceptor.initialize(parentShell, settings)) { ok[0] = false; } } @Override public void handleException(Throwable t) { ok[0] = false; interceptor.showErrorMessage(t, parentShell); BackupPlugin.getDefault() .logError("error while initializing storage interceptor '" + desc.getName() + "'", t); //$NON-NLS-1$ //$NON-NLS-2$ } }); storageInterceptors.add(interceptor); } if (!ok[0]) { monitor.done(); throw new InterruptedException(); } try { database.open(storageInterceptors); database.initialize(); int numFiles = database.factory().select(Factory.count()).from(Tables.FILES).fetchOne(Factory.count()) .intValue(); monitor.beginTask(Messages.Title_CheckBackupIntegrity, numFiles); Cursor<Record> cursor = null; try { cursor = database.factory().select(Tables.FILES.ID, Tables.FILES.BACKUP_PATH, Tables.FILES.CHECKSUM, Tables.FILES.LENGTH, Tables.FILES.COMPRESSION).from(Tables.FILES).fetchLazy(); while (cursor.hasNext()) { if (monitor.isCanceled()) { throw new InterruptedException(); } Record record = cursor.fetchOne(); String backupPath = record.getValue(Tables.FILES.BACKUP_PATH); String checksum = record.getValue(Tables.FILES.CHECKSUM); long length = record.getValue(Tables.FILES.LENGTH).longValue(); Compression compression = Compression .fromValue(record.getValue(Tables.FILES.COMPRESSION).intValue()); FileCheckResult checkResult = checkFile(backupPath, checksum, length, compression); if (!checkResult.ok) { backupOk = false; break; } if (checksum.length() != SHA256_LENGTH) { Integer id = record.getValue(Tables.FILES.ID); database.factory().update(Tables.FILES) .set(Tables.FILES.CHECKSUM, checkResult.checksumSHA256) .where(Tables.FILES.ID.equal(id)).execute(); } monitor.worked(1); } } finally { database.closeQuietly(cursor); } } catch (SQLException | IOException e) { boolean handled = false; for (IStorageInterceptor interceptor : storageInterceptors) { if (interceptor.showErrorMessage(e, parentShell)) { handled = true; } } if (handled) { throw new InterruptedException(); } throw new InvocationTargetException(e); } finally { database.close(); for (final IStorageInterceptor interceptor : storageInterceptors) { SafeRunner.run(new ISafeRunnable() { @Override public void run() { interceptor.destroy(); } @Override public void handleException(Throwable t) { BackupPlugin.getDefault().logError("error while destroying storage interceptor", t); //$NON-NLS-1$ } }); } System.gc(); monitor.done(); } }
From source file:de.blizzy.backup.restore.RestoreDialog.java
@Override public int open() { final ProgressMonitorDialog dlg = new ProgressMonitorDialog(getParentShell()); IRunnableWithProgress runnable = new IRunnableWithProgress() { @Override// w ww .j a v a 2 s.com public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(Messages.Title_OpenBackupDatabase, IProgressMonitor.UNKNOWN); final boolean[] ok = { true }; List<StorageInterceptorDescriptor> descs = BackupPlugin.getDefault().getStorageInterceptors(); for (final StorageInterceptorDescriptor desc : descs) { final IStorageInterceptor interceptor = desc.getStorageInterceptor(); SafeRunner.run(new ISafeRunnable() { @Override public void run() { IDialogSettings settings = Utils .getChildSection(Utils.getSection("storageInterceptors"), desc.getId()); //$NON-NLS-1$ if (!interceptor.initialize(dlg.getShell(), settings)) { ok[0] = false; } } @Override public void handleException(Throwable t) { ok[0] = false; interceptor.showErrorMessage(t, dlg.getShell()); BackupPlugin.getDefault().logError( "error while initializing storage interceptor '" + desc.getName() + "'", t); //$NON-NLS-1$ //$NON-NLS-2$ } }); storageInterceptors.add(interceptor); } if (!ok[0]) { monitor.done(); throw new InterruptedException(); } Cursor<BackupsRecord> cursor = null; try { database.open(storageInterceptors); database.initialize(); cursor = database.factory().selectFrom(Tables.BACKUPS) .where(Tables.BACKUPS.NUM_ENTRIES.isNotNull()).orderBy(Tables.BACKUPS.RUN_TIME.desc()) .fetchLazy(); while (cursor.hasNext()) { BackupsRecord record = cursor.fetchOne(); Backup backup = new Backup(record.getId().intValue(), new Date(record.getRunTime().getTime()), record.getNumEntries().intValue()); backups.add(backup); } } catch (SQLException | IOException e) { boolean handled = false; for (IStorageInterceptor interceptor : storageInterceptors) { if (interceptor.showErrorMessage(e, dlg.getShell())) { handled = true; } } if (handled) { throw new InterruptedException(); } throw new InvocationTargetException(e); } finally { database.closeQuietly(cursor); monitor.done(); } } }; try { dlg.run(true, false, runnable); } catch (InvocationTargetException e) { // TODO BackupPlugin.getDefault().logError("Error while opening backup database", e); //$NON-NLS-1$ } catch (InterruptedException e) { return Window.CANCEL; } return super.open(); }
From source file:com.autobizlogic.abl.rule.ConstraintRule.java
/** * Execute the expression defined in the annotation. * @param aLogicObject The logic object for the bean * @param bean The bean itself//from w ww .ja v a 2 s . co m * @param skipMethodIfPossible If true, and the constraint is an expression, do not execute the method. * @throws InvocationTargetException If the expression did not evaluate successfully */ private void executeDeclaredConstraint(Object aLogicObject, PersistentBean bean, boolean skipMethodIfPossible, LogicContext logicContext) throws InvocationTargetException { Object result = evaluateExpression(bean, logicContext); if (result == null) throw new RuntimeException( "Constraint " + this.getLogicGroup().getLogicClassName() + "." + this.getLogicMethodName() + " evaluated to null. A constraint must evaluate to true or false."); if (!(result instanceof Boolean)) throw new RuntimeException( "Constraint " + this.getLogicGroup().getLogicClassName() + "." + this.getLogicMethodName() + " evaluated to a non-boolean value. A constraint must evaluate to true or false."); if (!skipMethodIfPossible) { try { // Then call the method for debugging purposes, but ignore its return value MethodInvocationUtil.invokeMethodOnObject(aLogicObject, logicMethodName); } catch (Exception ex) { log.warn("Constraint method " + this.getLogicGroup().getLogicClassName() + "." + this.getLogicMethodName() + " threw an exception. This is not fatal because " + "the constraint has an expression in its declaration, and therefore the method itself " + "is called only for debugging convenience, but this should be examined. The exception was: " + ex); } } // If the constraint simply evaluated to false... if (!((Boolean) result)) { String msg = "Constraint expression " + getLogicGroup().getLogicClassName() + "." + getLogicMethodName() + " evaluated to false."; if (errorMessage != null) msg = getFormattedErrorMessage(bean); throw new InvocationTargetException(new InternalConstraintException(msg)); } }