Record samples

Basics

Example of uuid:

  • Using UUID -> "a66664a3-0e1d-4b03-9049-a2f4732a0802";

Suggested code sample

First, you must create the webservice object:

OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

Then should login using the method "login". You can access the "login" method from webservice object "ws" as is shown below:

ws.login(user, password);

Once you are logged with the webservices the session is keep in the webservice Object. Then you can use the other API method

At this point you can use all the Record methods from "record" class as is shown below:

ws.record.createRecord("ada67d44-b081-4b23-bdc1-74181cafbc5d", "PKI-100200", "new title", 0)

Methods

createRecord

Description:

MethodReturn valuesDescription

createRecord(String uuid, String name, String title, long nodeClass)

Record

Creates a new record and return as a result an object Record.

The parameters uuid should be any valid folder or record UUID.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Record;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            Record record = ws.record.createRecord("ada67d44-b081-4b23-bdc1-74181cafbc5d", "PKI-100200", "new title", 0);
            System.out.println(record);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

createRecordFromTemplate

Description:

MethodReturn valuesDescription

createRecordFromTemplate(String uuid, String dstPath, String language, boolean categories,
            boolean keywords, boolean propertyGroups, boolean notes, boolean wiki, Map<String, String> properties)

Record

Creates a new record from the template and returns an object Record.

The uuid parameter is the UUID value of the template record.

The dstPath is the destination path of the record.

The parameter language is optional.

When the template uses metadata groups to fill in fields, then these values are mandatory and must be set into properties parameter. 

For more information about Templates and metadata check: Creating templates.

Additional:

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

Example:

package com.openkm;

import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Record;
import com.openkm.sdk4j.impl.OKMWebservices;
import com.openkm.sdk4j.util.ISO8601;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            Map<String, String> properties = new HashMap<>();
            properties.put("okp:tpl.name", "Some name");
            Calendar cal = Calendar.getInstance();
            // Value must be converted to String ISO 8601 compliant
            properties.put("okp:tpl.bird_date", ISO8601.formatBasic(cal));
            properties.put("okp:tpl.language", "[ \"java\" ]");

            Record record = ws.record.createRecordFromTemplate("9fa9787e-d8b0-4ff7-905a-a89f0b228ec8", "/okm:root/test/record", "es", true, true, true, false, false, properties);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

}

getRecordProperties

Description:

MethodReturn valuesDescription

getRecordProperties(String uuid)

Record

