Package com.google.api.services.drive.model

Examples of com.google.api.services.drive.model.File


        if (Logging.connectors.isDebugEnabled()) {
          Logging.connectors.debug("GOOGLEDRIVE: Processing document identifier '"
              + nodeId + "'");
        }

        File googleFile = getObject(nodeId);
        if (googleFile == null || (googleFile.containsKey("explicitlyTrashed") && googleFile.getExplicitlyTrashed())) {
          //its deleted, move on
          continue;
        }


        if (Logging.connectors.isDebugEnabled()) {
          Logging.connectors.debug("GOOGLEDRIVE: have this file:\t" + googleFile.getTitle());
        }

        if ("application/vnd.google-apps.folder".equals(googleFile.getMimeType())) {
          //if directory add its children

          if (Logging.connectors.isDebugEnabled()) {
            Logging.connectors.debug("GOOGLEDRIVE: its a directory");
          }

          // adding all the children + subdirs for a folder

          getSession();
          GetChildrenThread t = new GetChildrenThread(nodeId);
          try {
            t.start();
            boolean wasInterrupted = false;
            try {
              XThreadStringBuffer childBuffer = t.getBuffer();
              // Pick up the paths, and add them to the activities, before we join with the child thread.
              while (true) {
                // The only kind of exceptions this can throw are going to shut the process down.
                String child = childBuffer.fetch();
                if (child ==  null)
                  break;
                // Add the pageID to the queue
                activities.addDocumentReference(child, nodeId, RELATIONSHIP_CHILD);
              }
            } catch (InterruptedException e) {
              wasInterrupted = true;
              throw e;
            } catch (ManifoldCFException e) {
              if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                wasInterrupted = true;
              throw e;
            } finally {
              if (!wasInterrupted)
                t.finishUp();
            }
          } catch (InterruptedException e) {
            t.interrupt();
            throw new ManifoldCFException("Interrupted: " + e.getMessage(), e,
              ManifoldCFException.INTERRUPTED);
          } catch (java.net.SocketTimeoutException e) {
            Logging.connectors.warn("GOOGLEDRIVE: Socket timeout adding child documents: " + e.getMessage(), e);
            handleIOException(e);
          } catch (InterruptedIOException e) {
            t.interrupt();
            throw new ManifoldCFException("Interrupted: " + e.getMessage(), e,
              ManifoldCFException.INTERRUPTED);
          } catch (IOException e) {
            Logging.connectors.warn("GOOGLEDRIVE: Error adding child documents: " + e.getMessage(), e);
            handleIOException(e);
          }

        } else {
          // its a file
          if (!scanOnly[i]) {
            doLog = true;

            if (Logging.connectors.isDebugEnabled()) {
              Logging.connectors.debug("GOOGLEDRIVE: its a file");
            }

            // We always direct to the PDF
            String documentURI = getUrl(googleFile, "application/pdf");

            // Get the file length
            Long fileLength = googleFile.getFileSize();
            if (fileLength != null) {

              // Unpack the version string
              ArrayList acls = new ArrayList();
              StringBuilder denyAclBuffer = new StringBuilder();
              int index = unpackList(acls,version,0,'+');
              if (index < version.length() && version.charAt(index++) == '+') {
                index = unpack(denyAclBuffer,version,index,'+');
              }

              //otherwise process
              RepositoryDocument rd = new RepositoryDocument();

              // Turn into acls and add into description
              String[] aclArray = new String[acls.size()];
              for (int j = 0; j < aclArray.length; j++) {
                aclArray[j] = (String)acls.get(j);
              }
              rd.setACL(aclArray);
              if (denyAclBuffer.length() > 0) {
                String[] denyAclArray = new String[]{denyAclBuffer.toString()};
                rd.setDenyACL(denyAclArray);
              }

              // Now do standard stuff
              String mimeType = googleFile.getMimeType();
              DateTime createdDate = googleFile.getCreatedDate();
              DateTime modifiedDate = googleFile.getModifiedDate();
              String extension = googleFile.getFileExtension();
              String title = googleFile.getTitle();
             
              if (mimeType != null)
                rd.setMimeType(mimeType);
              if (createdDate != null)
                rd.setCreatedDate(new Date(createdDate.getValue()));
              if (modifiedDate != null)
                rd.setModifiedDate(new Date(modifiedDate.getValue()));
              if (extension != null)
              {
                if (title == null)
                  title = "";
                rd.setFileName(title + "." + extension);
              }

              // Get general document metadata
              for (Entry<String, Object> entry : googleFile.entrySet()) {
                rd.addField(entry.getKey(), entry.getValue().toString());
              }

              // Fire up the document reading thread
              DocumentReadingThread t = new DocumentReadingThread(documentURI);
View Full Code Here


    // Sort it,
    java.util.Arrays.sort(acls);

    String[] rval = new String[documentIdentifiers.length];
    for (int i = 0; i < rval.length; i++) {
      File googleFile = getObject(documentIdentifiers[i]);
      if (!isDir(googleFile)) {
        String rev = googleFile.getModifiedDate().toStringRfc3339();
        if (StringUtils.isNotEmpty(rev)) {
          StringBuilder sb = new StringBuilder();

          // Acls
          packList(sb,acls,'+');
View Full Code Here

        if (Logging.connectors.isDebugEnabled()) {
          Logging.connectors.debug("GOOGLEDRIVE: Processing document identifier '"
              + nodeId + "'");
        }

        File googleFile = getObject(nodeId);
        if (googleFile == null || (googleFile.containsKey("explicitlyTrashed") && googleFile.getExplicitlyTrashed())) {
          //its deleted, move on
          continue;
        }


        if (Logging.connectors.isDebugEnabled()) {
          Logging.connectors.debug("GOOGLEDRIVE: have this file:\t" + googleFile.getTitle());
        }

        if ("application/vnd.google-apps.folder".equals(googleFile.getMimeType())) {
          //if directory add its children

          if (Logging.connectors.isDebugEnabled()) {
            Logging.connectors.debug("GOOGLEDRIVE: its a directory");
          }

          // adding all the children + subdirs for a folder

          getSession();
          GetChildrenThread t = new GetChildrenThread(nodeId);
          try {
            t.start();
            boolean wasInterrupted = false;
            try {
              XThreadStringBuffer childBuffer = t.getBuffer();
              // Pick up the paths, and add them to the activities, before we join with the child thread.
              while (true) {
                // The only kind of exceptions this can throw are going to shut the process down.
                String child = childBuffer.fetch();
                if (child ==  null)
                  break;
                // Add the pageID to the queue
                activities.addDocumentReference(child, nodeId, RELATIONSHIP_CHILD);
              }
            } catch (InterruptedException e) {
              wasInterrupted = true;
              throw e;
            } catch (ManifoldCFException e) {
              if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                wasInterrupted = true;
              throw e;
            } finally {
              if (!wasInterrupted)
                t.finishUp();
            }
          } catch (InterruptedException e) {
            t.interrupt();
            throw new ManifoldCFException("Interrupted: " + e.getMessage(), e,
              ManifoldCFException.INTERRUPTED);
          } catch (java.net.SocketTimeoutException e) {
            Logging.connectors.warn("GOOGLEDRIVE: Socket timeout adding child documents: " + e.getMessage(), e);
            handleIOException(e);
          } catch (InterruptedIOException e) {
            t.interrupt();
            throw new ManifoldCFException("Interrupted: " + e.getMessage(), e,
              ManifoldCFException.INTERRUPTED);
          } catch (IOException e) {
            Logging.connectors.warn("GOOGLEDRIVE: Error adding child documents: " + e.getMessage(), e);
            handleIOException(e);
          }

        } else {
          // its a file
          if (!scanOnly[i]) {
            doLog = true;

            if (Logging.connectors.isDebugEnabled()) {
              Logging.connectors.debug("GOOGLEDRIVE: its a file");
            }

            // We always direct to the PDF
            String documentURI = getUrl(googleFile, "application/pdf");

            // Get the file length
            Long fileLength = googleFile.getFileSize();
            if (fileLength != null) {

              // Unpack the version string
              ArrayList acls = new ArrayList();
              StringBuilder denyAclBuffer = new StringBuilder();
              int index = unpackList(acls,version,0,'+');
              if (index < version.length() && version.charAt(index++) == '+') {
                index = unpack(denyAclBuffer,version,index,'+');
              }

              //otherwise process
              RepositoryDocument rd = new RepositoryDocument();

              // Turn into acls and add into description
              String[] aclArray = new String[acls.size()];
              for (int j = 0; j < aclArray.length; j++) {
                aclArray[j] = (String)acls.get(j);
              }
              rd.setACL(aclArray);
              if (denyAclBuffer.length() > 0) {
                String[] denyAclArray = new String[]{denyAclBuffer.toString()};
                rd.setDenyACL(denyAclArray);
              }

              // Now do standard stuff
              String mimeType = googleFile.getMimeType();
              DateTime createdDate = googleFile.getCreatedDate();
              DateTime modifiedDate = googleFile.getModifiedDate();
              String extension = googleFile.getFileExtension();
              String title = googleFile.getTitle();
             
              if (mimeType != null)
                rd.setMimeType(mimeType);
              if (createdDate != null)
                rd.setCreatedDate(new Date(createdDate.getValue()));
              if (modifiedDate != null)
                rd.setModifiedDate(new Date(modifiedDate.getValue()));
              if (extension != null)
              {
                if (title == null)
                  title = "";
                rd.setFileName(title + "." + extension);
              }

              // Get general document metadata
              for (Entry<String, Object> entry : googleFile.entrySet()) {
                rd.addField(entry.getKey(), entry.getValue().toString());
              }

              // Fire up the document reading thread
              DocumentReadingThread t = new DocumentReadingThread(documentURI);
View Full Code Here

    // Sort it,
    java.util.Arrays.sort(acls);

    String[] rval = new String[documentIdentifiers.length];
    for (int i = 0; i < rval.length; i++) {
      File googleFile = getObject(documentIdentifiers[i]);
      if (!isDir(googleFile)) {
        String rev = googleFile.getModifiedDate().toStringRfc3339();
        if (StringUtils.isNotEmpty(rev)) {
          StringBuilder sb = new StringBuilder();

          // Acls
          packList(sb,acls,'+');
View Full Code Here

        if (Logging.connectors.isDebugEnabled()) {
          Logging.connectors.debug("GOOGLEDRIVE: Processing document identifier '"
              + nodeId + "'");
        }

        File googleFile = getObject(nodeId);
        if (googleFile == null || (googleFile.containsKey("explicitlyTrashed") && googleFile.getExplicitlyTrashed())) {
          //its deleted, move on
          continue;
        }


        if (Logging.connectors.isDebugEnabled()) {
          Logging.connectors.debug("GOOGLEDRIVE: have this file:\t" + googleFile.getTitle());
        }

        if ("application/vnd.google-apps.folder".equals(googleFile.getMimeType())) {
          //if directory add its children

          if (Logging.connectors.isDebugEnabled()) {
            Logging.connectors.debug("GOOGLEDRIVE: its a directory");
          }

          // adding all the children + subdirs for a folder

          getSession();
          GetChildrenThread t = new GetChildrenThread(nodeId);
          try {
            t.start();
            boolean wasInterrupted = false;
            try {
              XThreadStringBuffer childBuffer = t.getBuffer();
              // Pick up the paths, and add them to the activities, before we join with the child thread.
              while (true) {
                // The only kind of exceptions this can throw are going to shut the process down.
                String child = childBuffer.fetch();
                if (child ==  null)
                  break;
                // Add the pageID to the queue
                activities.addDocumentReference(child, nodeId, RELATIONSHIP_CHILD);
              }
            } catch (InterruptedException e) {
              wasInterrupted = true;
              throw e;
            } catch (ManifoldCFException e) {
              if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                wasInterrupted = true;
              throw e;
            } finally {
              if (!wasInterrupted)
                t.finishUp();
            }
          } catch (InterruptedException e) {
            t.interrupt();
            throw new ManifoldCFException("Interrupted: " + e.getMessage(), e,
              ManifoldCFException.INTERRUPTED);
          } catch (java.net.SocketTimeoutException e) {
            Logging.connectors.warn("GOOGLEDRIVE: Socket timeout adding child documents: " + e.getMessage(), e);
            handleIOException(e);
          } catch (InterruptedIOException e) {
            t.interrupt();
            throw new ManifoldCFException("Interrupted: " + e.getMessage(), e,
              ManifoldCFException.INTERRUPTED);
          } catch (IOException e) {
            Logging.connectors.warn("GOOGLEDRIVE: Error adding child documents: " + e.getMessage(), e);
            handleIOException(e);
          }

        } else {
          // its a file
          if (!scanOnly[i]) {
            doLog = true;

            if (Logging.connectors.isDebugEnabled()) {
              Logging.connectors.debug("GOOGLEDRIVE: its a file");
            }

            // We always direct to the PDF
            String documentURI = getUrl(googleFile, "application/pdf");

            // Get the file length
            Long fileLength = googleFile.getFileSize();
            if (fileLength != null) {

              // Unpack the version string
              ArrayList acls = new ArrayList();
              StringBuilder denyAclBuffer = new StringBuilder();
              int index = unpackList(acls,version,0,'+');
              if (index < version.length() && version.charAt(index++) == '+') {
                index = unpack(denyAclBuffer,version,index,'+');
              }

              //otherwise process
              RepositoryDocument rd = new RepositoryDocument();

              // Turn into acls and add into description
              String[] aclArray = new String[acls.size()];
              for (int j = 0; j < aclArray.length; j++) {
                aclArray[j] = (String)acls.get(j);
              }
              rd.setACL(aclArray);
              if (denyAclBuffer.length() > 0) {
                String[] denyAclArray = new String[]{denyAclBuffer.toString()};
                rd.setDenyACL(denyAclArray);
              }

              // Now do standard stuff
              String mimeType = googleFile.getMimeType();
              DateTime createdDate = googleFile.getCreatedDate();
              DateTime modifiedDate = googleFile.getModifiedDate();
              String extension = googleFile.getFileExtension();
              String title = googleFile.getTitle();
             
              if (mimeType != null)
                rd.setMimeType(mimeType);
              if (createdDate != null)
                rd.setCreatedDate(new Date(createdDate.getValue()));
              if (modifiedDate != null)
                rd.setModifiedDate(new Date(modifiedDate.getValue()));
              if (extension != null)
              {
                if (title == null)
                  title = "";
                rd.setFileName(title + "." + extension);
              }

              // Get general document metadata
              for (Entry<String, Object> entry : googleFile.entrySet()) {
                rd.addField(entry.getKey(), entry.getValue().toString());
              }

              // Fire up the document reading thread
              DocumentReadingThread t = new DocumentReadingThread(documentURI);
View Full Code Here

    // Sort it,
    java.util.Arrays.sort(acls);

    String[] rval = new String[documentIdentifiers.length];
    for (int i = 0; i < rval.length; i++) {
      File googleFile = getObject(documentIdentifiers[i]);
      if (!isDir(googleFile)) {
        String rev = googleFile.getModifiedDate().toStringRfc3339();
        if (StringUtils.isNotEmpty(rev)) {
          StringBuilder sb = new StringBuilder();

          // Acls
          packList(sb,acls,'+');
View Full Code Here

    return ImmutableList.copyOf(files);
  }

  @Override
  public GDirectory mkdir(String name) {
    File dir = exec.mkdir(file, name);
    return new GDirectoryFolder(exec, dir);
  }
View Full Code Here

    return this;
  }

  @Override
  public GFile as(MimeType mimeType) {
    File res = exec.write(file, from, title, mimeType);
    return new GFileBuilder(exec, res).build();
  }
View Full Code Here

    return ChangeId.of(id);
  }

  @Override
  public GFile getGFile() {
    File file = change.getFile();
    return new GFileBuilder(exec, file).build();
  }
View Full Code Here

    this.exec = exec;
  }

  @Override
  public GDirectory root() {
    File file = exec.directoryOf("root");
    return new GDirectoryFolder(exec, file);
  }
View Full Code Here

TOP

Related Classes of com.google.api.services.drive.model.File

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.