OKMFolder

Basics

On almost methods you'll see parameter named "fldId". The value of this parameter can be some valid folder UUID or path.

Example of fldId:

  • Using UUID -> "c52f9ea0-0d6c-45da-bae4-d72b66f42da3";
  • Using path -> "/okm:root/test"

About the parameter named "dstId", the value of this parameter can be some valid folder UUID or path node.

Example of dstId:

  • Using UUID -> "c4455667-0d6c-45da-1234-d98564323e0";
  • Using path -> "/okm:root/folder2"

Also on all methods you'll see parameter named "token". When accessing application across SOAP the login process returns a token, what is used to identify the user on all the exposed methods. From default application execution context you must use "null" value what indicates to the application must use the "user session".

On special cases you might be "promoted as Administrator" using the "administrator token".

String systemToken = DbSessionManager.getInstance().getSystemToken();

Methods

create

Description:

MethodReturn valuesDescription

create(String token, Folder fld)

Folder

Creates a new folder and returns as a result an object Folder.

The variable path into the parameter fld, must be initializated. It indicates the folder path into OpenKM.

Folder fld = new Folder();
fld.setPath("/okm:root/test");

The other variables of the Folder ( fld ) will not take any effect on the folder creation.

We suggest using the method below to create the Folder Simply rather this one.

Example:

package com.openkm;

import com.openkm.api.OKMFolder;
import com.openkm.bean.Folder;

