当前位置: 首页>>代码示例>>Java>>正文


Java AccessType类代码示例

本文整理汇总了Java中org.rmatil.sync.version.api.AccessType的典型用法代码示例。如果您正苦于以下问题:Java AccessType类的具体用法?Java AccessType怎么用?Java AccessType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AccessType类属于org.rmatil.sync.version.api包,在下文中一共展示了AccessType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addSharer

import org.rmatil.sync.version.api.AccessType; //导入依赖的package包/类
@Override
public synchronized void addSharer(String username, AccessType accessType, String pathToFile)
        throws InputOutputException {
    String fileNameHash = Hash.hash(Config.DEFAULT.getHashingAlgorithm(), pathToFile);

    String firstSharingHistoryEntry = Hash.hash(Config.DEFAULT.getHashingAlgorithm(), accessType.name());

    List<String> sharingHistory = new ArrayList<>();
    sharingHistory.add(firstSharingHistoryEntry);
    Sharer sharer = new Sharer(
            username,
            accessType,
            sharingHistory
    );

    PathObject pathObject = this.objectManager.getObject(fileNameHash);
    pathObject.setIsShared(true);
    pathObject.getSharers().add(sharer);
    this.objectManager.writeObject(pathObject);
}
 
开发者ID:p2p-sync,项目名称:versions,代码行数:21,代码来源:SharerManager.java

示例2: PathObject

import org.rmatil.sync.version.api.AccessType; //导入依赖的package包/类
/**
 * @param name       The name of the file or directory (without the path to it)
 * @param path       The path to the file or directory (without the name of it)
 * @param pathType   The type of the file
 * @param accessType The access type the client has on this file if it is shared. May be null otherwise
 * @param isShared   Whether this file is shared
 * @param deleted    Whether the path on disk is deleted
 * @param owner      The owner's username in case the file is shared
 * @param sharers    A list of sharers
 * @param versions   A list of versions
 */
public PathObject(String name, String path, PathType pathType, AccessType accessType, boolean isShared, Delete deleted, String owner, Set<Sharer> sharers, List<Version> versions) {
    this.name = name;
    this.path = path;
    this.pathType = pathType;
    this.accessType = accessType;
    this.isShared = isShared;
    this.deleted = deleted;
    this.owner = owner;
    this.sharers = sharers;
    if (null == this.sharers) {
        this.sharers = new HashSet<>();
    }

    this.versions = versions;
    if (null == this.versions) {
        this.versions = new ArrayList<>();
    }
}
 
开发者ID:p2p-sync,项目名称:versions,代码行数:30,代码来源:PathObject.java

示例3: testGetChildren

import org.rmatil.sync.version.api.AccessType; //导入依赖的package包/类
@Test
public void testGetChildren()
        throws InputOutputException {
    objectManager.writeObject(pathObject);

    PathObject dirObject = new PathObject("dir", "somePath/to", PathType.DIRECTORY, AccessType.WRITE, false, new Delete(null, new ArrayList<>()), null, new HashSet<>(), new ArrayList<>());
    objectManager.writeObject(dirObject);

    List<PathObject> children = objectManager.getChildren("somePath/to/dir");

    assertFalse("Children contain a path", children.isEmpty());
    assertEquals("Children contain only one path", 1, children.size());
    assertEquals("PathObject is not equal", pathObject.toJson(), children.get(0).toJson());

    objectManager.removeObject(Hash.hash(Config.DEFAULT.getHashingAlgorithm(), dirObject.getAbsolutePath()));
    objectManager.removeObject(Hash.hash(Config.DEFAULT.getHashingAlgorithm(), pathObject.getAbsolutePath()));
}
 
开发者ID:p2p-sync,项目名称:versions,代码行数:18,代码来源:ObjectManagerTest.java

示例4: setUp

