@Override public <T extends ExtRepositoryObject> T moveExtRepositoryObject( ExtRepositoryObjectType<T> extRepositoryObjectType, String extRepositoryObjectKey, String newExtRepositoryFolderKey, String newTitle) throws PortalException { try { Drive drive = getDrive(); File file = getFile(drive, extRepositoryObjectKey); Drive.Parents driveParents = drive.parents(); List<ParentReference> parentReferences = file.getParents(); for (ParentReference parentReference : parentReferences) { Drive.Parents.Delete driveParentsDelete = driveParents.delete(file.getId(), parentReference.getId()); driveParentsDelete.execute(); } ParentReference parentReference = new ParentReference(); parentReference.setId(newExtRepositoryFolderKey); Drive.Parents.Insert driveParentsInsert = driveParents.insert(file.getId(), parentReference); driveParentsInsert.execute(); if (extRepositoryObjectType.equals(ExtRepositoryObjectType.FILE)) { return (T) new GoogleDriveFileEntry(file); } return (T) new GoogleDriveFolder(file, getRootFolderKey()); } catch (IOException ioe) { _log.error(ioe, ioe); throw new SystemException(ioe); } }
@Override public ExtRepositoryFolder getExtRepositoryParentFolder(ExtRepositoryObject extRepositoryObject) throws PortalException { try { Drive drive = getDrive(); File file = getFile(drive, extRepositoryObject.getExtRepositoryModelKey()); List<ParentReference> parentReferences = file.getParents(); if (!parentReferences.isEmpty()) { ParentReference parentReference = parentReferences.get(0); File parentFile = getFile(drive, parentReference.getId()); return new GoogleDriveFolder(parentFile, getRootFolderKey()); } } catch (IOException ioe) { // _log.error(ioe, ioe); } return null; }