if (!path.toFile().exists()) { String msg = NLS.bind(PrefsMessages.preferences_fileNotFound, path.toOSString()); throw new CoreException(new Status(IStatus.ERROR, PrefsMessages.OWNER_NAME, 1, msg, null)); input = new BufferedInputStream(new FileInputStream(path.toFile())); service.importPreferences(input); } catch (FileNotFoundException e) { String msg = NLS.bind(PrefsMessages.preferences_fileNotFound, path.toOSString()); throw new CoreException(new Status(IStatus.ERROR, PrefsMessages.OWNER_NAME, 1, msg, e)); } finally { if (input != null)
public static void reloadMessages() { NLS.initializeMessages(BUNDLE_NAME, Messages.class); } }
try { monitor = ProgressUtil.getMonitorFor(monitor); monitor.beginTask(Messages.loadingTask, 5); InputStream in = new FileInputStream(path.append("catalina.policy").toFile()); in.read(); in.close(); monitor.worked(1); server = (Server) serverFactory.loadDocument(new FileInputStream(path.append("server.xml").toFile())); serverInstance = new ServerInstance(server, null, null); monitor.worked(1); webAppDocument = new WebAppDocument(path.append("web.xml")); } catch (Exception e) { Trace.trace(Trace.WARNING, "Could not load Tomcat v4.0 configuration from " + path.toOSString() + ": " + e.getMessage()); throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotLoadConfiguration, path.toOSString()), e));
private void initializeLocation() throws CoreException { // check if the location can be created if (location.toFile().exists()) { if (!location.toFile().isDirectory()) { String message = NLS.bind(CommonMessages.meta_notDir, location); throw new CoreException(new Status(IStatus.ERROR, IRuntimeConstants.PI_RUNTIME, IRuntimeConstants.FAILED_WRITE_METADATA, message, null)); } } //try infer the device if there isn't one (windows) if (location.getDevice() == null) location = new Path(location.toFile().getAbsolutePath()); createLocation(); initialized = true; }
private void validateManifestFile(IFile file, IProgressMonitor monitor) { if (monitor.isCanceled()) return; String message = NLS.bind(PDECoreMessages.Builders_verifying, file.getFullPath().toString()); monitor.subTask(message); BundleErrorReporter reporter = new BundleErrorReporter(file); if (reporter != null) { reporter.validateContent(monitor); monitor.subTask(PDECoreMessages.Builders_updating); } monitor.done(); }
/** * @param baseline the baseline that is disposed * @throws CoreException with the baseline disposed information */ protected void baselineDisposed(IApiBaseline baseline) throws CoreException { throw new CoreException(new Status(IStatus.ERROR, ApiPlugin.PLUGIN_ID, ApiPlugin.REPORT_BASELINE_IS_DISPOSED, NLS.bind(Messages.BundleApiComponent_baseline_disposed, baseline.getName()), null)); } }
public IStatus validateLinkLocation(IResource resource, IPath unresolvedLocation) { IPath location = resource.getPathVariableManager().resolvePath(unresolvedLocation); if (location.isEmpty()) return new ResourceStatus(IResourceStatus.INVALID_VALUE, resource.getFullPath(), Messages.links_noPath); //check that the location is absolute if (!location.isAbsolute()) { //we know there is at least one segment, because of previous isEmpty check String message = NLS.bind(Messages.pathvar_undefined, location.toOSString(), location.segment(0)); return new ResourceStatus(IResourceStatus.VARIABLE_NOT_DEFINED_WARNING, resource.getFullPath(), message); } //if the location doesn't have a device, see if the OS will assign one if (location.getDevice() == null) location = new Path(location.toFile().getAbsolutePath()); return validateLinkLocationURI(resource, URIUtil.toURI(location)); }
protected void backupPath(IPath path, IPath confDir, IPath backup, MultiStatus ms, IProgressMonitor monitor) { File[] files = path.toFile().listFiles(); if (files == null) return; monitor.beginTask(Messages.publishConfigurationTask, size * 100); for (int i = 0; i < size; i++) { try { File file = files[i]; String name = file.getName(); monitor.subTask(NLS.bind(Messages.publisherPublishTask, new String[] {name})); if (Trace.isTraceEnabled()) Trace.trace(Trace.FINEST, "Publishing " + name); if (backup != null && !(backup.append(name).toFile().exists())) { IStatus status = FileUtil.copyFile(confDir.append(name).toOSString(), backup + File.separator + name); ms.add(status); } catch (Exception e) { Trace.trace(Trace.SEVERE, "backupAndPublish() error", e); ms.add(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPublishConfiguration, new String[] {e.getLocalizedMessage()}), e)); monitor.worked(100);
/** * Returns a URL to the configuration area associated with this profile or <code>null</code> * if none. * * @return configuration area URL or <code>null</code> * @throws CoreException if unable to generate a URL or the user specified location does not exist */ private URL getConfigurationArea() throws CoreException { IPath home = resolveHomeLocation(); IPath configuration = null; if (fConfiguration == null) { configuration = home.append("configuration"); //$NON-NLS-1$ } else { configuration = new Path(resolveVariables(fConfiguration)); } File file = configuration.toFile(); if (file.exists()) { try { return file.toURL(); } catch (MalformedURLException e) { throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, NLS.bind(Messages.ProfileBundleContainer_1, home.toOSString()), e)); } } else if (fConfiguration != null) { // If the user specified config area does not exist throw an error throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, NLS.bind(Messages.ProfileBundleContainer_2, configuration.toOSString()))); } return null; }
/** * @see ErrorHandler#fatalError(SAXParseException) */ @Override public void fatalError(SAXParseException error) throws SAXException { // ensure a null value is not passed as message to Status constructor (bug 42782) String message = error.getMessage(); if (project != null) message = NLS.bind(Messages.resources_readMeta, project.getName()); problems.add(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IResourceStatus.FAILED_READ_METADATA, message == null ? "" : message, error)); //$NON-NLS-1$ throw error; }
@Override protected void collectAll(IResource resource, int depth, final IProgressMonitor monitor) { Policy.checkCanceled(monitor); monitor.beginTask(null, IProgressMonitor.UNKNOWN); ResourceTraversal[] traversals = new ResourceTraversal[] { new ResourceTraversal(new IResource[] { resource }, depth, IResource.NONE) }; try { getSubscriber().accept(traversals, diff -> { Policy.checkCanceled(monitor); monitor.subTask(NLS.bind(Messages.SubscriberDiffTreeEventHandler_0, tree.getResource(diff).getFullPath().toString())); // Queue up any found diffs for inclusion into the output tree queueDispatchEvent( new SubscriberDiffChangedEvent(tree.getResource(diff), SubscriberEvent.CHANGE, IResource.DEPTH_ZERO, diff)); // Handle any pending dispatches handlePreemptiveEvents(monitor); handlePendingDispatch(monitor); return true; }); } catch (CoreException e) { if (resource.getProject().isAccessible()) handleException(e, resource, ITeamStatus.SYNC_INFO_SET_ERROR, e.getMessage()); } finally { monitor.done(); } }
/** * Tries to delete the custom loader jar added to support serving projects directly * without publishing. Returns a warning if not successful. * * @param destDir destination directory containing the loader jar * @param serverId ID of the server from which to delete the jar * @return result of copy operation */ public static IStatus removeLoaderJar(IPath destDir, String serverId) { String loaderJar = "/" + serverId + ".loader.jar"; File loaderFile = destDir.append(loaderJar).toFile(); // If loader jar exists but is not successfully deleted, return warning if (loaderFile.exists() && !loaderFile.delete()) return new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPublishCantDeleteLoaderJar, loaderFile.getPath()), null); return Status.OK_STATUS; } /**
private void modifyExtensionSplashHandlers(IPluginExtension extension) throws CoreException { // Update progress work units fMonitor.beginTask(NLS.bind(PDEUIMessages.UpdateSplashHandlerInModelAction_msgModifyingExtension, F_SPLASH_HANDLERS_EXTENSION), 1); // modify the existing extension children modifyExtensionChildrenSplashHandlers(extension); // Update progress work units fMonitor.done(); }
@Override public void run(IProgressMonitor mon) throws InvocationTargetException, InterruptedException { mon.beginTask(PDEUIMessages.FormatManifestOperation_task, fObjects.length); for (int i = 0; !mon.isCanceled() && i < fObjects.length; i++) { Object obj = fObjects[i]; if (obj instanceof IFileEditorInput) obj = ((IFileEditorInput) obj).getFile(); if (obj instanceof IFile) { mon.subTask(NLS.bind(PDEUIMessages.FormatManifestOperation_subtask, ((IFile) obj).getFullPath().toString())); format((IFile) obj, mon); } mon.worked(1); } }
protected void assertCreateRequirements(IFileStore store, IFileInfo localInfo, int updateFlags) throws CoreException { checkDoesNotExist(); Container parent = (Container) getParent(); ResourceInfo info = parent.getResourceInfo(false, false); parent.checkAccessible(getFlags(info)); checkValidGroupContainer(parent, false, false); final boolean force = (updateFlags & IResource.FORCE) != 0; if (!force && localInfo.exists()) { //return an appropriate error message for case variant collisions if (!Workspace.caseSensitive) { String name = getLocalManager().getLocalName(store); if (name != null && !store.getName().equals(name)) { String msg = NLS.bind(Messages.resources_existsLocalDifferentCase, new Path(store.toString()).removeLastSegments(1).append(name).toOSString()); throw new ResourceException(IResourceStatus.CASE_VARIANT_EXISTS, getFullPath(), msg, null); } } String msg = NLS.bind(Messages.resources_fileExists, store.toString()); throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, getFullPath(), msg, null); } }
@Override public IStatus merge(OutputStream output, String outputEncoding, IStorage ancestor, IStorage target, IStorage other, IProgressMonitor monitor) throws CoreException { IStorageMerger merger = createDelegateMerger(target); if (merger == null) return new Status(IStatus.WARNING, TeamPlugin.ID, CONFLICT, Messages.DelegatingStorageMerger_0, null); if (ancestor == null && !merger.canMergeWithoutAncestor()) { return new Status(IStatus.WARNING, TeamPlugin.ID, CONFLICT, NLS.bind(Messages.MergeContext_1, new String[] { target.getFullPath().toString() }), null); } return merger.merge(output, outputEncoding, ancestor, target, other, monitor); }
if (!PREFS_FILE_EXTENSION.equals(path.getFileExtension())) return; String project = path.segment(0); String qualifier = path.removeFileExtension().lastSegment(); Preferences root = Platform.getPreferencesService().getRootNode(); Preferences node = root.node(ProjectScope.SCOPE).node(project).node(qualifier); String message = null; try { message = NLS.bind(Messages.preferences_syncException, node.absolutePath()); if (!(node instanceof ProjectPreferences)) return; preferencesChanged(file.getProject()); } catch (BackingStoreException e) { IStatus status = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IStatus.ERROR, message, e); throw new CoreException(status);
private void endLinkPath(String elementName) { if (elementName.equals(NAME)) { IPath newPath = new Path(charBuffer.toString()); // objectStack has a LinkDescription on it. Set the name // on this LinkDescription. IPath oldPath = ((LinkDescription) objectStack.peek()).getProjectRelativePath(); if (oldPath.segmentCount() != 0) { parseProblem(NLS.bind(Messages.projRead_badLinkName, oldPath, newPath)); } else { ((LinkDescription) objectStack.peek()).setPath(newPath); } state = S_LINK; } }
private IStatus refresh(IResource resource, int depth, IProgressMonitor monitor) { monitor = Policy.monitorFor(monitor); try { monitor.beginTask(null, 100); Set<IResource> allChanges = new HashSet<>(); if (getResourceComparator().isThreeWay()) { IResource[] baseChanges = getBaseTree().refresh(new IResource[] {resource}, depth, Policy.subMonitorFor(monitor, 25)); allChanges.addAll(Arrays.asList(baseChanges)); } IResource[] remoteChanges = getRemoteTree().refresh(new IResource[] {resource}, depth, Policy.subMonitorFor(monitor, 75)); allChanges.addAll(Arrays.asList(remoteChanges)); IResource[] changedResources = allChanges.toArray(new IResource[allChanges.size()]); fireTeamResourceChange(SubscriberChangeEvent.asSyncChangedDeltas(this, changedResources)); return Status.OK_STATUS; } catch (TeamException e) { return new TeamStatus(IStatus.ERROR, TeamPlugin.ID, 0, NLS.bind(Messages.ResourceVariantTreeSubscriber_2, new String[] { resource.getFullPath().toString(), e.getMessage() }), e, resource); } catch (OperationCanceledException e) { return new TeamStatus(IStatus.CANCEL, TeamPlugin.ID, 0, NLS.bind( Messages.ResourceVariantTreeSubscriber_4, new String[] { resource.getFullPath().toString() }), e, resource); } finally { monitor.done(); } }
private void importJar(File jar, IResource destination, IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { try (ZipFile input = new ZipFile(jar);) { ZipFileStructureProvider provider = new ZipFileStructureProvider(input); ImportOperation op = new ImportOperation(destination.getFullPath(), provider.getRoot(), provider, pathString -> IOverwriteQuery.ALL); op.run(monitor); } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, IPDEUIConstants.PLUGIN_ID, IStatus.OK, NLS.bind(PDEUIMessages.NewProjectCreationOperation_errorImportingJar, jar), e)); } }