Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Orion (Archived) » can no longer guess file system locations from user file locations
can no longer guess file system locations from user file locations [message #924827] Thu, 27 September 2012 06:48 Go to next message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
In dev.cloudfier.com I have a hack for implementing project-wide builds:

1) I run a server side-by-side with Orion (could be merged in one, but that should not matter), so I can access the project contents

2) Implement a validator service that will pass the location of the file being validated to my server (instead of the contents)

3) The server will then construct a file system location by appending the location to the workspace location: I get to the relevant user file, can walk up to the containing dir for the project location, etc, so I can build the entire project.

However, 1.0M2 breaks this hack, and I can't at this point move to this version: the locations representing user files no longer expose the hashes used in the file system storage, so it is no longer possible to map the location a validator gets from Orion to a file system location.

Granted, I was relying on unspecified behavior. But at the same time I am just trying to implement functionality Orion should ideally be providing out of the box.

So, any ideas of how to get out of this situation? Things I thought:

1) Orion file system locations preserved user-chosen names (I guess the goal of the hashes here is to avoid file system limitations for file names?)

2) Orion exposes both user-facing and internal locations (ugly, now there would be two locations for everything)

3) Orion provides a server setting that allows reverting locations to be hashed as pre-M2

4) I implement my own file service that saves data in my own server (which would be unfortunate, as I'd rather not be in the business of file storage - and I guess the user would lose Git support for his files)

5) Orion provides support for project-wide validation (say, the validator is given a parameter that allows it to browse the tree and fetch file contents).

6) ???

Cheers,

Rafael

[Updated on: Thu, 27 September 2012 07:59]

Report message to a moderator

Re: can no longer guess file system locations from user file locations [message #925408 is a reply to message #924827] Thu, 27 September 2012 17:38 Go to previous messageGo to next message
John Arthorne is currently offline John ArthorneFriend
Messages: 176
Registered: July 2009
Senior Member
Ugh, sorry about this Rafael. The intent here was to create cleaner, more logical client side URLs and avoid hashes appearing anywhere visible. The reason for the hash was actually to avoid collisions between multiple users with top-level folders of the same name. Here is a quick reaction to your suggestions:

1) Orion file system locations preserved user-chosen names. -> This would be possible. We currently support multiple files system "shapes" confirmed by server preference. We could conceivably support a new shape that matches the URL structure. The problem with changing the current mapping is that it breaks all the existing workspaces out there.

2) Orion exposes both user-facing and internal locations. -> No the whole goal here was to hide the internal server locations.

3) Orion provides a server setting that allows reverting locations to be hashed as pre-M2. -> Not possible. This was a massive rewrite on the server side to support this. Supporting multiple URL shapes turns out to be much harder than multiple disk layouts (option 1).

4) I implement my own file service that saves data in my own server. -> Yeah not very nice.

5) Orion provides support for project-wide validation. -> This is the right long term answer. I guess you are doing server side validation which is fine, but we really should be enabling client side multi-file validation. I know we have been saying we'll get to this for a year now without actually doing it.

Unfortunately in the short term we are really squeezed for getting fixes into our 1.0 release right now. I think 1) is the best short term option but I don't think I'll have time to investigate this.

John
Re: can no longer guess file system locations from user file locations [message #925492 is a reply to message #924827] Thu, 27 September 2012 19:31 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
Thanks for the detailed reply, John. I appreciate your constraints. I am happy to stick with M1 for the time being, until hopefully sometime post 1.0 we can have project-wide validation.

Quote:
I guess you are doing server side validation which is fine, but we really should be enabling client side multi-file validation


That is fine - whatever enables client-side validation will probably work for server-side validation as well.

Re: can no longer guess file system locations from user file locations [message #925855 is a reply to message #925492] Fri, 28 September 2012 04:44 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
I may end up reaching into the server.core metadata about users, workspaces, and projects and do the mapping myself. Somehow I missed those .prefs files when I scanned the workspace metadata at first.

Cheers,

Rafael
Re: can no longer guess file system locations from user file locations [message #925919 is a reply to message #925492] Fri, 28 September 2012 06:15 Go to previous message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
Somehow I missed those .prefs files when I scanned the workspace metadata at first. The following method maps from Orion user facing "file" paths to the local file system location:

public static IFileStore getSourcePath(IPath originalPath) {
    IFileStore rootInstanceDir = EFS.getLocalFileSystem().getStore(
            URI.create(Platform.getInstanceLocation().getURL().toString()));
    String userName = originalPath.segments()[0];
    String projectName = originalPath.segments()[1];
    IPath projectPath = originalPath.removeFirstSegments(2).makeAbsolute();
    IFileStore serverSettings = rootInstanceDir.getChild(".metadata/.plugins/org.eclipse.orion.server.core/.settings/");
    Properties workspaceProperties = readProperties(serverSettings.getChild("Workspaces.prefs"));
    Properties projectProperties = readProperties(serverSettings.getChild("Projects.prefs"));
    if (workspaceProperties != null && projectProperties != null)
        try {
            for (Iterator<JsonNode> it = ((ArrayNode) JsonHelper.parse(new StringReader((String) workspaceProperties.get(userName + "/Projects")))).iterator();it.hasNext();) {
                ObjectNode entry = (ObjectNode) it.next();
                String projectKey = entry.get("Id").getTextValue();
                if (projectName.equals(projectProperties.getProperty(projectKey + "/Name"))) {
                    String workspaceLocation = projectProperties.getProperty(projectKey + "/ContentLocation");
                    URI result = URI.create(workspaceLocation + projectPath);
                    return EFS.getLocalFileSystem().getStore(result);
                }
            }
        } catch (IOException e) {
            //
        }
    return null;
}

protected static Properties readProperties(IFileStore propertiesLocation) {
    try {
        Properties userPrefs = new Properties();
        userPrefs.load(new StringReader(FileUtils.readFileToString(propertiesLocation.toLocalFile(EFS.NONE, null))));
        return userPrefs;
    } catch (IOException e) {
        return null;
    } catch (CoreException e) {
        return null;
    }
}


I am not proud but it seems to work.

Cheers,

Rafael
Previous Topic:1.0 M2 - every menu opens a new tab
Next Topic:feedback from command-triggered long running operations
Goto Forum:
  


Current Time: Fri Apr 19 10:01:55 GMT 2024

Powered by FUDForum. Page generated in 0.01539 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top