### Sever Side Javascript Helpers Kitchen Sink

- openForum
- external
- file
- js

### Documentation for openForum

string openForum.getVersion()

string openForum.wikiToTitleName( {string title} )

string openForum.findStoreKeys( {string keyMatchRegex} )

void openForum.storeValue( {string key} , {string value} )

string openForum.retrieveValue( {string key} )

void openForum.storeObject( {string key} , {object} )

object openForum.retrieveObject( {string key} )

object openForum.removeObject( {string key} )

void openForum.refreshPage( {string pageName} )

void openForum.postMessageToQueue( {string queueName} , {string message} )

integer openForum.getTimeStamp()

boolean openForum.rebuild( {boolean forceBuildNow} )

boolean openForum.rebuild()

string openForum.getDateTimeStamp()

string openForum.getDateTimeStamp( {string pageName} )

void openForum.addJournalEntry( {string journalEntry} )

boolean openForum.pageExists( {string pageName} )

string openForum.buildPage( {string pageName} , {string pageSource} )

string openForum.buildPage( {string pageName} , {string pageSource} , {boolean isWikiData} )

string openForum.buildPage( {string pageName}, {boolean buildRefersTo} )

string openForum.buildPage( {string pageName} )

string openForum.renderWikiData( {string name} , {string data} )

JavascriptEngine openForum.getJavascriptEngine()

string openForum.titleToWikiName( {string title} )

void openForum.deletePage( {string pageName} )

void openForum.deleteAttachment( {string pageName} , {string fileName} )

void openForum.copyPage( {string pageName} , {string fileName} , {string listPageName} )

void openForum.addToListPage( {string listPageName}, {string pageName} )

Deprecated - Use JavascriptFileHelper.saveAttachment

void openForum.saveAsAttachment( {string pageName} , {string fileName} , {string data} , {string user} )

TODO

    string[][] openForum.getPageAsList( {string pageName} )

void openForum.setHomePage( {string pageName} )

string openForum.generateUniqueId()

void openForum.revert( {string pageName} , {string version} )

void openForum.signOut( {transaction} )

void openForum.cleanUpQueues()

boolean openForum.signIn( {transaction} )

string openForum.validateWikiTitle( {string title} )

Map openForum.getPageAsTable( {string pageName} )

string openForum.getMessagesSince( {string queueName} , {string time} )

string openForum.createQueue() Edit http://open-forum.onestonesoup.org/OpenForum/Editor?pageName=/OpenForum/Documentation/OpenForumServerSideJavascript&fileName=openForum.page.content

### Documentation for external

Retrieves a url as a file attached to a page

void external.getURLAsFile( {string url} , {string user} , {string password} , {string pageName} , {string fileName} )

Retrieves a url as a file attached to a page using Http authentication to sign in

void external.getURLAsFile( {string url} , {string pageName} , {string fileName} )

Post data to a url using Http authentication to sign in

string external.postURLAsString( {string url} , {string user} , {string password} , {string data} )

Post data to a url

string external.postURLAsString( {string url} , {string data} )

Retrieves a url as a string using Http authentication to sign in

string external.getURLAsString( {string url} , {string user} , {string password} )

Retrieves a url as a string

string external.getURLAsString( {string url} ) Edit http://open-forum.onestonesoup.org/OpenForum/Editor?pageName=/OpenForum/Documentation/OpenForumServerSideJavascript&fileName=external.page.content

### Documentation for file

Delete a file attached to a page without backing it up in history

boolean file.deleteAttachmentNoBackup( {string pageName} , {string fileName} )

Append data to file

void file.appendToPageSource( {string pageName}, {string dataToAppend})

Get the time since a file's last modification

integer file.getAttachmentTimestamp( {string pageName} , {string fileName} )

string file.getAttachment( {string pageName} , {string fileName} , {boolean resolveLinks} )

string file.getAttachment( {string pageName} , {string fileName} )

boolean file.pageExists( {string pageName} )

string file.getPageInheritedFileAsString( {string pageName} , {string fileName} )

void file.appendStringToFile( {string pageName} , {string fileName} , {string dataToAppend} )

void file.copyAttachment( {string fromPageName} , {string fromFileName} , {string toPageName} , {string toFileName} )

boolean file.attachmentExists( {string pageName} , {string fileName} )

integer file.getAttachmentSize( {string pageName} , {string fileName} )

InputStream file.getAttachmentInputStream( {string pageName} , {string fileName} )

string file.getPageInheritedFilePath( {string pageName} , {string fileName} )

void file.zipPage( {string pageName} )

OutputStream file.getAttachmentOutputStream( {string pageName} , {string fileName} )

void file.saveAttachment( {string pageName} , {string fileName} , {string data} )

void file.saveAttachmentNoBackup( {string pageName} , {string fileName} , {string dataToAppend} )

void file.unZipAttachment( {string pageName} , {string fileName} )

void file.appendStringToFileNoBackup( {string pageName} , {string fileName} , {string dataToAppend} )

Map file.getAttachmentsForPage( {string pageName} ) Example:

    var attachments=[];
    var pageName = "/Sandbox";
    var matching = ".*"; //Regex include all

    var list = file.getAttachmentsForPage( pageName );
    if(pageName.charAt(0)!='/')
    {
      pageName = "/"+pageName;
    }

    var iterator= list.keySet().iterator();
    while(iterator.hasNext())
    {
      var key = ""+iterator.next();
      var item;
      if(key.charAt(0)==='+') { // ignore sub pages
        continue;
      } else if(matching!==null && key.search( ""+matching )==-1 ) {
        continue;
      } else {
        item = key;
      }

      attachments.push( {pageName: pageName, fileName: item} );

    }

Edit http://open-forum.onestonesoup.org/OpenForum/Editor?pageName=/OpenForum/Documentation/OpenForumServerSideJavascript&fileName=file.page.content

### Documentation for js

void js.refreshJarManager()

object js.loadObject( {string pageName} , {string fileName} )

StringBuffer js.getStringBuffer()

fileName is used as a reference in error messages

void js.startJavascript( {string fileName} , {string script} )

object js.getApi( {string pageName} )

string js.generateMD5( {string data} )

object js.getObject( {string pageName} , {string fileName} )

void js.sleep( {integer millisecondsToSleep} ) Edit http://open-forum.onestonesoup.org/OpenForum/Editor?pageName=/OpenForum/Documentation/OpenForumServerSideJavascript&fileName=js.page.content

## An error has occurred.

{{OpenForum.errorMessage}}

See technical details

×

## Error details.

{{OpenForum.error}}

×

## {{OpenForum.alert.title}}

{{OpenForum.alert.message}}

×