@Test public void testCreateDataRoom() throws Exception { final RandomStringService randomStringService = new AlphanumericRandomStringService(); final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session).withCache(cache); final Path room = new SDSDirectoryFeature(session, nodeid).mkdir( new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume, Path.Type.triplecrypt)), null, new TransferStatus()); assertNotNull(room.attributes().getVersionId()); assertTrue(new DefaultFindFeature(session).find(room)); new SDSDeleteFeature(session, nodeid).delete(Collections.<Path>singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback()); assertFalse(new DefaultFindFeature(session).find(room)); }
@Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { if(containerService.isContainer(folder)) { final CreateRoomRequest roomRequest = new CreateRoomRequest(); roomRequest.setParentId(null); final UserAccountWrapper user = session.userAccount(); roomRequest.addAdminIdsItem(user.getId()); roomRequest.setAdminGroupIds(null); if(!folder.getParent().isRoot()) { roomRequest.setParentId(Long.parseLong(nodeid.getFileid(folder.getParent(), new DisabledListProgressListener()))); } roomRequest.setName(folder.getName()); final Node r = new NodesApi(session.getClient()).createRoom(roomRequest, StringUtils.EMPTY, null); return new Path(folder.getParent(), folder.getName(), EnumSet.of(Path.Type.directory, Path.Type.volume), new SDSAttributesFinderFeature(session, nodeid).toAttributes(r)); } else { final CreateFolderRequest folderRequest = new CreateFolderRequest(); folderRequest.setParentId(Long.parseLong(nodeid.getFileid(folder.getParent(), new DisabledListProgressListener()))); folderRequest.setName(folder.getName()); final Node f = new NodesApi(session.getClient()).createFolder(folderRequest, StringUtils.EMPTY, null); return new Path(folder.getParent(), folder.getName(), folder.getType(), new SDSAttributesFinderFeature(session, nodeid).toAttributes(f)); } } catch(ApiException e) { throw new SDSExceptionMappingService().map("Cannot create folder {0}", e, folder); } }
SDSDirectoryFeature implements Directory<VersionId> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { if(containerService.isContainer(folder)) { final CreateRoomRequest roomRequest = new CreateRoomRequest(); roomRequest.setParentId(null); final UserAccountWrapper user = session.userAccount(); roomRequest.addAdminIdsItem(user.getId()); roomRequest.setAdminGroupIds(null); if(!folder.getParent().isRoot()) { roomRequest.setParentId(Long.parseLong(nodeid.getFileid(folder.getParent(), new DisabledListProgressListener()))); } roomRequest.setName(folder.getName()); final Node r = new NodesApi(session.getClient()).createRoom(roomRequest, StringUtils.EMPTY, null); return new Path(folder.getParent(), folder.getName(), EnumSet.of(Path.Type.directory, Path.Type.volume), new SDSAttributesFinderFeature(session, nodeid).toAttributes(r)); } else { final CreateFolderRequest folderRequest = new CreateFolderRequest(); folderRequest.setParentId(Long.parseLong(nodeid.getFileid(folder.getParent(), new DisabledListProgressListener()))); folderRequest.setName(folder.getName()); final Node f = new NodesApi(session.getClient()).createFolder(folderRequest, StringUtils.EMPTY, null); return new Path(folder.getParent(), folder.getName(), folder.getType(), new SDSAttributesFinderFeature(session, nodeid).toAttributes(f)); } } catch(ApiException e) { throw new SDSExceptionMappingService().map("Cannot create folder {0}", e, folder); } } }
SDSDirectoryFeature implements Directory<VersionId> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { if(containerService.isContainer(folder)) { final CreateRoomRequest roomRequest = new CreateRoomRequest(); roomRequest.setParentId(null); final UserAccountWrapper user = session.userAccount(); roomRequest.addAdminIdsItem(user.getId()); roomRequest.setAdminGroupIds(null); if(!folder.getParent().isRoot()) { roomRequest.setParentId(Long.parseLong(nodeid.getFileid(folder.getParent(), new DisabledListProgressListener()))); } roomRequest.setName(folder.getName()); final Node r = new NodesApi(session.getClient()).createRoom(roomRequest, StringUtils.EMPTY, null); return new Path(folder.getParent(), folder.getName(), EnumSet.of(Path.Type.directory, Path.Type.volume), new SDSAttributesFinderFeature(session, nodeid).toAttributes(r)); } else { final CreateFolderRequest folderRequest = new CreateFolderRequest(); folderRequest.setParentId(Long.parseLong(nodeid.getFileid(folder.getParent(), new DisabledListProgressListener()))); folderRequest.setName(folder.getName()); final Node f = new NodesApi(session.getClient()).createFolder(folderRequest, StringUtils.EMPTY, null); return new Path(folder.getParent(), folder.getName(), folder.getType(), new SDSAttributesFinderFeature(session, nodeid).toAttributes(f)); } } catch(ApiException e) { throw new SDSExceptionMappingService().map("Cannot create folder {0}", e, folder); } } SDSDirectoryFeature(final SDSSession session, final SDSNodeIdProvider nodeid); }
SDSDirectoryFeature implements Directory<VersionId> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { if(containerService.isContainer(folder)) { final CreateRoomRequest roomRequest = new CreateRoomRequest(); roomRequest.setParentId(null); final UserAccountWrapper user = session.userAccount(); roomRequest.addAdminIdsItem(user.getId()); roomRequest.setAdminGroupIds(null); if(!folder.getParent().isRoot()) { roomRequest.setParentId(Long.parseLong(nodeid.getFileid(folder.getParent(), new DisabledListProgressListener()))); } roomRequest.setName(folder.getName()); final Node r = new NodesApi(session.getClient()).createRoom(roomRequest, StringUtils.EMPTY, null); return new Path(folder.getParent(), folder.getName(), EnumSet.of(Path.Type.directory, Path.Type.volume), new SDSAttributesFinderFeature(session, nodeid).toAttributes(r)); } else { final CreateFolderRequest folderRequest = new CreateFolderRequest(); folderRequest.setParentId(Long.parseLong(nodeid.getFileid(folder.getParent(), new DisabledListProgressListener()))); folderRequest.setName(folder.getName()); final Node f = new NodesApi(session.getClient()).createFolder(folderRequest, StringUtils.EMPTY, null); return new Path(folder.getParent(), folder.getName(), folder.getType(), new SDSAttributesFinderFeature(session, nodeid).toAttributes(f)); } } catch(ApiException e) { throw new SDSExceptionMappingService().map("Cannot create folder {0}", e, folder); } } SDSDirectoryFeature(final SDSSession session, final SDSNodeIdProvider nodeid); @Override Path mkdir(final Path folder, final String region, final TransferStatus status); @Override boolean isSupported(final Path workdir, final String name); @Override Directory<VersionId> withWriter(final Write<VersionId> writer); }
SDSDirectoryFeature implements Directory<VersionId> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { if(containerService.isContainer(folder)) { final CreateRoomRequest roomRequest = new CreateRoomRequest(); roomRequest.setParentId(null); final UserAccountWrapper user = session.userAccount(); roomRequest.addAdminIdsItem(user.getId()); roomRequest.setAdminGroupIds(null); if(!folder.getParent().isRoot()) { roomRequest.setParentId(Long.parseLong(nodeid.getFileid(folder.getParent(), new DisabledListProgressListener()))); } roomRequest.setName(folder.getName()); final Node r = new NodesApi(session.getClient()).createRoom(roomRequest, StringUtils.EMPTY, null); return new Path(folder.getParent(), folder.getName(), EnumSet.of(Path.Type.directory, Path.Type.volume), new SDSAttributesFinderFeature(session, nodeid).toAttributes(r)); } else { final CreateFolderRequest folderRequest = new CreateFolderRequest(); folderRequest.setParentId(Long.parseLong(nodeid.getFileid(folder.getParent(), new DisabledListProgressListener()))); folderRequest.setName(folder.getName()); final Node f = new NodesApi(session.getClient()).createFolder(folderRequest, StringUtils.EMPTY, null); return new Path(folder.getParent(), folder.getName(), folder.getType(), new SDSAttributesFinderFeature(session, nodeid).toAttributes(f)); } } catch(ApiException e) { throw new SDSExceptionMappingService().map("Cannot create folder {0}", e, folder); } } SDSDirectoryFeature(final SDSSession session, final SDSNodeIdProvider nodeid); @Override Path mkdir(final Path folder, final String region, final TransferStatus status); @Override boolean isSupported(final Path workdir, final String name); @Override Directory<VersionId> withWriter(final Write<VersionId> writer);  }