@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); } }