import org.rmatil.sync.version.api.AccessType; //导入依赖的package包/类
@BeforeClass
public static void setUp()
        throws InputOutputException {
    try {
        // create test dir
        if (! Files.exists(ROOT_TEST_DIR)) {
            Files.createDirectory(ROOT_TEST_DIR);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    storageAdapter = new LocalStorageAdapter(ROOT_TEST_DIR);
    objectManager = new ObjectManager("index.json", "objects", storageAdapter);
    deleteManager = new DeleteManager(objectManager);

    pathObject = new PathObject("myFile.txt", "somePath/to/dir", PathType.FILE, AccessType.WRITE, true, new Delete(DeleteType.EXISTENT, new ArrayList<>()), null, new HashSet<>(), new ArrayList<>());
    objectManager.writeObject(pathObject);
}
 
开发者ID:p2p-sync,项目名称:versions,代码行数:20,代码来源:DeleteManagerTest.java

示例5: setUp

import org.rmatil.sync.version.api.AccessType; //导入依赖的package包/类
@BeforeClass
public static void setUp()
        throws InputOutputException {
    try {
        // create test dir
        if (! Files.exists(ROOT_TEST_DIR)) {
            Files.createDirectory(ROOT_TEST_DIR);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    storageAdapter = new LocalStorageAdapter(ROOT_TEST_DIR);
    objectManager = new ObjectManager("index.json", "objects", storageAdapter);

    String owner = "Valentino Morose";

    Sharer sharer1 = new Sharer("Natalya Undergrowth", AccessType.READ, new ArrayList<>());
    Sharer sharer2 = new Sharer("Archibald Northbottom", AccessType.WRITE, new ArrayList<>());

    Set<Sharer> sharers = new HashSet<>();
    sharers.add(sharer1);
    sharers.add(sharer2);

    Version v1 = new Version("hashOfContent");
    Version v2 = new Version("hashOfContentAfterModifying");

    List<Version> versions = new ArrayList<>();
    versions.add(v1);
    versions.add(v2);

    pathObject = new PathObject("myFile.txt", "somePath/to/dir", PathType.FILE, AccessType.WRITE, true, new Delete(null, new ArrayList<>()), owner, sharers, versions);
}
 
开发者ID:p2p-sync,项目名称:versions,代码行数:34,代码来源:ObjectManagerTest.java

示例6: testClear

import org.rmatil.sync.version.api.AccessType; //导入依赖的package包/类
@Test
public void testClear()
        throws InputOutputException {
    objectManager.writeObject(pathObject);

    PathObject dirObject = new PathObject("dir", "somePath/to", PathType.DIRECTORY, AccessType.WRITE, false, new Delete(null, new ArrayList<>()), null, new HashSet<>(), new ArrayList<>());
    objectManager.writeObject(dirObject);

    PathObject anotherObject = new PathObject("anotherFile.txt", "somePath/to/dir", PathType.FILE, AccessType.WRITE, false, new Delete(null, new ArrayList<>()), null, new HashSet<>(), new ArrayList<>());
    objectManager.writeObject(anotherObject);

    Index origIndex = objectManager.getIndex();
    assertEquals("not all files are in the index", 3, origIndex.getPaths().size());

    String pathObjectHash = Hash.hash(Config.DEFAULT.getHashingAlgorithm(), pathObject.getAbsolutePath());
    assertNotNull("pathObject should not be null", objectManager.getObject(pathObjectHash));
    String dirObjectHash = Hash.hash(Config.DEFAULT.getHashingAlgorithm(), dirObject.getAbsolutePath());
    assertNotNull("pathObject should not be null", objectManager.getObject(dirObjectHash));
    String anotherObjectHash = Hash.hash(Config.DEFAULT.getHashingAlgorithm(), anotherObject.getAbsolutePath());
    assertNotNull("pathObject should not be null", objectManager.getObject(anotherObjectHash));

    objectManager.clear();

    assertEquals("Paths in index are not cleared", 0, objectManager.getIndex().getPaths().size());

    thrown.expect(InputOutputException.class);
    objectManager.getObject(pathObjectHash);

    thrown.expect(InputOutputException.class);
    objectManager.getObject(dirObjectHash);

    thrown.expect(InputOutputException.class);
    objectManager.getObject(anotherObjectHash);
}
 
开发者ID:p2p-sync,项目名称:versions,代码行数:35,代码来源:ObjectManagerTest.java

示例7: setUp

import org.rmatil.sync.version.api.AccessType; //导入依赖的package包/类
@BeforeClass
public static void setUp()
        throws InputOutputException {
    try {
        // create test dir
        if (! Files.exists(ROOT_TEST_DIR)) {
            Files.createDirectory(ROOT_TEST_DIR);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    storageAdapter = new LocalStorageAdapter(ROOT_TEST_DIR);
    objectManager = new ObjectManager("index.json", "objects", storageAdapter);
    sharerManager = new SharerManager(objectManager);

    owner = "Monsieur F";

    sharer1 = new Sharer("Eleanor Fant", AccessType.READ, new ArrayList<>());
    sharer2 = new Sharer("Eric Widget", AccessType.WRITE, new ArrayList<>());

    Set<Sharer> sharers = new HashSet<>();
    sharers.add(sharer1);
    sharers.add(sharer2);

    List<Version> versions = new ArrayList<>();

    pathObject = new PathObject("myFile.txt", "somePath/to/dir", PathType.FILE, AccessType.WRITE, true, new Delete(null, new ArrayList<>()), owner, sharers, versions);

    objectManager.writeObject(pathObject);
}
 
开发者ID:p2p-sync,项目名称:versions,代码行数:32,代码来源:SharerManagerTest.java

示例8: before

import org.rmatil.sync.version.api.AccessType; //导入依赖的package包/类
@Before
public void before() {
    list = new ArrayList<>();
    list.add("Version1");

    List<String> list2 = new ArrayList<>();
    list2.add("Version1");
    sharer = new Sharer(USERNAME, AccessType.WRITE, list);
    sharer2 = new Sharer(USERNAME, AccessType.WRITE, list2);
}
 
开发者ID:p2p-sync,项目名称:versions,代码行数:11,代码来源:SharerTest.java

示例9: testAccessor

import org.rmatil.sync.version.api.AccessType; //导入依赖的package包/类
@Test
public void testAccessor() {
    assertEquals("Username not equal", USERNAME, sharer.getUsername());
    sharer.setUsername("Shequondolisa Bivouac");
    assertEquals("Username not equal after change", "Shequondolisa Bivouac", sharer.getUsername());
    assertEquals("AccessType not equal", AccessType.WRITE, sharer.getAccessType());
    sharer.setAccessType(AccessType.READ);
    assertEquals("AccessType not equal after changing", AccessType.READ, sharer.getAccessType());

    assertArrayEquals("Sharing history should not be empty", list.toArray(), sharer.getSharingHistory().toArray());
}
 
开发者ID:p2p-sync,项目名称:versions,代码行数:12,代码来源:SharerTest.java

示例10: testEquals

import org.rmatil.sync.version.api.AccessType; //导入依赖的package包/类
@Test
public void testEquals() {
    assertTrue("Sharer should be equals", sharer.equals(sharer2));

    Sharer sharer3 = new Sharer(USERNAME, AccessType.WRITE, new ArrayList<>());

    assertFalse("Sharer3 should not be equal", sharer.equals(sharer3));
}
 
开发者ID:p2p-sync,项目名称:versions,代码行数:9,代码来源:SharerTest.java

示例11: testAccessor

import org.rmatil.sync.version.api.AccessType; //导入依赖的package包/类
@Test
public void testAccessor() {
    assertEquals("Absolute path is not equals", NAME, pathObject.getAbsolutePath());
    assertEquals("PathType is not equal", PathType.DIRECTORY, pathObject.getPathType());
    assertFalse("PathObject is not not shared", pathObject.isShared());
    pathObject.setIsShared(true);
    assertTrue("PathObject should be shared after sharing", pathObject.isShared());
    assertEquals("Sharers are not empty", 0, pathObject.getSharers().size());

    Sharer s1 = new Sharer("a", AccessType.WRITE, new ArrayList<>());
    Set<Sharer> sharer = new HashSet<>();
    sharer.add(s1);
    pathObject.setSharers(sharer);

    assertEquals("Sharers are not equal", sharer, pathObject.getSharers());

    assertEquals("Versions are not empty", 0, pathObject.getVersions().size());

    assertEquals("Access type should be equal", ACCESS_TYPE, pathObject.getAccessType());
    pathObject.setAccessType(AccessType.READ);
    assertEquals("Access type should be equal after writing", AccessType.READ, pathObject.getAccessType());

    assertEquals("Path type should be a dir", PathType.DIRECTORY, pathObject.getPathType());
    pathObject.setPathType(PathType.FILE);
    assertEquals("Path type should be a file", PathType.FILE, pathObject.getPathType());

    assertEquals("Path should not be deleted", DeleteType.EXISTENT, pathObject.getDeleted().getDeleteType());
    assertEquals("Path should have an empty history", 0, pathObject.getDeleted().getDeleteHistory().size());
}
 
开发者ID:p2p-sync,项目名称:versions,代码行数:30,代码来源:PathObjectTest.java

示例12: setUp

import org.rmatil.sync.version.api.AccessType; //导入依赖的package包/类
@BeforeClass
public static void setUp()
        throws InputOutputException {
    try {
        // create test dir
        if (! Files.exists(ROOT_TEST_DIR)) {
            Files.createDirectory(ROOT_TEST_DIR);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    storageAdapter = new LocalStorageAdapter(ROOT_TEST_DIR);
    objectManager = new ObjectManager("index.json", "objects", storageAdapter);
    versionManager = new VersionManager(objectManager);

    String owner = "Mister Pepper";

    Sharer sharer1 = new Sharer("Weir Doe", AccessType.READ, new ArrayList<>());
    Sharer sharer2 = new Sharer("Niles Peppertrout", AccessType.WRITE, new ArrayList<>());

    Set<Sharer> sharers = new HashSet<>();
    sharers.add(sharer1);
    sharers.add(sharer2);

    List<Version> versions = new ArrayList<>();

    pathObject = new PathObject("myFile.txt", "somePath/to/dir", PathType.FILE, AccessType.WRITE, true, new Delete(null, new ArrayList<>()), owner, sharers, versions);

    objectManager.writeObject(pathObject);
}
 
开发者ID:p2p-sync,项目名称:versions,代码行数:32,代码来源:VersionManagerTest.java

示例13: testMoveEventWithHistory

import org.rmatil.sync.version.api.AccessType; //导入依赖的package包/类
@Test
public void testMoveEventWithHistory()
        throws InputOutputException {

    Version v1 = new Version("hashOfV1");
    ArrayList<Version> versions = new ArrayList<>();
    versions.add(v1);

    PathObject testOldPath = new PathObject(
            fileName,
            Naming.getPathWithoutFileName(fileName, oldPath.toString()),
            PathType.FILE,
            AccessType.WRITE,
            false,
            new Delete(DeleteType.EXISTENT, new ArrayList<>()),
            null,
            new HashSet<>(),
            versions
    );

    objectManagerMock.writeObject(testOldPath);
    DeleteEvent deleteEvent = new DeleteEvent(oldPath, fileName, null, firstTimestamp);
    CreateEvent createEvent = new CreateEvent(newPath, fileName, v1.getHash(), secondTimestamp);

    List<IEvent> forceLookupInHistoryList = new ArrayList<>();
    forceLookupInHistoryList.add(deleteEvent);
    forceLookupInHistoryList.add(createEvent);

    List<IEvent> results = moveAggregator.aggregate(forceLookupInHistoryList);

    assertEquals("Result does not only contain the move event", 1, results.size());
    assertThat("Event is not move event", results.get(0), instanceOf(MoveEvent.class));
}
 
开发者ID:p2p-sync,项目名称:aggregator,代码行数:34,代码来源:HistoryMoveAggregatorTest.java

示例14: removeSharer

import org.rmatil.sync.version.api.AccessType; //导入依赖的package包/类
@Override
public synchronized void removeSharer(String username, String pathToFile)
        throws InputOutputException {
    String fileNameHash = Hash.hash(Config.DEFAULT.getHashingAlgorithm(), pathToFile);

    PathObject pathObject = this.objectManager.getObject(fileNameHash);

    boolean isLastSharerForPath = true;
    Sharer sharer = null;

    Iterator<Sharer> itr = pathObject.getSharers().iterator();
    while (itr.hasNext()) {
        Sharer entry = itr.next();
        if (entry.getUsername().equals(username)) {
            sharer = entry;
            itr.remove();
        } else {
            isLastSharerForPath = false;
        }
    }

    if (null == sharer) {
        throw new InputOutputException("Can not remove sharer " + username + " since he is not present in the list");
    }

    // if the sharer is the last sharer for the file, we can remove the shared flag
    if (isLastSharerForPath) {
        pathObject.setIsShared(false);
        pathObject.setOwner(null);
    }

    String nextSharingHistoryEntry = "";
    // make a hash of all previously history entries
    for (String shareHistory : sharer.getSharingHistory()) {
        nextSharingHistoryEntry = Hash.hash(Config.DEFAULT.getHashingAlgorithm(), nextSharingHistoryEntry + shareHistory);
    }

    // now add the new state to the history
    nextSharingHistoryEntry = Hash.hash(Config.DEFAULT.getHashingAlgorithm(), nextSharingHistoryEntry + AccessType.ACCESS_REMOVED.name());
    sharer.getSharingHistory().add(nextSharingHistoryEntry);
    sharer.setAccessType(AccessType.ACCESS_REMOVED);

    pathObject.getSharers().add(sharer);
    this.objectManager.writeObject(pathObject);
}
 
开发者ID:p2p-sync,项目名称:versions,代码行数:46,代码来源:SharerManager.java

示例15: Sharer

import org.rmatil.sync.version.api.AccessType; //导入依赖的package包/类
public Sharer(String username, AccessType accessType, List<String> sharingHistory) {
    this.username = username;
    this.accessType = accessType;
    this.sharingHistory = sharingHistory;
}
 
开发者ID:p2p-sync,项目名称:versions,代码行数:6,代码来源:Sharer.java


注:本文中的org.rmatil.sync.version.api.AccessType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。