Java Code Examples for org.eclipse.core.filesystem.IFileStore

The following examples show how to use org.eclipse.core.filesystem.IFileStore. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: goclipse   Source File: NavigatorLinkHelper.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public IStructuredSelection findSelection(IEditorInput input) {
  IFile file = ResourceUtil.getFile(input);

  if (file != null) {
    return new StructuredSelection(file);
  }

  IFileStore fileStore = (IFileStore) input.getAdapter(IFileStore.class);

  if (fileStore == null && input instanceof FileStoreEditorInput) {
    URI uri = ((FileStoreEditorInput)input).getURI();
    
    try {
      fileStore = EFS.getStore(uri);
    } catch (CoreException e) {

    }
  }
  
  if (fileStore != null) {
    return new StructuredSelection(fileStore);
  }

  return StructuredSelection.EMPTY;
}
 
Example 2
Source Project: orion.server   Source File: ManifestUtilsTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testFlatComplexInheritance() throws Exception {
	String MANIFEST_LOCATION = "testData/manifestTest/inheritance/06"; //$NON-NLS-1$
	String manifestName = "final-manifest.yml"; //$NON-NLS-1$

	URL entry = ServerTestsActivator.getContext().getBundle().getEntry(MANIFEST_LOCATION);
	IFileStore fs = EFS.getStore(URIUtil.toURI(FileLocator.toFileURL(entry).getPath().concat(manifestName)));

	ManifestParseTree manifest = ManifestUtils.parse(fs.getParent(), fs);
	ManifestParseTree applications = manifest.get("applications"); //$NON-NLS-1$
	assertEquals(2, applications.getChildren().size());

	for (ManifestParseTree application : applications.getChildren()) {
		assertTrue(application.has("domain")); //$NON-NLS-1$
		assertTrue(application.has("instances")); //$NON-NLS-1$
		assertTrue(application.has("memory")); //$NON-NLS-1$

		if ("A".equals(application.get("name").getValue())) //$NON-NLS-1$ //$NON-NLS-2$
			assertTrue("2".equals(application.get("instances").getValue())); //$NON-NLS-1$ //$NON-NLS-2$
	}
}
 
Example 3
protected Set<IFileStore> toFileStores(IProgressMonitor monitor)
{
	SubMonitor sub = SubMonitor.convert(monitor, files.size());
	Set<IFileStore> fileStores = new HashSet<IFileStore>(files.size());
	for (IFile file : files)
	{
		try
		{
			IFileStore store = EFS.getStore(file.getLocationURI());
			if (store == null)
			{
				continue;
			}
			fileStores.add(store);
		}
		catch (CoreException e)
		{
			IdeLog.logError(IndexPlugin.getDefault(), e);
		}
		finally
		{
			sub.worked(1);
		}
	}
	return fileStores;
}
 
Example 4
Source Project: orion.server   Source File: SftpFileStore.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException {
	SynchronizedChannel channel = getChannel();
	try {
		try {
			channel.mkdir(getPathString(channel));
		} catch (SftpException sftpException) {
			//jsch mkdir fails if dir already exists, but EFS API says we should not fail
			SftpATTRS stat = channel.stat(getPathString(channel));
			if (stat.isDir())
				return this;
			//rethrow and fail
			throw sftpException;
		}
	} catch (Exception e) {
		ChannelCache.flush(host);
		throw wrap(e);
	}
	return this;
}
 
Example 5
/**
 * Looks for a Procfile and parses the web command.
 * @return <code>null</code> iff there is no Procfile present or it does not contain a web command.
 */
protected String getProcfileCommand(IFileStore contentLocation) {
	IFileStore procfileStore = contentLocation.getChild(ManifestConstants.PROCFILE);
	if (!procfileStore.fetchInfo().exists())
		return null;

	InputStream is = null;
	try {

		is = procfileStore.openInputStream(EFS.NONE, null);
		Procfile procfile = Procfile.load(is);
		return procfile.get(ManifestConstants.WEB);

	} catch (Exception ex) {
		/* can't parse the file, fail */
		return null;

	} finally {
		IOUtilities.safeClose(is);
	}
}
 
