use of com.owncloud.android.utils.NextcloudServer in project android by nextcloud.
the class ChooseRichDocumentsTemplateDialogFragment method newInstance.
// will be removed in favor of generic direct editing
@NextcloudServer(max = 18)
public static ChooseRichDocumentsTemplateDialogFragment newInstance(OCFile parentFolder, Type type) {
ChooseRichDocumentsTemplateDialogFragment frag = new ChooseRichDocumentsTemplateDialogFragment();
Bundle args = new Bundle();
args.putParcelable(ARG_PARENT_FOLDER, parentFolder);
args.putString(ARG_TYPE, type.name());
frag.setArguments(args);
return frag;
}
use of com.owncloud.android.utils.NextcloudServer in project android by nextcloud.
the class RichDocumentsUrlOperation method run.
@NextcloudServer(max = 18)
protected RemoteOperationResult run(OwnCloudClient client) {
RemoteOperationResult result;
Utf8PostMethod postMethod = null;
try {
postMethod = new Utf8PostMethod(client.getBaseUri() + DOCUMENT_URL + JSON_FORMAT);
postMethod.setParameter(FILE_ID, fileID);
// remote request
postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
int status = client.executeMethod(postMethod, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT);
if (status == HttpStatus.SC_OK) {
String response = postMethod.getResponseBodyAsString();
// Parse the response
JSONObject respJSON = new JSONObject(response);
String url = respJSON.getJSONObject(NODE_OCS).getJSONObject(NODE_DATA).getString(NODE_URL);
result = new RemoteOperationResult(true, postMethod);
result.setSingleData(url);
} else {
result = new RemoteOperationResult(false, postMethod);
client.exhaustResponse(postMethod.getResponseBodyAsStream());
}
} catch (Exception e) {
result = new RemoteOperationResult(e);
Log_OC.e(TAG, "Get rich document url for file with id " + fileID + " failed: " + result.getLogMessage(), result.getException());
} finally {
if (postMethod != null) {
postMethod.releaseConnection();
}
}
return result;
}
Aggregations