Skip to content
Other versions

Loading…

Folder samples

On most methods you’ll see parameter named “fldId”. The value of this parameter can be some valid folder UUID or path.

Description:

Method Return values Description
createFolder(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");

Example:

package com.openkm;
import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Folder;
public class Test {
public static void main(String[] args) {
String host = "http://localhost:8080/OpenKM";
String username = "okmAdmin";
String password = "admin";
OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try {
Folder fld = new Folder();
fld.setPath("/okm:root/test");
ws.createFolder(fld);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
createFolderSimple(String fldPath) Folder Creates a new folder and returns as a result an object Folder.

Example:

package com.openkm;
import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Folder;
public class Test {
public static void main(String[] args) {
String host = "http://localhost:8080/OpenKM";
String username = "okmAdmin";
String password = "admin";
OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try {
ws.createFolderSimple("/okm:root/test");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getFolderProperties(String fldId) Folder Return the folder properties.

Example:

package com.openkm;
import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test {
public static void main(String[] args) {
String host = "http://localhost:8080/OpenKM";
String username = "okmAdmin";
String password = "admin";
OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try {
System.out.println(ws.getFolderProperties("/okm:root/test"));
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
deleteFolder(String fldId) void Delete a folder.

Example:

package com.openkm;
import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test {
public static void main(String[] args) {
String host = "http://localhost:8080/OpenKM";
String username = "okmAdmin";
String password = "admin";
OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try {
ws.deleteFolder("/okm:root/test");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
renameFolder(String fldId, String newName) void Rename a folder.

Example:

package com.openkm;
import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test {
public static void main(String[] args) {
String host = "http://localhost:8080/OpenKM";
String username = "okmAdmin";
String password = "admin";
OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try {
// Exists folder /okm:root/test
ws.renameFolder("/okm:root/test","renamedFolder");
// Folder has renamed to /okm:root/renamedFolder
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
moveFolder(String fldId, String dstId) void Moves folder into some folder or record.

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

Example:

package com.openkm;
import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test {
public static void main(String[] args) {
String host = "http://localhost:8080/OpenKM";
String username = "okmAdmin";
String password = "admin";
OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try {
// Exists folder /okm:root/test
ws.moveFolder("/okm:root/test","/okm:root/tmp");
// Folder has moved to /okm:root/tmp/test
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getFolderChildren(String fldId) List Returns a list of all folders which their parent is fldId.

The parameter fldId can be a folder or a record node.

Example:

package com.openkm;
import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Folder;
public class Test {
public static void main(String[] args) {
String host = "http://localhost:8080/OpenKM";
String username = "okmAdmin";
String password = "admin";
OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try {
for (Folder fld : ws.getFolderChildren("/okm:root")) {
System.out.println(fld);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
isValidFolder(String fldId) Boolean Returns a boolean that indicates if the node is a folder or not.

Example:

package com.openkm;
import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test {
public static void main(String[] args) {
String host = "http://localhost:8080/OpenKM";
String username = "okmAdmin";
String password = "admin";
OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try {
// Return false
ws.isValidFolder("/okm:root/logo.png");
// Return true
ws.isValidFolder("/okm:root");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getFolderPath(String uuid) String Convert folder UUID to folder path.

Example:

package com.openkm;
import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test {
public static void main(String[] args) {
String host = "http://localhost:8080/OpenKM";
String username = "okmAdmin";
String password = "admin";
OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try {
System.out.println(ws.getFolderPath("f123a950-0329-4d62-8328-0ff500fd42db"));
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
copyFolder(String fldId, String dstId, String newName) void Copies a folder into a folder or record.

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

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

Example:

package com.openkm;
import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test {
public static void main(String[] args) {
String host = "http://localhost:8080/OpenKM";
String username = "okmAdmin";
String password = "admin";
OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try {
ws.copyFolder("/okm:root/test","/okm:root/temp","new_name");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
extendedFolderCopy(String fldId, String dstId, boolean categories, boolean keywords, boolean propertyGroups, boolean notes, boolean wiki) void Copies a folder with the associated data into some folder or record.

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

Example:

package com.openkm;
import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test {
public static void main(String[] args) {
String host = "http://localhost:8080/OpenKM";
String username = "okmAdmin";
String password = "admin";
OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try {
ws.extendedFolderCopy("/okm:root/test", "/okm:root/tmp", true, true, true, true, true);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getContentInfo(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 records into.
  • The number of mails into.
  • The size in bytes of all objects into the folder.

Example:

package com.openkm;
import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test {
public static void main(String[] args) {
String host = "http://localhost:8080/OpenKM";
String username = "okmAdmin";
String password = "admin";
OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try {
System.out.println(ws.getContentInfo("/okm:root/test"));
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
purgeFolder(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.

Example:

package com.openkm;
import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test {
public static void main(String[] args) {
String host = "http://localhost:8080/OpenKM";
String username = "okmAdmin";
String password = "admin";
OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try {
ws.purgeFolder("/okm:trash/okmAdmin/test");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
setStyle(String fldId, long styleId) void Set the folder style.

Example:

package com.openkm;
import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test {
public static void main(String[] args) {
String host = "http://localhost:8080/OpenKM";
String username = "okmAdmin";
String password = "admin";
OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try {
ws.setStyle("/okm:trash/okmAdmin/test", 1);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
createMissingFolders(String fldPath) void Create missing folders.

Example:

package com.openkm;
import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test {
public static void main(String[] args) {
String host = "http://localhost:8080/OpenKM";
String username = "okmAdmin";
String password = "admin";
OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try {
ws.createMissingFolders("/okm:root/missingfld1/missingfld2/missingfld3");
} catch (Exception e) {
e.printStackTrace();
}
}
}