public class Test {
    public static void main(String[] args) {
        try {            
            Folder fld = new Folder();
            fld.setPath("/okm:root/test");
            OKMFolder.getInstance().create(null, fld);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

createSimple

Description:

MethodReturn valuesDescription

createSimple(String token, String fldPath)

Folder

Creates a new folder and returns as a result an object Folder.

Example:

package com.openkm;

import com.openkm.api.OKMFolder;

public class Test {
    public static void main(String[] args) {
        try {            
            String fldPath = "/okm:root/test";
            OKMFolder.getInstance().createSimple(null, fldPath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getProperties

Description:

MethodReturn valuesDescription

getProperties(String token, String fldId)

Folder

Return the folder properties.

Example:

package com.openkm;

import com.openkm.api.OKMFolder;
import com.openkm.bean.Folder;

public class Test {
    public static void main(String[] args) {
        try {            
            Folder fld = OKMFolder.getInstance().getProperties(null, "/okm:root/test");
            System.out.println(fld);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

delete

Description:

MethodReturn valuesDescription

delete(String token, String fldId)

void

Delete a folder.

Example:

package com.openkm;

import com.openkm.api.OKMFolder;

public class Test {
    public static void main(String[] args) {
        try {            
            OKMFolder.getInstance().delete(null, "/okm:root/test");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

purge

Description:

MethodReturn valuesDescription

purge(String token, String fldId)

void

The folder is definitely removed from the repository.

Usually you will purge folders into /okm:trash/userId - the personal trash user locations - but it is possible to directly purge any folder from the whole repository.

When a folder is purged, it will  only be able to be restored from a previously repository backup. The purge action removes the folder definitely from the repository.

Example:

package com.openkm;

import com.openkm.api.OKMFolder;

public class Test {
    public static void main(String[] args) {
        try {            
            OKMFolder.getInstance().purge(null, "/okm:root/test");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

rename

Description:

MethodReturn valuesDescription

rename(String token, String fldId, String newName)

Folder

Rename a folder.

Example:

package com.openkm;

import com.openkm.api.OKMFolder;

public class Test {
    public static void main(String[] args) {
        try {            
            OKMFolder.getInstance().rename(null, "/okm:root/test", "newname");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

move

Description:

MethodReturn valuesDescription

move(String token, String fldId, String dstId)

void

Moves folder into some folder.

The values of the dstId parameter should be a folder UUID or path.

Example:

package com.openkm;

import com.openkm.api.OKMFolder;

public class Test {
    public static void main(String[] args) {
        try {            
            OKMFolder.getInstance().move(null, "/okm:root/test", "/okm:root/move/destination");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

copy

Description:

MethodReturn valuesDescription

copy(String token, String fldId, String dstId)

void

Copies a folder into a folder.

The values of the dstId parameter should be a folder UUID or path.

Only the security grants are copied to destination, the metadata, keywords, etc. of the folder are not copied.

See "extendedCopy" method for this feature.

Example:

package com.openkm;

import com.openkm.api.OKMFolder;

public class Test {
    public static void main(String[] args) {
        try {            
            OKMFolder.getInstance().copy(null, "/okm:root/test", "/okm:root/move/destination");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

extendedCopy

Description:

MethodReturn valuesDescription

extendedCopy(String token, String fldId, String dstId, ExtendedAttributes extAttr)

void

Copies a folder with the associated data into some folder.

The values of the dstId parameter should be a folder UUID or path.

By default only the binary data and the security grants, the metadata, keywords, etc. of the folder are not copyed.

Additional extended attributes parameters:

  • When the category parameter is true the original values of the categories will be copied.
  • When the keywords parameter is true the original values of the keywords will be copied.
  • When the propertyGroups parameter is true the original values of the metadata groups will be copied.
  • When the notes parameter is true the original values of the notes will be copied.
  • When the wiki parameter is true the original values of the wiki will be copied.

Example:

package com.openkm;

import com.openkm.api.OKMFolder;
import com.openkm.bean.ExtendedAttributes;

public class Test {
    public static void main(String[] args) {
        try {            
            ExtendedAttributes extAttr = new ExtendedAttributes(); 
            extAttr.setKeywords(true);
            OKMFolder.getInstance().extendedCopy(null, "/okm:root/sample.pdf","/okm:root/test", extAttr);
            
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

extendedCopy

Description:

MethodReturn valuesDescription

extendedCopy(String token, String fldId, String dstId, ExtendedAttributes extAttr, String newName)

void

Copies a folder with the associated data into some folder.

The values of the dstId parameter should be a folder UUID or path.

When parameter newName value is null, folder will preservate the same name.

By default only the binary data and the security grants, the metadata, keywords, etc. of the folder are not copyed.

Additional extended attributes parameters:

  • When the category parameter is true the original values of the categories will be copied.
  • When the keywords parameter is true the original values of the keywords will be copied.
  • When the propertyGroups parameter is true the original values of the metadata groups will be copied.
  • When the notes parameter is true the original values of the notes will be copied.
  • When the wiki parameter is true the original values of the wiki will be copied.

Example:

package com.openkm;

import com.openkm.api.OKMFolder;
import com.openkm.bean.ExtendedAttributes;

public class Test {
    public static void main(String[] args) {
        try {            
            ExtendedAttributes extAttr = new ExtendedAttributes(); 
            extAttr.setKeywords(true);
            OKMFolder.getInstance().extendedCopy(null, "/okm:root/sample.pdf","/okm:root/test", extAttr, "new_name.pdf");
            
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getChilds

Description:

MethodReturn valuesDescription

getChilds(String token, String fldId)

List<Folder>

Returns a list of all folders which their parent is fldId.

The parameter fldId can be a folder node.

This method is deprecated in favour of getChildren method. We encourage do not using it, because on nearly future will be removed.

Example:

package com.openkm;

import com.openkm.api.OKMFolder;
import com.openkm.bean.Folder;

public class Test {
    public static void main(String[] args) {
        try {            
            for (Folder fld : OKMFolder.getInstance().getChilds(null, "/okm:root/test")) {
                System.out.println(fld);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getChildren

Description:

MethodReturn valuesDescription

getChildren(String token, String fldId)

List<Folder>

Returns a list of all folders which their parent is fldId.

The parameter fldId can be a folder node.

Example:

package com.openkm;

import com.openkm.api.OKMFolder;
import com.openkm.bean.Folder;

public class Test {
    public static void main(String[] args) {
        try {            
            for (Folder fld : OKMFolder.getInstance().getChildren(null, "/okm:root/test")) {
                System.out.println(fld);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getContentInfo

Description:

MethodReturn valuesDescription

getContentInfo(String token, String fldId)

ContentInfo

Return and object ContentInfo with information about folder.

The ContentInfo object retrives information about:

  • The number of folders into.
  • The number of documents into.
  • The number of mails into.
  • The size in bytes of all objects into the folder.

Example:

package com.openkm;

import com.openkm.api.OKMFolder;
import com.openkm.bean.ContentInfo;

public class Test {
    public static void main(String[] args) {
        try {            
            ContentInfo ci =  OKMFolder.getInstance().getContentInfo(null, "/okm:root/test");
            System.out.println(ci);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

isValid

Description:

MethodReturn valuesDescription

isValid(String token, String fldId)

boolean

Returns a boolean that indicates if the node is a folder or not.

Example:

package com.openkm;

import com.openkm.api.OKMFolder;

public class Test {
    public static void main(String[] args) {
        try {            
            boolean valid =  OKMFolder.getInstance().isValid(null, "/okm:root/test");
            System.out.println(valid);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getPath

Description:

MethodReturn valuesDescription

getPath(String token, String uuid)

String

Convert folder UUID to folder path.

Example:

package com.openkm;

import com.openkm.api.OKMFolder;

public class Test {
    public static void main(String[] args) {
        try {            
            String path =  OKMFolder.getInstance().getPath(null, "c52f9ea0-0d6c-45da-bae4-d72b66f42da3");
            System.out.println(path);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

createMissingFolders

Description:

MethodReturn valuesDescription

createMissingFolders(String token, String fldPath)

void

Create missing folders based on all the path nodes.

The method checks all subfolders and when detects some one is missing, it creates all missing subfolders from there.

Example:

package com.openkm;

import com.openkm.api.OKMFolder;

public class Test {
    public static void main(String[] args) {
        try {            
            OKMFolder.getInstance().createMissingFolders(null, "/okm:root/test/missing/from/here");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}