Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package de.pfabulist.lindwurm.stellvertreter;
  
  
  import java.nio.file.Path;
 import java.util.List;
 import java.util.UUID;
 
 import static de.pfabulist.lindwurm.stellvertreter.SaveState.CONSISTENT;
 import static de.pfabulist.lindwurm.stellvertreter.SaveState.NEEDS_SAVING;
 import static de.pfabulist.lindwurm.stellvertreter.StellvertreterConstants.CONTENT_ROOT;

** BEGIN LICENSE BLOCK ***** BSD License (2 clause) Copyright (c) 2006 - 2015, Stephan Pfab All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Stephan Pfab BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **** END LICENSE BLOCK ****

 
 
 public class Local2 {
 
     private final UUID id;
     private final KryoProvider kp;
     private final CopyEncrypted copyEncrypted;
     private final Path hostRoot;
 
     public Local2UUID idKryoProvider kpCopyEncrypted copyEncryptedPath hostRoot ) {
         this. = id;
         this. = kp;
         this. = copyEncrypted;
         this. = hostRoot;
     }
 
     public Local2Path hostPathKryoProvider kpCopyEncrypted copyEncryptedPath hostRoot ) {
         this. = UUID.fromStringhostPath.getNamehostPath.getNameCount() - 5 ).toString() + "-" +
                                            hostPath.getNamehostPath.getNameCount() - 4 ).toString() + "-" +
                                            hostPath.getNamehostPath.getNameCount() - 3 ).toString() + "-" +
                                            hostPath.getNamehostPath.getNameCount() - 2 ).toString() + "-" +
                                            hostPath.getNamehostPath.getNameCount() - 1 ).toString());
         this. = kp;
         this. = null;
         this. = hostRoot;
     }
 
     public List<UUIDgetKids() {
         FM2 fm = FM2.valueOf );
         return new ArrayList<>( fm.kids );
     }
 
     @Override
     public boolean equalsObject o ) {
         ifthis == o ) return true;
         ifo == null || getClass() != o.getClass() ) return false;
 
         Local2 local2 = (Local2o;
 
         return .equalslocal2.id );
 
     }
 
     @Override
     public int hashCode() {
         return .hashCode();
     }
 
     public void createFileIfNotExistsEightyPath path ) {
         if ( !exists()) {
             Local2 parent = getpath.getParent() );
 
             FM2.newFile.copyEncryptpath.getFileName().toString() ) );
             FM2.addChildparent.id );
         }
     }
    public void createDirEightyPath path ) {
        Local2 parent = getpath.getParent() );
        FM2.newDir.copyEncryptpath.getFileName().toString() ) );
        FM2.addChildparent.id );
    }
    public boolean exists() {
        return FM2.exists) && !FM2.valueOf ).;
    }
    public Path getContentPath() {
        return getPath );
    }
    public Path getPathPath root ) {
        Path ret = root.resolve );
        String[] parts = .toString().split"-" );
        for ( String part : parts ) {
            ret = ret.resolvepart );
        }
        return ret;
    }
    public String getClearName() {
        FM2 fm = FM2.valueOf );
        return .copyDecryptfm.name );
    }
    public void setTimesFileTime lastModifiedTimeFileTime lastAccessTimeFileTime createTime ) {
        FM2.setTimes,
                      lastModifiedTime == null ? 0 : lastModifiedTime.toMillis(),
                      lastAccessTime == null ? 0 : lastAccessTime.toMillis(),
                      createTime == null ? 0 : createTime.toMillis() );
    }
        FM2 fm = FM2.valueOf );
        return new StellvertreterAttributes(
                ,
                fm.isDir,
                FileTime.fromMillisfm.lastModifiedTime ),
                FileTime.fromMillisfm.lastAccessTime ),
                FileTime.fromMillisfm.creationTime ),
                fm.size,
                fm.pinned,
                fm.isDir || Files.existsgetContentPath() ),
                FileTime.fromMillis(1), // fm.version,
                fm.saved.stream().anyMatchstate -> !state.equals ) ),
                fm.saved.stream().anyMatchstate -> state.equals ) ),
                fm.ids);
    }
    // -----------------------------------------------------------------
    private Local2 getChildString name ) {
        List<UUIDkids = getKids();
        for ( UUID kid : kids ) {
            FM2 fm = FM2.valueOfkid );
            if ( .copyDecryptfm.name ).equalsname )) {
                return new Local2kid );
            }
        }
        return new Local2( UUID.randomUUID(),  );
    }
    // -----------------------------------------------------------------
    private static ConcurrentMap<Path,UUIDidCache = new ConcurrentHashMap<>();
    public static Local2 getKryoProvider kpCopyEncrypted copyEncryptedPath hostrootPath guest) {
        UUID id = .getguest );
        ifid != null ) {
            return new Local2idkpcopyEncryptedhostroot );
        }
        Local2 ret = getCalckpcopyEncryptedhostrootguest );
        .putguestret.id );
        return ret;
    }
    public static Local2 getCalcKryoProvider kpCopyEncrypted copyEncryptedPath hostrootPath guest) {
        if ( guest.getParent() == null ) {
            return new Local2new UUID( 0,1 ), kpcopyEncryptedhostroot );
        }
        Local2 ret = getkpcopyEncryptedhostrootguest.getParent() );
                //new Local2( rootID, kp, copyEncrypted, hostroot );
        ret = ret.getChildguest.getFileName().toString() );
        return ret;
    }
    public static void ensureRootKryoProvider kpCopyEncrypted copyEncryptedPath hostroot) {
        UUID rootID = new UUID( 0,1 );
        //Local2 ret = new Local2( rootID, kp, copyEncrypted, hostroot );
        FM2.ensurekphostrootrootIDcopyEncrypted.copyEncrypt"" ) );
    }
    public static void deleteKryoProvider kpCopyEncrypted copyEncryptedPath hostrootPath path ) {
        Local2 parent = getkpcopyEncryptedhostrootpath.getParent() );
        Local2 child = getkpcopyEncryptedhostrootpath );
        FM2.deletekphostrootparent.idchild.id );
        .removepath );
    }
    public static void moveKryoProvider kryoProviderCopyEncrypted copyEncryptedPath hostRootLocal2 srcParentLocal2 srcLocal2 tgtParentPath sourcePath target ) {
        FM2 fm = FM2.valueOfkryoProviderhostRootsrc.id );
        if ( fm.isDir ) {
            .clear(); // throw away cache
        } else {
            .removesource );
            .removetarget );
        }
        FM2.movekryoProviderhostRootsrcParent.idsrc.idtgtParent.idcopyEncrypted.copyEncrypttarget.getFileName().toString() ) );
    }
    public List<StringgetIds() {
        return FM2.valueOf ).;
    }
    public void setWrittenlong size ) {
        FM2.setWrittensize );
    }
    public void setRead() {
        FM2.setRead );
    }
    public boolean isSavedElsewhere els ) {
        try {
            List<SaveStatesaves = FM2.valueOf ).;
            return els.getIdx() < saves.size() && !saves.getels.getIdx() ).equals );
        } catch ( RuntimeException e ) {
            // hm local without a meta ?
            e.printStackTrace();
            return false;
        }
    }
    public boolean isSavedToAll() {
        List<SaveStatesaved = FM2.valueOf ).;
        return saved.size() > 0 && saved.stream().allMatchstate -> !state.equals. ) );
    }
    public boolean isLocal() {
        return Files.existsgetContentPath() );
    }
    public String getIdElsewhere els ) {
        List<Stringids = getIds();
        if ( ids.size() <= els.getIdx() ) {
            return null;
        }
        return ids.getels.getIdx() );
    }
    public String getIdint idx ) {
        List<Stringids = getIds();
        if ( ids.size() <= idx ) {
            return null;
        }
        return ids.getidx );
    }
    public FM2 getFM() {
        return FM2.valueOf );
    }
    public void savedlong versionint idxString elseIdBoolean consistent ) {
        FM2.justSavedversionidxelseIdconsistent );
    }
    @Override
    public String toString() {
        return "Local2{" +  + '}';
    }
    public void deletedInElseElsewhere els ) {
        FM2.deletedInElseels.getIdx() );
    }
    public void removeFinally() {
        FM2.removeFinally );
    }
    public boolean isPurgable() {
        FM2 fm = FM2.valueOf );
        // todo make dirs purgable
        return !fm.isDir && fm.saved.stream().anyMatchstate -> state.equals. ) );
    }
    public long getSize() {
        return FM2.valueOf ).;
    }
    public long getVersion() {
        return FM2.valueOf ).;
    }
New to GrepCode? Check out our FAQ X