Erwin Müller Blog

Simple REST Library

simpelrest-logo
  • Update 28/02/2016

Introduction

The library provides a high level API to the REST interfaces of various services.


License

The simpleREST library is released under the GNU Lesser General Public License LGPLv3 license

Owncloud OCS

Overview

Access to the Owncloud OCS REST API functions,

status,
requests the status of the Owncloud server;
upload,
uploads a file to the Owncloud server;
shares,
retrieves information about shares;
create share,
creates a new share;

OwncloudStatus

Requests the status of the Owncloud server. Use the factory OwncloudOcsStatusFactory to create the request and call the call() method to do the request. The factory require the following arguments.

  • OwncloudOcsStatusFactory#create(OwncloudAccount account)
  • OwncloudOcsStatusFactory#create(OwncloudAccount account,CloseableHttpClient httpClient)
account,
the Owncloud account;
httpClient,
optionally, the pooled client;

On success, the following information is returned.

getInstalled(),
true if the server is installed;
getVersionString(),
the version of the server;
getVersion(),
the version of the server;
getEdition(),
the edition of the server.

OwncloudUploadFile

Use the factory OwncloudOcsUploadFileFactory to create the request and call the call() method to do the request to upload the file. The factory require the following arguments.

  • OwncloudOcsUploadFileFactory#create(OwncloudAccount account, File file, String remotePath,ContentType contentType)
  • OwncloudOcsUploadFileFactory#create(OwncloudAccount account, File file, String remotePath,ContentType contentType, CloseableHttpClient httpClient)
account,
the Owncloud account;
file,
the file to upload;
remotePath
the destination path;
contentType
the content type of the file;
httpClient,
optionally, the pooled client;

Optionally the following parameters can be set.

setRequiredEtag()
sets the e-tag;

OwncloudShares

Use the factory OwncloudOcsSharesFactory to create the request and call the call() method to do the request to retrieve information about shares. The factory require the following arguments.

  • OwncloudOcsSharesFactory#create(OwncloudAccount account)
  • OwncloudOcsSharesFactory#create(OwncloudAccount account, CloseableHttpClient httpClient)
account,
the Owncloud account;
httpClient,
optionally, the pooled client;

Optionally the following parameters can be set.

setPath()
sets path of the folder or file;
setReshares()
sets to true to return re-shares;
setSubfiles()
sets to true to return sub-files;

On success, the SharesMessage information is returned containing the ShareData for each share.

OwncloudCreateShare

Use the factory OwncloudOcsCreateShareFactory to create the request and call the call() method to do the request and to create the share. The factory require the following arguments.

  • OwncloudOcsCreateShareFactory#create(OwncloudAccount account, String path, ShareType type, String shareWith, Boolean publicUpload, String password, Integer permissions)
  • OwncloudOcsCreateShareFactory#create(OwncloudAccount account, String path, ShareType type, String shareWith, Boolean publicUpload, String password, Integer permissions, CloseableHttpClient httpClient)
account,
the Owncloud account;
path,
the path to the folder or file;
type,
type of the share;
shareWith,
the user or group name, can be null;
publicUpload,
set to true to allow public upload, can be null;
password,
set the password of the share, can be null;
permissions,
the permissions of the share, can be null;
httpClient,
optionally, the pooled client;

On success, the ShareResultMessage information is returned containing the ShareResult of the share.

Leave a Reply