CommentFileOperation.java 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Nextcloud Android client application
  3. *
  4. * @author Tobias Kaminsky
  5. * Copyright (C) 2018 Tobias Kaminsky
  6. * Copyright (C) 2018 Nextcloud GmbH.
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. package com.owncloud.android.operations;
  22. import com.owncloud.android.lib.common.OwnCloudClient;
  23. import com.owncloud.android.lib.common.operations.RemoteOperationResult;
  24. import com.owncloud.android.lib.common.utils.Log_OC;
  25. import com.owncloud.android.lib.resources.comments.CommentFileRemoteOperation;
  26. import com.owncloud.android.operations.common.SyncOperation;
  27. /**
  28. * Comment file
  29. */
  30. public class CommentFileOperation extends SyncOperation {
  31. private String message;
  32. private String fileId;
  33. private String userId;
  34. /**
  35. * Constructor
  36. *
  37. * @param message Comment to store
  38. * @param userId userId to access correct dav endpoint
  39. */
  40. public CommentFileOperation(String message, String fileId, String userId) {
  41. this.message = message;
  42. this.fileId = fileId;
  43. this.userId = userId;
  44. }
  45. /**
  46. * Performs the operation.
  47. *
  48. * @param client Client object to communicate with the remote ownCloud server.
  49. */
  50. @Override
  51. protected RemoteOperationResult run(OwnCloudClient client) {
  52. RemoteOperationResult result = new CommentFileRemoteOperation(message, fileId, userId).execute(client, true);
  53. if (!result.isSuccess()) {
  54. Log_OC.e(this, "File with Id " + fileId + " could not be commented");
  55. }
  56. return result;
  57. }
  58. }