Returns the record properties.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            System.out.println(ws.record.getRecordProperties("fbe2933e-b141-4557-ab7a-736820ecdb2e"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

deleteRecord

Description:

MethodReturn valuesDescription

deleteRecord(String uuid)

void

Deletes a record.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            ws.record.deleteRecord("fbe2933e-b141-4557-ab7a-736820ecdb2e");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

purgeRecord

Description:

MethodReturn valuesDescription

purgeRecord(String uuid)

void

The record is definetivelly removed from repository.

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

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

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            ws.record.purgeRecord("fbe2933e-b141-4557-ab7a-736820ecdb2e");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

renameRecord

Description:

MethodReturn valuesDescription

renameRecord(String uuid, String newName)

Record

Renames a record.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            ws.record.renameRecord("5489fc37-3eb7-43de-998c-319725ae0ca0", "new_name");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

moveRecord

Description:

MethodReturn valuesDescription

moveRecord(String uuid, String dstId)

void

Moves a record to a folder or record.

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

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            ws.record.moveRecord("5489fc37-3eb7-43de-998c-319725ae0ca0", "8599eab7-ae61-4628-8010-1103d6950c63");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

copyRecord

Description:

MethodReturn valuesDescription

copyRecord(String uuid, String dstId, String newName)

void

Copies a record to a folder or record.

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

When the parameter newName value is null, the record will preserve the same name.

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

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);                       
            ws.record.copyRecord("5489fc37-3eb7-43de-998c-319725ae0ca0", "8599eab7-ae61-4628-8010-1103d6950c63", "PKI-100200");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

isValidRecord

Description:

MethodReturn valuesDescription

isValidRecord(String uuid)

Boolean

Returns a boolean that indicate if the node is a record or not.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);                                   
            System.out.println("Is a record:" + ws.record.isValidRecord("5489fc37-3eb7-43de-998c-319725ae0ca0"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getRecordChildren

Description:

MethodReturn valuesDescription

getRecordChildren(String uuid)

List<Record>

Returns a list of all records which their parent is fldId

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

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Record;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            for (Record rec : ws.record.getRecordChildren("8599eab7-ae61-4628-8010-1103d6950c63")) {
                System.out.println(rec);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

lockRecord

Description:

MethodReturn valuesDescription

lockRecord(String uuid)

LockInfo

Locks a record and return an object with the Lock information

Only the user who locked the record is allowed to unlock.

A locked record can not be modified by other users.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            ws.record.lockRecord("5489fc37-3eb7-43de-998c-319725ae0ca0");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

unlockRecord

Description:

MethodReturn valuesDescription

unlockRecord(String uuid)

void

Unlock a locked record.

Only the user who locked the document is allowed to unlock.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            ws.record.unlockRecord("5489fc37-3eb7-43de-998c-319725ae0ca0");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

forceUnlockRecord

Description:

MethodReturn valuesDescription

forceUnlockRecord(String uuid)

void

Unlocks a locked record.

This method allows to unlock any locked record.

It is not mandatory to execute this action by the same user who previously executed the checkout lock action.

This action can only be done by a super user ( user with ROLE_ADMIN ).

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            ws.record.forceUnlockRecord("5489fc37-3eb7-43de-998c-319725ae0ca0");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

setRecordTitle

Description:

MethodReturn valuesDescription

setRecordTitle(String uuid, String title)

void

Sets a record title.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            ws.record.setRecordTitle("5489fc37-3eb7-43de-998c-319725ae0ca0", "some title");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getRecordPath

Description:

MethodReturn valuesDescription

getRecordPath(String uuid)

String

Converts a record UUID to a record path.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            System.out.println(ws.record.getRecordPath("5489fc37-3eb7-43de-998c-319725ae0ca0"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

setRecordNodeClass

Description:

MethodReturn valuesDescription

setRecordNodeClass(String uuid, long ncId)

void

Set the NodeClass.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long ncId = 2;
            ws.record.setRecordNodeClass("7ce1b4a8-4ade-4dce-8d7d-4e99a6cd368b", ncId);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

setRecordDispositionStage

Description:

MethodReturn valuesDescription

setRecordDispositionStage(String uuid, long stage)

void

Set the disposition stage

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long stage = 1;
            ws.record.setRecordDispositionStage("7ce1b4a8-4ade-4dce-8d7d-4e99a6cd368b", stage);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

setRecordDescription

Description:

MethodReturn valuesDescription

setRecordDescription(String uuid, String description)

void

Set a description.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            ws.record.setRecordDescription("7ce1b4a8-4ade-4dce-8d7d-4e99a6cd368b", "some description");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

extendedRecordCopy

Description:

MethodReturn valuesDescription

extendedRecordCopy(String uuid, String dstId, String newName, boolean categories, boolean keywords, boolean propertyGroups, boolean notes, boolean wiki, boolean security)

void

Copies a record with the associated data into some folder or record.

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

When parameter newName value is null, the record 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:

  • 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.
  • When the security parameter is true the original value of the security will be copied.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            ws.record.extendedRecordCopy("ada67d44-b081-4b23-bdc1-74181cafbc5d", "8599eab7-ae61-4628-8010-1103d6950c63",
                    "new name record", true, true, true, true, true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

createWizardRecord

Description:

MethodReturn valuesDescription

createWizardRecord(String uuid, String name, String title, long nodeClass)

WizardNode

Create a new record with wizard.

The parameters uuid should be any valid folder or record UUID.

The WizardNode contains a list of pending actions what should be done to complete the process of record creation. These might be:

  • Add keyword
  • Add Categories
  • Add Metadata

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.WizardNode;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            WizardNode wn = ws.record.createWizardRecord("1f323e88-64ee-4f57-91e2-9276f8c603f9", "PKI-100200", "new title", 0);
            System.out.print(wn);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

forceLockRecord

Description:

MethodReturn valuesDescription

forceLockRecord(String uuid)

LockInfo

Locks a record and returns an object with the Lock information.

This method allows to lock any record.

This action can only be done by a super user ( user with ROLE_ADMIN ).

In case exist a previous lock it will be replaced by a new one. When parent is locked you must apply the lock from parent.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.LockInfo;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);            
            LockInfo lockInfo = ws.record.forceLockRecord("1ec49da9-1746-4875-ae32-9281d7303a62");
            System.out.println("Author:" + lockInfo.getOwner());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}