• OKMFOLDER To Copy a Folder With All Its contents to OPENKM

  • Do you want to create a native client or integrate with third party applications: webservices are the solution.
Do you want to create a native client or integrate with third party applications: webservices are the solution.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #28257  by YusCristiano10
 
Hello everybody, I'am new at forum, but in the past I have read a lot of topics very interesting, I Congratulate you and go ahead.
In this moment i have a little problem. I am doing a proyect and i have to copy a folder to OpenKm Repository from a path in my pc for example(C:\\Users\\hello), but I want to copy this folder with all its contents, sub-folders, documents (whathever type), and the contents of its sub-folders etc... I developed a software on Netbeans(Java) and I am trying to consume the webservice OpenKM. I read about topics that could help me to Authenticate (OKMAuth), and copy a document from a path (OKMDocument), but its looks like you dont have any example of how I can create a Folder or in this case copy a folder from a path (OKMFolder) or may be I haven't found it.

I have this example: to copy a Document from my path to OpenKM Repository. It works pretty good.
Code: Select all
String file = "C:\\Users\\usuario\\Documents\\archive\\hello.txt";
        try
        {
            OKMAuthService oKMAuthService = new OKMAuthService();
            OKMAuth oKMAuth = oKMAuthService.getOKMAuthPort();
            OKMDocumentService oKMDocumentService = new OKMDocumentService();
            OKMDocument oKMDocument = oKMDocumentService.getOKMDocumentPort();
            
            
            //Login
            String token = oKMAuth.login("okmAdmin", "admin");
            System.out.println("Token: "+token);
            
            Document doc = new Document();
            doc.setPath("/okm:root/"+file.substring(file.lastIndexOf('\\')));
            FileInputStream fis = new FileInputStream(file);
            byte[] content = new byte[fis.available()];
            int size = fis.read(content);
            System.out.println("File Size: "+size);
            fis.close();
            
            Document newDoc = oKMDocument.create(token, doc, content);
            System.out.println("[DOCUMENT] PATH: "+newDoc.getPath()+", Author: "+newDoc.getAuthor()+
                    ", Size: "+newDoc.getActualVersion().getSize());
            
           
            //Logout
            oKMAuth.logout(token);
            
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
But I think that it's different to create or copy a folder. because if I try to use this code to create a folder it doesn't work. (Obviously I addapt the code to a folder)

These are my question:

1. Can you provide me an example to create a folder on OpenKM Repository using java Client. (Consuming the webservice OKMFolder)?
2. Can I copy a Folder with all its contents from a path in Windows to OpenKMRepository or I can only copy a folder empty?

This are my System information:
--OpenKM-5.0.3_JBoss-4.2.3GA (I am using this one, beacuse I found it implemented in jboss, if you can help me to get an actual version of OpenKM implemented at Jboss that would be helpful)
--Google Chrome and Mozilla Firefox
--Windows 7 Ultimate
--Netbeans IDE 7.4 (Java)
--jdk1.6.0_45 and jre 6

Please help me. I really need to do this work. because I have to give it very soon. Thank you very much!!
 #28269  by jllort
 
- First of all you got really older OpenKM version 5.0.3 ( this is actually not supported ). Will be hard upgrade to 5.1.X branch and after it update to 6.2 but I suggest you do it ( backup all before doing it ).
- About this kind of import I would like to understand better the scenario, here some questions :
1- import data is always on same network or openkm folder ?
2- after data imported must be removed
3- must be imported on real time or can be imported one time per day ( for example at night )

I do this questions because we want suggest you the best and easy way for doing it.
 #28281  by YusCristiano10
 
Thank you very much Jllort I really want to receive your response. I have this work and I have to give it very soon, no more than a week. I really going to appreciate your help. Thanks for response.

I know that I am using an older version (OpenKM 5.0.3), The situation is that was the only one that I found implemented on jboss 4.2.3 GA, If you can provide me a link where I can download a newer version that can be compatible, Iam going to thank you. I would prefer a newer version of OpenKM implemented on jboss 4.2.3GA or newer one. because I can understand better the use of openKm on jboss. (I need a community version).

This is my scenario:

1) I have in my local disk this folder (C:\\users\\hola), This folder contains sub-folders and documents (.doc,.txt,.pdf,.jpg,.tiff, etc...), and the sub-folders contains other sub-folders and more documents of this kind or others.
2) This data is stored on an unsafely place, whatever person can access to this data, manipulate it, also it is ocupying a lot of storage. This is the situation that i want to avoid it.
3) I chose OpenKM to solve this problem, because I think that it is the better option at dms area.
4) I chose mySQL to use it, as an OpenKM Repository. I think that all the data Openkm will be save on mySQL Database, where anybody can't access.
5) I develop a Software application on netbeans(Java Client) to apply the OpenKM webservice and it can be possible do this work.