Example 6
@Override
public boolean isEnabled() {
	ISelection selection = selectionProvider.getSelection();
	if(selection.isEmpty() || !(selection instanceof StructuredSelection)) {
		return false;
	}
	StructuredSelection ss = (StructuredSelection) selection;
	if(ss.size() == 1 && ss.getFirstElement() instanceof IFileStore) {
		IFileStore fileStore = (IFileStore) ss.getFirstElement();
		if(!fileStore.fetchInfo().isDirectory()) {
			this.fileStore = fileStore;
			return true;
		}
		return false;
	}
	return false;
}
 
Example 7
Source Project: orion.server   Source File: CoreFilesTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testListenerWriteFile() throws CoreException, IOException, SAXException, JSONException {
	String directoryPath = "sample/directory/path" + System.currentTimeMillis();
	IFileStore dir = createDirectory(directoryPath);
	String fileName = "testfile.txt";

	WebRequest request = getPostFilesRequest(directoryPath, getNewFileJSON(fileName).toString(), fileName);
	WebResponse response = webConversation.getResponse(request);
	assertEquals(HttpURLConnection.HTTP_CREATED, response.getResponseCode());

	modListener = new TestFilesystemModificationListener();

	//put to file location should succeed
	String location = response.getHeaderField("Location");
	String fileContent = "New contents";
	request = getPutFileRequest(location, fileContent);
	response = webConversation.getResponse(request);
	assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

	modListener.assertListenerNotified(dir.getChild(fileName), ChangeType.WRITE);
}
 
Example 8
Source Project: sarl   Source File: BuildSettingWizardPage.java    License: Apache License 2.0 6 votes vote down vote up
private static File createBackup(IFileStore source, String name) throws CoreException {
	try {
		final File bak = File.createTempFile("eclipse-" + name, ".bak"); //$NON-NLS-1$//$NON-NLS-2$
		copyFile(source, bak);
		return bak;
	} catch (IOException e) {
		final IStatus status = new Status(
				IStatus.ERROR,
				JavaUI.ID_PLUGIN,
				IStatus.ERROR,
				MessageFormat.format(
				NewWizardMessages.NewJavaProjectWizardPageTwo_problem_backup,
				name),
				e);
		throw new CoreException(status);
	}
}
 
Example 9
Source Project: orion.server   Source File: PackagerTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testCFIgnoreNegation() throws Exception {
	ZipOutputStream mockZos = mock(ZipOutputStream.class);

	String LOCATION = "testData/packagerTest/02"; //$NON-NLS-1$
	URL entry = ServerTestsActivator.getContext().getBundle().getEntry(LOCATION);
	IFileStore source = EFS.getStore(URIUtil.toURI(FileLocator.toFileURL(entry).getPath()));

	PackageUtils.writeZip(source, mockZos);

	/* what is... */
	verify(mockZos).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry(".cfignore")))); //$NON-NLS-1$
	verify(mockZos).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry("A/B/.cfignore")))); //$NON-NLS-1$
	verify(mockZos).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry("A/B/test.in")))); //$NON-NLS-1$

	/* ... and what should never be */
	verify(mockZos, never()).putNextEntry(argThat(new ZipArgumentMatcher(new ZipEntry("A/B/test2.in")))); //$NON-NLS-1$
}
 
Example 10
/**
 * getContributedFiles
 * 
 * @param container
 * @return
 */
protected Set<IFileStore> getContributedFiles(URI container)
{
	Set<IFileStore> result = new HashSet<IFileStore>();
	IndexManager manager = getIndexManager();

	if (manager != null)
	{
		for (IIndexFileContributor contributor : manager.getFileContributors())
		{
			Set<IFileStore> files = contributor.getFiles(container);

			if (!CollectionsUtil.isEmpty(files))
			{
				result.addAll(files);
			}
		}
	}

	return result;
}
 
