Package cloudsync.model

Examples of cloudsync.model.Item


  public void prepareParent(Handler handler, Item item) throws CloudsyncException {

    if (item.getParent() != null) {

      Item parentItem = item.getParent();

      final Path parentPath = Paths.get(localPath + Item.SEPARATOR + parentItem.getPath());

      try {
        Files.createDirectories(parentPath);
      } catch (IOException e) {
        throw new CloudsyncException("Can't create " + parentItem.getTypeName() + " '" + parentItem.getPath() + "'", e);
      }
    }
  }
View Full Code Here


      return null;
    }

    final File driveRoot = _getBackupFolder();
    final List<String> parentDriveTitles = new ArrayList<String>();
    Item parentItem = item;
    do {
      parentItem = parentItem.getParent();
      if (parentItem.getRemoteIdentifier().equals(driveRoot.getId())) {
        break;
      }
      final File parentDriveItem = _getDriveItem(parentItem);
      parentDriveTitles.add(0, parentDriveItem.getTitle());
    } while (true);
View Full Code Here

    try {
      final Reader in = new FileReader(cacheFilePath.toFile());
      final Iterable<CSVRecord> records = CSVFormat.EXCEL.parse(in);
      for (final CSVRecord record : records) {

        final Item item = Item.fromCSV(record);
        final String childPath = Helper.trim(record.get(0), Item.SEPARATOR);
        final String parentPath = childPath.length() == item.getName().length() ? "" : StringUtils.removeEnd(FilenameUtils.getPath(childPath), Item.SEPARATOR);
        mapping.put(childPath, item);
        // System.out.println(parentPath+":"+item.getName());
        Item parent = mapping.get(parentPath);
        item.setParent(parent);
        parent.addChild(item);
      }
    } catch (final IOException e) {

      throw new CloudsyncException("Can't read cache from file '" + cacheFilePath.toString() + "'", e);
    }
View Full Code Here

        continue;

      String backupPath = filePath;
      try {

        Item localChildItem = localConnection.getItem(localChildFile, followlinks);
        localChildItem.setParent(remoteParentItem);

        backupPath = localChildItem.getPath();

        Item remoteChildItem = remoteParentItem.getChildByName(localChildItem.getName());

        if (remoteChildItem == null) {
          remoteChildItem = localChildItem;
          LOGGER.log(Level.FINE, "create " + remoteChildItem.getTypeName() + " '" + backupPath + "'");
          if (perform) {
            createLock();
            remoteConnection.upload(this, remoteChildItem);
          }
          remoteParentItem.addChild(remoteChildItem);
          status.create++;
        } else {

          if (remoteChildItem.isTypeChanged(localChildItem)) {
            LOGGER.log(Level.FINE, "remove " + remoteChildItem.getTypeName() + " '" + backupPath + "'");
            if (perform) {
              createLock();
              remoteConnection.remove(this, remoteChildItem);
            }
            status.remove++;

            remoteChildItem = localChildItem;
            LOGGER.log(Level.FINE, "create " + remoteChildItem.getTypeName() + " '" + backupPath + "'");
            if (perform) {
              createLock();
              remoteConnection.upload(this, remoteChildItem);
            }
            remoteParentItem.addChild(remoteChildItem);
            status.create++;
          }
          // check filesize and modify time
          else if (remoteChildItem.isMetadataChanged(localChildItem)) {
            final boolean isFiledataChanged = localChildItem.isFiledataChanged(remoteChildItem);
            remoteChildItem.update(localChildItem);
            List<String> types = new ArrayList<String>();
            if (isFiledataChanged)
              types.add("data,attributes");
            else if (!isFiledataChanged)
              types.add("attributes");
            if (remoteChildItem.isMetadataFormatChanged())
              types.add("format");
            LOGGER.log(Level.FINE, "update " + remoteChildItem.getTypeName() + " '" + backupPath + "' [" + StringUtils.join(types, ",") + "]");
            if (perform) {
              createLock();
              remoteConnection.update(this, remoteChildItem, isFiledataChanged);
            }
            status.update++;
          } else {
            status.skip++;
          }
        }

        try {
          // refresh Metadata
          Item _localChildItem = localConnection.getItem(localChildFile, followlinks);
          if (_localChildItem.isMetadataChanged(localChildItem)) {

            LOGGER.log(Level.WARNING, localChildItem.getTypeName() + " '" + backupPath + "' was changed during update.");
          }
        } catch (NoSuchFileException e) {
View Full Code Here

    int retryCount = 0;
    do {
      try {

        Item parentItem = item.getParent();
        String parentPath = buildPath(parentItem);
        String path = parentPath + SEPARATOR + handler.getLocalEncryptedTitle(item);
        DbxEntry entry;

        if (item.isType(ItemType.FOLDER)) {
View Full Code Here

TOP

Related Classes of cloudsync.model.Item

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.