What is my problem?
1) I have used OKMAuth to authenticate.
2) I have used OKMDocument to create a document (What I really need is to copy a document from a path in my local disk (C:\\users\\hola.tiff) to openKM Repository)
3) I haven't used OKMFolder to create a folder because I dont have any code to do this part. May be you can provide me a code to create a Folder on the OpenKM Repository (With java client).

Important:
I don't really need to create a new folder with OKMFolder, I need to "Copy" a folder from my path on (C:\\users\\hola) to my OpenKMRepository /okm:root/hola.

If you can provide me a code to do this I really appreciate it.

WHAT IS THE MOST IMPORTANT:

I have this path in my local disk(C:\\Users\hola) the folder "hola" has three folders more (hola1, hola2, hola3) and three documents (hola.tiff, hola.txt, hola.doc). The sub-folder hola2 has three documents and one folder more (hola2.pdf, hola2.jpg, hola2.tiff, hola21). I need to copy the folder "hola" With all its contents from my pc to openKM. I need that on my OpenKM Repository is create the same structure.

example:

OPENKM
/okm:root/
hola
hola1
hola2
hola2.pdf, hola2.jpg, hola2.tiff
hola21
hola3
hola.tiff
hola.txt
hola.doc

I apologize for being so detailed, I just want you to understand me well.

Answer to your question:

1. Yes, all data will always be at same network (from my pc1 (C:\\users\\hola) to my pc2 OpenKM(on jboss(localhost:8080)) at the same network.
2. I just want to copy the data, not removing anything ( from my path (C:\\users\\hola) a exactly copy to OpenKM(/okm:root/hola)).
3. My folder is very heavy, I need to copy all that information, if it can be in the first time that would be awesome. but if it is not the case, I want to copy a subfolder with a lot more data (copy sub-folder by sub-folder).

May be you can help me
1) Can I use for this my current and old version OpenKM 5.0.3, otherwise I would like to have a link to download a newer version of OpenKM implemented on jboss.
2) I would like to have a code for create folders on OpenKM repository using Webservices Java Client.
3) I would like to have a code for copy folders from a path (C:\\users\\hola) to OpenKM repository (/okm:root/hola) using webservice java Client.
4) I have an Idea to copy a folder with all it's contents (Using recursion). Actually I have a code for doing that. But I dont have any idea how to implement this code using webservice OpenKM. May be you can provide me a code to do this work, copy a folder with all its contents (sub-folders, documents, and sub-folders contents) from my pc to OpenKM Repository.


Thanks for your help Jllort. I really need it, and am gonna appreciate your support.
I apologize to you for such a long post, but i really needed to explain you all my scenario.
GOD BLESS YOU!!!
 #28304  by jllort
 
I supposed you only want to import files only one time ? is right ? otherside will be a problem with existing files already imported and newer what can not be separated from existing in openkm if you want to take control from webservices or scripting and should control error when document exists or control is exists with some api calls.

If you want to import files from your server, the easiest is use OpenKM import utility http://wiki.openkm.com/index.php/Repository_import Do not check any checkbox and all data will be imported including subfolders if document or folder already exists into your openkm you will be adviced but will not be overwritten. I think this is the easiest. I suggest do a backup before doing anything.

From version 5.1.11 we've removed jboss and moved to tomcat ( best performance with less resources ).
 #28310  by YusCristiano10
 
OK! I understand Jllort and thank you very much!

