Package cloudsync.exceptions

Examples of cloudsync.exceptions.CloudsyncException


          MediaHttpUploader uploader = inserter.getMediaHttpUploader();
          prepareUploader(uploader, data);
          driveItem = inserter.execute();
        }
        if (driveItem == null) {
          throw new CloudsyncException("Could not create item '" + item.getPath() + "'");
        }
        _addToCache(driveItem, null);
        item.setRemoteIdentifier(driveItem.getId());
        return;
      } catch (final NoSuchFileException e) {
View Full Code Here


            // copyOfdriveItem.setTitle(driveItem.getTitle());
            // copyOfdriveItem.setMimeType(driveItem.getMimeType());
            // copyOfdriveItem.setProperties(driveItem.getProperties());
            final File _copyOfDriveItem = service.files().copy(item.getRemoteIdentifier(), copyOfdriveItem).execute();
            if (_copyOfDriveItem == null) {
              throw new CloudsyncException("Could not make a history snapshot of item '" + item.getPath() + "'");
            }
          }
        }
        File driveItem = new File();
        final byte[] data = _prepareDriveItem(driveItem, item, handler, with_filedata);
        if (data == null) {
          driveItem = service.files().update(item.getRemoteIdentifier(), driveItem).execute();
        } else {
          final InputStreamContent params = new InputStreamContent(FILE, new ByteArrayInputStream(data));
          params.setLength(data.length);
          Update updater = service.files().update(item.getRemoteIdentifier(), driveItem, params);
          MediaHttpUploader uploader = updater.getMediaHttpUploader();
          prepareUploader(uploader, data);
          driveItem = updater.execute();
        }
        if (driveItem == null) {
          throw new CloudsyncException("Could not update item '" + item.getPath() + "'");
        } else if (driveItem.getLabels().getTrashed()) {
          throw new CloudsyncException("Remote item '" + item.getPath() + "' [" + driveItem.getId() + "] is trashed\ntry to run with --nocache");
        }
        _addToCache(driveItem, null);
        return;
      } catch (final NoSuchFileException e) {
        throw e;
View Full Code Here

          parentReference.setId(_parentDriveItem.getId());
          File driveItem = new File();
          driveItem.setParents(Arrays.asList(parentReference));
          driveItem = service.files().patch(item.getRemoteIdentifier(), driveItem).execute();
          if (driveItem == null) {
            throw new CloudsyncException("Could not make a history snapshot of item '" + item.getPath() + "'");
          }
        } else {
          service.files().delete(item.getRemoteIdentifier()).execute();
        }
        _removeFromCache(item.getRemoteIdentifier());
View Full Code Here

          service.files().delete(file.getId()).execute();
        }
      }
    } catch (final IOException e) {

      throw new CloudsyncException("Unexpected error during history cleanup", e);
    }
  }
View Full Code Here

      driveItem = service.files().get(id).execute();

    } catch (HttpResponseException e) {

      if (e.getStatusCode() == 404) {
        throw new CloudsyncException("Couldn't find remote item '" + item.getPath() + "' [" + id + "]\ntry to run with --nocache");
      }

      throw e;
    }

    if (driveItem.getLabels().getTrashed()) {
      throw new CloudsyncException("Remote item '" + item.getPath() + "' [" + id + "] is trashed\ntry to run with --nocache");
    }

    _addToCache(driveItem, null);
    return driveItem;
  }
View Full Code Here

              final ParentReference parentReference = new ParentReference();
              parentReference.setId(parentItem.getId());
              folder.setParents(Arrays.asList(parentReference));
              _parentItem = service.files().insert(folder).execute();
              if (_parentItem == null) {
                throw new CloudsyncException("Could not create folder '" + name + "'");
              }
            } else if (result.size() == 1) {
              _parentItem = result.get(0);
            } else {

              throw new CloudsyncException("base path '" + path + "' not unique");
            }

            if (!_parentItem.getMimeType().equals(FOLDER)) {
              throw new CloudsyncException("No folder found at '" + path + "'");
            }

            _addToCache(_parentItem, parentItem);

            parentItem = _parentItem;

            request.setPageToken(files.getNextPageToken());
          } while (request.getPageToken() != null && request.getPageToken().length() > 0);
        }
      }
      return parentItem;
    } catch (final IOException e) {

      throw new CloudsyncException("Unexpected Exception", e);
    }
  }
View Full Code Here

      LOGGER.log(Level.WARNING, getExceptionMessage(e) + name + " - retry " + count + "/" + RETRY_COUNT);

      return count;
    }

    throw new CloudsyncException("Unexpected error during " + name + " of " + item.getTypeName() + " '" + item.getPath() + "'", e);
  }
View Full Code Here

    service = new Drive.Builder(httpTransport, jsonFactory, credential).setApplicationName("Backup").build();
    credential.setExpiresInSeconds(MIN_TOKEN_REFRESH_TIMEOUT);
    try {
      refreshCredential();
    } catch (IOException e) {
      throw new CloudsyncException("couldn't refresh google drive token");
    }
    handler.getRootItem().setRemoteIdentifier(_getBackupFolder().getId());
  }
View Full Code Here

    lockFilePath = Paths.get(lockFile.replace("{name}", name));
    pidFilePath = Paths.get(pidFile.replace("{name}", name));

    if (synctype.checkPID()) {
      if (!forcestart && Files.exists(pidFilePath, LinkOption.NOFOLLOW_LINKS)) {
        throw new CloudsyncException("Other job is running or previous job has crashed. If you are sure that no other job is running use the option '--forcestart'");
      }

      RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
      String jvmName = bean.getName();
      long pid = Long.valueOf(jvmName.split("@")[0]);

      try {
        Files.write(pidFilePath, new Long(pid).toString().getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
        pidCleanup = true;
      } catch (IOException e) {
        throw new CloudsyncException("Couldn't create '" + pidFilePath.toString() + "'");
      }
    }

    if (Files.exists(lockFilePath, LinkOption.NOFOLLOW_LINKS)) {
      LOGGER.log(Level.WARNING, "Found an inconsistent cache file state. Possibly previous job has crashed or duplicate files was detected. Force a cache file rebuild.");
View Full Code Here

    try {
      if (pidCleanup)
        Files.delete(pidFilePath);
    } catch (IOException e) {
      throw new CloudsyncException("Couldn't remove '" + pidFilePath.toString() + "'");
    }
  }
View Full Code Here

TOP

Related Classes of cloudsync.exceptions.CloudsyncException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.