cancel
Showing results for 
Search instead for 
Did you mean: 

Using JS api to import filesystem permissions : JS File API ?

ermantis
Champ in-the-making
Champ in-the-making
Hello everyone,
I'm trying to import a filesystem's permissions into alfresco, so it fits my current configuration.
To do that, i'm planning to use the javascript API. To do this, I want to get access to my filesystem using the File API implemented in javascript.
Thing is, it doesn't seem to be implemented ?
<!–break–>
Here is the base I use to check if it could work on alfresco :


// Check for the various File API support.
if (window.File && window.FileReader && window.FileList && window.Blob) {
  // Great success! All the File APIs are supported.
   alert("OK!");
} else {
  alert('The File APIs are not fully supported in this browser.');
}


This turns me that error :


org.alfresco.error.AlfrescoRuntimeException: 01181160 Error during command servlet processing: 01181159 Failed to execute script 'workspace://SpacesStore/b08ea900-d60c-48b1-bd62-a240a2a2c4e9': 01181158 ReferenceError: "window" n'est pas défini (workspace://SpacesStore/b08ea900-d60c-48b1-bd62-a240a2a2c4e9#3)
causé par :
org.alfresco.scripts.ScriptException: 01181159 Failed to execute script 'workspace://SpacesStore/b08ea900-d60c-48b1-bd62-a240a2a2c4e9': 01181158 ReferenceError: "window" n'est pas défini (workspace://SpacesStore/b08ea900-d60c-48b1-bd62-a240a2a2c4e9#3)
causé par :
org.alfresco.error.AlfrescoRuntimeException: 01181158 ReferenceError: "window" n'est pas défini (workspace://SpacesStore/b08ea900-d60c-48b1-bd62-a240a2a2c4e9#3)
causé par :
org.mozilla.javascript.EcmaError: ReferenceError: "window" n'est pas défini (workspace://SpacesStore/b08ea900-d60c-48b1-bd62-a240a2a2c4e9#3)


It's french, but the main error in english would be : "ReferenceError : "window" is not defined".

Sooo… what ? I think i'm missing something, but it seems like the script has to get through some alfresco's compilation or something, so it doesn't successfully brings up the "window" object that is supposed to be managed by the web browser.
Am I right ? Is there any workaround ? Should I drop javascript and try something else ?
Thanks in advance !
5 REPLIES 5

mrogers
Star Contributor
Star Contributor
If its server side alfresco java script then there is no browser or window.

ermantis
Champ in-the-making
Champ in-the-making
Well, I put the script in my Data Dictionnary / Scripts, and execute it via the URL, so… not sure, but I guess it is server side JS…
So, how do i call my function ? How do I explore my FS ? Or how do I get access to FS permission ?

mrogers
Star Contributor
Star Contributor
It would be a potential security hole if you could do what you are trying to do - so not its not possible with Java Script.  

You may like to look at the bulk file system import tool tool which uses the java API to import files.

ermantis
Champ in-the-making
Champ in-the-making
I don't want to import files, I want to import their permissions, and Bulk FS doesn't manage to do that… Any other way to import permissions, then ?

mrogers
Star Contributor
Star Contributor
No.    There's no way to "import" permissions.   However there are various permissions APIs.

I gave the example of the BFSIT since its an example of reading a filesystem and updating an alfresco repository.    Dealing with permissions is similar although you would need to work out how the access control maps bewtween a bare filesystem and alfresco.