The first time I want to copy folder with subfolders and documents unique. but in the future may be I can get a webservice to overwrite or I dont know get a version?

but this is the issue: I know that it is easier using the tools from OpenKM for importing all data, but that I really need it is hide all the process for the user, So that in this way the user doesn't know that OpenKM it's storing the data, that is the reason which I want to use WebServices.

What I need to know?
1) There are any way to copy a Folder from a path in windows (C:\\hola) with all its content, to openKM Repository using WebServices?
(I think that should be a combination between OKMFolder and OKMDocument Webservices).
Remember I am using a Software Application created in Netbeans Java.
2) Can you provide me a code to copy a Folder from a path in windows to OpenKM Repository using OKMFolder web service? I found an example but it is to copy a Document from a path in windows to OpenKM Repository, I need exactly do the same thing but for Folders instead of Documents.
Code: Select all
public static void main (String [] args)
    {
        String file = "C:\\Users\\RAMIREZ\\Documents\\ITIC\\descargar iso S.O..txt";
        try
        {
            OKMAuthService oKMAuthService = new OKMAuthService();
            OKMAuth oKMAuth = oKMAuthService.getOKMAuthPort();
            OKMDocumentService oKMDocumentService = new OKMDocumentService();
            OKMDocument oKMDocument = oKMDocumentService.getOKMDocumentPort();
            
            
            //Login
            String token = oKMAuth.login("okmAdmin", "admin");
            System.out.println("Token: "+token);
            
            Document doc = new Document();
            doc.setPath("/okm:root/"+file.substring(file.lastIndexOf('\\')));
            FileInputStream fis = new FileInputStream(file);
            byte[] content = new byte[fis.available()];
            int size = fis.read(content);
            System.out.println("File Size: "+size);
            fis.close();
            
            Document newDoc = oKMDocument.create(token, doc, content);
            System.out.println("[DOCUMENT] PATH: "+newDoc.getPath()+", Author: "+newDoc.getAuthor()+
                    ", Size: "+newDoc.getActualVersion().getSize());
            
           
            //Logout
            oKMAuth.logout(token);
            
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
    
}
If you can help me I go to thank you so much!

About the version of Openkm dont worry! I get OpenKM 6.2.2 Tomcat bundle http://sourceforge.net/projects/openkm/files/6.2/ and I achieved connect with Mysql http://wiki.openkm.com/index.php/MySQL_-_OpenKM_6.2.
I am using this one already.

I hope that you can understand my question, because that helpme to solve my little problem. I only need to know how I can copy a folder with all its content to OpenKM from a path in windows and I gonna finish my project.
 #28324  by jllort
 
There's no high level copy entire folder from file system to openkm. Must recursivelly iterate into folder and subfolders.

Basically the document example is similar to folder. Here http://wiki.openkm.com/index.php/Webser ... OpenKM_6.2 you got http://wiki.openkm.com/index.php/OKMFolder and should be interested in create(String token, Folder fld)

In Fld is only necessary set the complete openkm path, nothing else; I'm not sure if in actual community version there's also a createSimple method in wiki I've not seen ( after generate jar if you got this method use it ).
 #28327  by YusCristiano10
 
Ohhh thank you so much for your help Jllort.

One question more:

Do you meant that there is no way to copy a folder with all its content to OpenKM using webservice?
Of that way I have to create a folder first, then a subfolder into that folder, copy a documents one by one, and copy a document into the subfolder one by one, sorry the issue is that that way its a very tedious way. I thought that I could to copy the folder with all its content from the first time.

I am using Java Client (Netbeans), I thought that may be I could join Java code with Webservice OpenKM (OKMFolder, OKMDocument) and may be do that I need.

If there is any way to do it, I appreciate your help, If it's not possible, the same way I appreciate and thank all your help.

GOD bless you!!!
 #28332  by jllort
 
You can do this kind of action with webservices, but does not exists a method that reply contents from local content to remote openkm. You need to iterate recursivelly folders, subfolders and documents and step by step reply into openkm usign create folder and create documents methods in webservices api.

I suggest also create a log file for this kind of operation.

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.