GetCapabilitiesOperarion.java 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * ownCloud Android client application
  3. *
  4. * @author masensio
  5. * Copyright (C) 2015 ownCloud Inc.
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2,
  9. * as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. package com.owncloud.android.operations;
  21. import com.owncloud.android.lib.common.OwnCloudClient;
  22. import com.owncloud.android.lib.common.operations.RemoteOperationResult;
  23. import com.owncloud.android.lib.resources.status.GetRemoteCapabilitiesOperation;
  24. import com.owncloud.android.lib.resources.status.OCCapability;
  25. import com.owncloud.android.operations.common.SyncOperation;
  26. /**
  27. * Get and save capabilities from the server
  28. */
  29. public class GetCapabilitiesOperarion extends SyncOperation {
  30. @Override
  31. protected RemoteOperationResult run(OwnCloudClient client) {
  32. GetRemoteCapabilitiesOperation getCapabilities = new GetRemoteCapabilitiesOperation();
  33. RemoteOperationResult result = getCapabilities.execute(client);
  34. if (result.isSuccess()){
  35. // Read data from the result
  36. if( result.getData()!= null && result.getData().size() > 0) {
  37. OCCapability capability = (OCCapability) result.getData().get(0);
  38. // Save the capabilities into database
  39. getStorageManager().saveCapabilities(capability);
  40. }
  41. }
  42. return result;
  43. }
  44. }