Example 11
Source Project: tracecompass   Source File: LoadDialog.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void okPressed() {
    fIsForce = fForceButton.getSelection();
    if (fFileWidget != null) {
        fRemoteFiles = fFileWidget.getResources();
        if (!fRemoteFiles.isEmpty()) {
            super.okPressed();
        }
        return;
    }

    Object[] files = fFolderViewer.getCheckedElements();
    List<IFileStore> stores = new ArrayList<>();
    for (Object file : files) {
        if (file instanceof File) {
            stores.add(EFS.getLocalFileSystem().fromLocalFile((File) file));
        }
    }
    if (!stores.isEmpty()) {
        fLocalFiles = stores;
        super.okPressed();
    }
}
 
Example 12
Source Project: orion.server   Source File: FileHandlerV1.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private void handleMultiPartGet(HttpServletRequest request, HttpServletResponse response, IFileStore file) throws IOException, CoreException,
		NoSuchAlgorithmException, JSONException {
	String boundary = createBoundaryString();
	response.setHeader("Cache-Control", "no-cache"); //$NON-NLS-1$ //$NON-NLS-2$
	response.setHeader(ProtocolConstants.HEADER_ACCEPT_PATCH, ProtocolConstants.CONTENT_TYPE_JSON_PATCH);
	response.setHeader(ProtocolConstants.HEADER_CONTENT_TYPE, "multipart/related; boundary=\"" + boundary + '"'); //$NON-NLS-1$
	OutputStream outputStream = response.getOutputStream();
	Writer out = new OutputStreamWriter(outputStream, "UTF-8");
	out.write("--" + boundary + EOL); //$NON-NLS-1$
	out.write("Content-Type: application/json" + EOL + EOL); //$NON-NLS-1$
	appendGetMetadata(request, response, out, file);
	out.write(EOL + "--" + boundary + EOL); //$NON-NLS-1$
	// headers for file contents go here
	out.write(EOL);
	out.flush();
	IOUtilities.pipe(file.openInputStream(EFS.NONE, null), outputStream, true, false);
	out.write(EOL + "--" + boundary + EOL); //$NON-NLS-1$
	out.flush();
}
 
Example 13
Source Project: bonita-studio   Source File: OpenLogCommand.java    License: GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	IFileStore fileStore = EFS.getLocalFileSystem().getStore(Platform.getLogFileLocation());
	try {
		IDE.openEditorOnFileStore(page, fileStore);
	} catch (PartInitException e) {
		BonitaStudioLog.error(e);
		try {
			IDE.openInternalEditorOnFileStore(page, fileStore);
		} catch (PartInitException e1) {
			BonitaStudioLog.error(e1);
			BonitaStudioLog.log("Can't open .log file in editor. You should associate .log to a program at OS level.");
		}
	}		
	return null;
}
 
Example 14
Source Project: orion.server   Source File: GitUtils.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the existing git repositories for the given file path, following the given traversal rule.
 *
 * @param path
 *            expected format /file/{Workspace}/{projectName}[/{path}]
 * @return a map of all git repositories found, or <code>null</code> if the provided path format doesn't match the expected format.
 * @throws CoreException
 */
public static Map<IPath, File> getGitDirs(IPath path, Traverse traverse) throws CoreException {
	IPath p = path.removeFirstSegments(1);// remove /file
	IFileStore fileStore = NewFileServlet.getFileStore(null, p);
	if (fileStore == null)
		return null;
	Map<IPath, File> result = new HashMap<IPath, File>();
	File file = fileStore.toLocalFile(EFS.NONE, null);
	// jgit can only handle a local file
	if (file == null)
		return result;
	switch (traverse) {
	case CURRENT:
		File gitDir = resolveGitDir(file);
		if (gitDir != null) {
			result.put(new Path(""), gitDir); //$NON-NLS-1$
		}
		break;
	case GO_UP:
		getGitDirsInParents(file, result);
		break;
	case GO_DOWN:
		getGitDirsInChildren(file, p, result);
		break;
	}
	return result;
}
 
Example 15
/**
 * Constructs a new document adapter.
 * 
 * @param owner the owner of this buffer
 * @param fileStore the file store of the file that backs the buffer
 * @param path the path of the file that backs the buffer
 * @since 3.6
 */
