I want to access the reports repository like the designer from my own client. How can I do it?
Since version 14.x the designer use a JSON-RPC API to access the remote repository. See the Wikipedia for details to JSON-RPC.
The same API is used in version 15.x and 16.x. There is no warranty that this will work in future versions. Currently there is no plan to change this in the future.
System requirments:
- You need the plugins repository.zip and jsonrepository.zip in your server.
- The user need the system permission rights for “Remote Designer” or “Repository”. The names can vary between different versions.
URL: <server base url>/jsonrpc/repository
Structures:
- FolderDescription
- String name
- int rights
- int foldertype
- FileDescription
- String name
- long size
- long lastModified
- int rights
Methods:
All available methods of your version can be found in the enum com.inet.report.plugins.json.repository.shared.RepositoryMethods in the jsonrepository plugin.
The follow method documentation use a Java method declarartion like it will be used with a wrapper.
- Root
FolderDescription = Root()
- Folders
List<FolderDescription> = Folders(String parent)
- Folder
FolderDescription = Folder(String parent, String name)
- Files
List = Files(String parent)
- File
FileDescription = File(String parent, String name)
- CreateFolder
FolderDescription = CreateFolder(String parent, String name)
- CreateFile
FileDescription = CreateFile(String parent, String name)
- Rename
FileDescription/FolderDescription = Rename(String parent, String name)
- Delete
Boolean = Delete(String element)
-
Exists
Boolean = Exists(String element)
-
Thumbnail
ASCII-String = Thumbnail(String name)
- Keywords
List = Keywords(String name)
- SetKeywords
Boolean = SetKeywords(String name, String… keywords)
- Search
List = Search(String phrase)
- ServerVersion
String = ServerVersion()
- Save
Boolean = Save(String name, ASCII-String data)
- Load
ASCII-String = Load(String name)
Protocol Sample:
–> {“jsonrpc”: “2.0”, “method”: “Root”, “id”: 3}
<-- {“jsonrpc”: “2.0”, “result”: {“name”:“foo.rpt”,“rights”:0,“foldertype”:0}, “id”: 3}
Usage with JSON-RPC 2.0 library http://software.dzhuvinov.com/json-rpc-2.0-client.html
This library is very strict. You need the patched version 14.1.660 or higher.
Sample code:
import java.net.URL;
import com.thetransactioncompany.jsonrpc2.JSONRPC2Request;
import com.thetransactioncompany.jsonrpc2.JSONRPC2Response;
import com.thetransactioncompany.jsonrpc2.client.JSONRPC2Session;
public class JsonRpcTest {
public static void main( String[] args ) throws Exception { URL serverURL = new URL( "http://localhost:9000/jsonrpc/repository" );
JSONRPC2Session session = new JSONRPC2Session( serverURL ); JSONRPC2Request request = new JSONRPC2Request("Root", null); String[] contentTypes = {"application/binary-json", "application/error-json", "application/clearreport-json"}; session.getOptions().setAllowedResponseContentTypes(contentTypes); JSONRPC2Response response = session.send(request);
if (response.indicatesSuccess()) { System.out.println(response.getResult()); } else { System.out.println(response.getError().getMessage()); System.out.println(response.getError().getCode()); } }
}