public void trash( final String origPath, final FileRecord deletedRecord ) { Trash trash = userToTrashMap.get( currentUserProvider.getUser() ); if ( trash == null ) { trash = new Trash(); userToTrashMap.put( currentUserProvider.getUser(), trash ); } RepositoryFile popFile = new RepositoryFile.Builder( deletedRecord.getFile() ).originalParentFolderPath( origPath ).deletedDate( new Date() ).build(); deletedRecord.setFile( popFile ); List<FileRecord> dels = trash.getOrigPathToFilesMap().get( origPath ); if ( dels == null ) { dels = new ArrayList<FileRecord>(); trash.getOrigPathToFilesMap().put( origPath, dels ); } dels.add( deletedRecord ); trash.getIdToOrigPathMap().put( deletedRecord.getFile().getId(), origPath ); }
public void restore( final Serializable fileId ) { Trash trash = userToTrashMap.get( currentUserProvider.getUser() ); if ( trash == null ) { throw new UnifiedRepositoryException( "no trash found for user" ); } String origPath = trash.getIdToOrigPathMap().get( fileId ); List<FileRecord> dels = trash.getOrigPathToFilesMap().get( origPath ); FileRecord found = null; for ( Iterator<FileRecord> iter = dels.iterator(); iter.hasNext(); ) { FileRecord r = iter.next(); if ( r.getFile().getId().equals( fileId ) ) { iter.remove(); found = r; } } FileRecord parentFolder = root.getFileRecord( origPath ); parentFolder.addChild( found ); trash.getIdToOrigPathMap().remove( fileId ); RepositoryFile popFile = new RepositoryFile.Builder( found.getFile() ).originalParentFolderPath( null ).deletedDate( null ).build(); found.setFile( popFile ); }
.lockDate( unmarshalDate( v.getLockDate() ) ).locked( v.isLocked() ).lockMessage( v.getLockMessage() ).lockOwner( v.getLockOwner() ) .title( v.getTitle() ).versioned( v.isVersioned() ).versionId( v.getVersionId() ).originalParentFolderPath( v.getOriginalParentFolderPath() ).deletedDate( unmarshalDate( v.getDeletedDate() ) ).hidden( v.isHidden() ).schedulable( !v .isNotSchedulable() ).aclNode( v.isAclNode() ).build();
public Builder( final RepositoryFile other ) { this( other.getName() ); synchronized ( other ) { this.id( other.getId() ).path( other.getPath() ).createdDate( other.getCreatedDate() ).creatorId( other.getCreatorId() ).fileSize( other.getFileSize() ).folder( other.isFolder() ).lastModificationDate( other.getLastModifiedDate() ).versioned( other.isVersioned() ).hidden( other.isHidden() ).schedulable( other.isSchedulable() ).versionId( other.getVersionId() ).locked( other.isLocked() ).lockDate( other.getLockDate() ).lockOwner( other.getLockOwner() ).lockMessage( other.getLockMessage() ).title( other.getTitle() ).description( other.getDescription() ).locale( other.getLocale() ).originalParentFolderPath( other.getOriginalParentFolderPath() ).deletedDate( other.getDeletedDate() ).localePropertiesMap( other.getLocalePropertiesMap() ).aclNode( other.isAclNode() ); } }
private RepositoryFile nodeToDeletedFile( final Session session, final PentahoJcrConstants pentahoJcrConstants, final Node trashFileNode, String owner ) throws RepositoryException { // each fileId node has at most one child that is the deleted file RepositoryFile deletedFile = JcrRepositoryFileUtils.nodeToFile( session, pentahoJcrConstants, pathConversionHelper, lockHelper, trashFileNode ); Date deletedDate = getDeletedDate( trashFileNode, pentahoJcrConstants ); String originalParentFolderPath = getOriginalParentFolderPath( session, pentahoJcrConstants, trashFileNode, true ); return new RepositoryFile.Builder( deletedFile ).deletedDate( deletedDate ).originalParentFolderPath( originalParentFolderPath ).creatorId( owner ).build(); }