public DocumentAdapter(IOpenable owner, IFileStore fileStore, IPath path) {
	Assert.isLegal(fileStore != null);
	Assert.isLegal(path != null);
	fOwner= owner;
	fFileStore= fileStore;
	fPath= path;
	fLocationKind= LocationKind.NORMALIZE;

	initialize();
}
 
Example 16
Source Project: orion.server   Source File: GitIgnoreHandlerV1.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Appends a single rule in the given .gitignore file store. If necessary, the .gitignore file is created.
 * 
 * @param gitignoreStore
 *            The .gitignore file store.
 * @param rule
 *            The entry to be appended to the .gitignore.
 * @throws CoreException
 * @throws IOException
 */
private void appendGitignore(IFileStore gitignoreStore, String rule) throws CoreException, IOException {
	OutputStream out = null;
	try {
		out = gitignoreStore.openOutputStream(EFS.APPEND, null);
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out));
		bw.write(System.getProperty("line.separator") + "/" + rule);
		bw.flush();
	} finally {
		if (out != null)
			out.close();
	}
}
 
Example 17
/**
 * Replaces the old jar file with the new one.
 *
 * @param monitor
 *            the progress monitor to use
 * @throws CoreException
 *             if an error occurs
 */
private void replaceJarFile(final IProgressMonitor monitor) throws CoreException {
	try {
		monitor.beginTask(JarImportMessages.JarImportWizard_cleanup_import, 250);
		final URI location= fImportData.getRefactoringFileLocation();
		if (location != null) {
			final IPackageFragmentRoot root= fImportData.getPackageFragmentRoot();
			if (root != null) {
				final URI uri= getLocationURI(root.getRawClasspathEntry());
				if (uri != null) {
					final IFileStore store= EFS.getStore(location);
					if (fImportData.isRenameJarFile()) {
						final URI target= getTargetURI(uri);
						store.copy(EFS.getStore(target), EFS.OVERWRITE, new SubProgressMonitor(monitor, 50, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
						if (!uri.equals(target))
							EFS.getStore(uri).delete(EFS.NONE, new SubProgressMonitor(monitor, 50, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
					} else
						store.copy(EFS.getStore(uri), EFS.OVERWRITE, new SubProgressMonitor(monitor, 100, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
					if (fJavaProject != null)
						fJavaProject.getResource().refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 50, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
					return;
				}
			}
		}
		throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, JarImportMessages.JarImportWizard_error_copying_jar, null));
	} finally {
		monitor.done();
	}
}
 
Example 18
private IFile getWorkspaceFile(IFileStore fileStore)
{
	IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
	IFile[] files = workspaceRoot.findFilesForLocationURI(fileStore.toURI());
	if (files != null && files.length > 0)
	{
		return files[0];
	}
	return null;
}
 
Example 19
Source Project: Pydev   Source File: ChangedLinesComputer.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Return the lines which have changed in the given buffer since the last save occurred. 
 * 
 * @param buffer the buffer to compare contents from
 * @param monitor to report progress to
 * @return the regions of the changed lines or null if something went wrong.
 */
public static int[] calculateChangedLines(final ITextFileBuffer buffer, final IProgressMonitor monitor)
        throws CoreException {
    int[] result = null;

    try {
        monitor.beginTask("Calculating changed lines", 20);
        IFileStore fileStore = buffer.getFileStore();

        ITextFileBufferManager fileBufferManager = FileBuffers.createTextFileBufferManager();
        fileBufferManager.connectFileStore(fileStore, getSubProgressMonitor(monitor, 15));
        try {
            IDocument currentDocument = buffer.getDocument();
            IDocument oldDocument = ((ITextFileBuffer) fileBufferManager.getFileStoreFileBuffer(fileStore))
                    .getDocument();

            result = getChangedLines(oldDocument, currentDocument);
        } finally {
            fileBufferManager.disconnectFileStore(fileStore, getSubProgressMonitor(monitor, 5));
            monitor.done();
        }
    } catch (Exception e) {
        Log.log(e);
        return null;
    }

    return result;
}
 
Example 20
Source Project: orion.server   Source File: PushAppCommand.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public PushAppCommand(Target target, App app, IFileStore appStore, IDeploymentPackager packager) {
	super(target);
	this.commandName = "Push application"; //$NON-NLS-1$

	this.app = app;
	this.appStore = appStore;
	this.packager = packager;
}
 
Example 21
Source Project: xds-ide   Source File: IdeImportResolver.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected XdsParser createXdsParser(IFileStore moduleFile, String fileContents,
		XdsSourceType sourceType) {
	XdsParser parser = new XdsParser( moduleFile, fileContents
               , new XdsSettings(buildSettings, sourceType), this, reporter, monitor );
	return parser;
}
 
Example 22
Source Project: APICloud-Studio   Source File: EFSUtils.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the files of the filestore array plus all of their children
 * 
 * @param files
 * @return
 * @throws CoreException
 */
public static IFileStore[] getAllFiles(IFileStore[] files, boolean recurse, boolean includeCloakedFiles,
		IProgressMonitor monitor) throws CoreException
{
	List<IFileStore> fileList = new ArrayList<IFileStore>();
	fileList.addAll(Arrays.asList(files));
	fileList.addAll(Arrays.asList(getFiles(files, true, false, monitor)));

	return fileList.toArray(new IFileStore[fileList.size()]);
}
 
Example 23
public Image getImage(Object element) {
	if (element instanceof IFileStore) {
		IFileStore curr = (IFileStore) element;
		if (curr.fetchInfo().isDirectory()) {
			return IMG_FOLDER;
		}
		return IMG_FILE;
	}
	return null;
}
 
Example 24
/**
 * Make a best guess as to whether the IFileStore is local or remote. Should be local for LocalFile and
 * WorkspaceFile.
 * 
 * @param baseStore
 * @return
 */
private boolean isRemoteURI(IFileStore baseStore)
{
	try
	{
		return baseStore.toLocalFile(EFS.NONE, new NullProgressMonitor()) == null;
	}
	catch (CoreException e)
	{
		IdeLog.logError(HTMLPlugin.getDefault(), e);
	}
	return true;
}
 
Example 25
/**
 * Checks whether the infos exist.
 *
 * @param stores
 *            the file infos to test
 * @return Multi status with one error message for each missing file.
 */
IStatus checkExist(IFileStore[] stores) {
    MultiStatus multiStatus = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, getProblemsMessage(), null);

    for (int i = 0; i < stores.length; i++) {
        if (stores[i].fetchInfo().exists() == false) {
            String message = NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_resourceDeleted,
                    stores[i].getName());
            IStatus status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, message, null);
            multiStatus.add(status);
        }
    }
    return multiStatus;
}
 
Example 26
protected String getApplicationHost(IFileStore contentLocation) throws UnsupportedEncodingException {

		IFileStore rootStore = OrionConfiguration.getRootLocation();
		Path relativePath = new Path(URLDecoder.decode(contentLocation.toURI().toString(), "UTF8").substring(rootStore.toURI().toString().length()));
		if (relativePath.segmentCount() < 4) {
			// not a change to a file in a project
			return null;
		}
		
		String folderName = relativePath.segment(3);
		folderName = folderName.replaceFirst(" \\| ", " --- ");
		return ManifestUtils.slugify(folderName);
	}
 
Example 27
Source Project: APICloud-Studio   Source File: EFSUtils.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * getFiles
 * 
 * @param file
 * @param recurse
 * @param list
 * @param includeCloakedFiles
 * @param monitor
 *            the progress monitor to use for reporting progress to the user. It is the caller's responsibility to
 *            call done() on the given monitor. Accepts null, indicating that no progress should be reported and
 *            that the operation cannot be cancelled.
 * @throws CoreException
 */
private static void getFiles(IFileStore file, boolean recurse, List<IFileStore> list, boolean includeCloakedFiles,
		IProgressMonitor monitor) throws CoreException
{
	if (file == null)
	{
		return;
	}

	if (monitor != null)
	{
		Policy.checkCanceled(monitor);
	}

	if (isFolder(file, monitor))
	{
		IFileStore[] children = file.childStores(EFS.NONE, monitor);
		if (children != null)
		{
			SubMonitor progress = SubMonitor.convert(monitor, children.length);
			boolean addingFile;
			for (IFileStore child : children)
			{
				Policy.checkCanceled(progress);
				addingFile = false;
				if (includeCloakedFiles || !CloakingUtils.isFileCloaked(child))
				{
					list.add(child);
					addingFile = true;
				}

				if (recurse && addingFile && isFolder(child, progress))
				{
					getFiles(child, recurse, list, includeCloakedFiles, progress.newChild(1));
				}
			}
		}
	}
}
 
Example 28
/**
 * Creates a fake compilation unit.
 *
 * @param editorInput the URI editor input
 * @return the fake compilation unit
 * @since 3.3
 */
private ICompilationUnit createFakeCompiltationUnit(IURIEditorInput editorInput) {
	try {
		final URI uri= editorInput.getURI();
		final IFileStore fileStore= EFS.getStore(uri);
		final IPath path= URIUtil.toPath(uri);
		String fileStoreName= fileStore.getName();
		if (fileStoreName == null || path == null)
			return null;

		WorkingCopyOwner woc= new WorkingCopyOwner() {
			/*
			 * @see org.eclipse.jdt.core.WorkingCopyOwner#createBuffer(org.eclipse.jdt.core.ICompilationUnit)
			 * @since 3.2
			 */
			@Override
			public IBuffer createBuffer(ICompilationUnit workingCopy) {
				return new DocumentAdapter(workingCopy, fileStore, path);
			}
		};

		IClasspathEntry[] cpEntries= null;
		IJavaProject jp= findJavaProject(path);
		if (jp != null)
			cpEntries= jp.getResolvedClasspath(true);

		if (cpEntries == null || cpEntries.length == 0)
			cpEntries= new IClasspathEntry[] { JavaRuntime.getDefaultJREContainerEntry() };

		final ICompilationUnit cu= woc.newWorkingCopy(fileStoreName, cpEntries, getProgressMonitor());

		if (!isModifiable(editorInput))
			JavaModelUtil.reconcile(cu);

		return cu;
	} catch (CoreException ex) {
		return null;
	}
}
 
Example 29
Source Project: XPagesExtensionLibrary   Source File: ManifestMetaModel.java    License: Apache License 2.0 5 votes vote down vote up
public BluemixManifestEditorInput(IFileStore fileStore, IDominoDesignerProject project) {
    super(fileStore);
    _designerProject = project;
    
    // Get the file link for the manifest - This allows us to sync with
    // the Navigator and close the manifest when the project is closing
    _fileLink = project.getProject().getFile(MANIFEST_PATH);
    try {                
        // Is the correct file link in place ?
        if (_fileLink.getLocationURI().equals(getURI())) {
            // Yes, refresh the resource - this is needed or we run into
            // file sync problems, not sure why !!!
            _fileLink.refreshLocal(IResource.DEPTH_ZERO, null);
        } else {
            // No, create the link - this modifies the .project file
            // The link has to be created in the project root, links in sub-dirs
            // cause exceptions when opening an NSF
            _fileLink.createLink(getURI(), IResource.REPLACE, null);
        }

    } catch (CoreException e) {
        if (BluemixLogger.BLUEMIX_LOGGER.isErrorEnabled()) {
            BluemixLogger.BLUEMIX_LOGGER.errorp(this, "BluemixManifestEditorInput", e, "Failed to create or refresh the manifest file link"); // $NON-NLS-1$ $NLE-ManifestMetaModel.Failedtocreateorrefreshthemanifes-2$
        }
    }
    
}
 
Example 30
Source Project: orion.server   Source File: SimpleMetaStore.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IFileStore getUserHome(String userId) {
	IFileStore root = OrionConfiguration.getRootLocation();
	if (userId != null) {
		// the format of the user home is /serverworkspace/an/anthony
		String userPrefix = userId.substring(0, Math.min(2, userId.length()));
		return root.getChild(userPrefix).getChild(userId);
	}
	// for backwards compatibility, if userId is null, the old API used to return the root location;
	return root;
}