本文整理汇总了Java中org.hive2hive.core.model.UserPermission类的典型用法代码示例。如果您正苦于以下问题:Java UserPermission类的具体用法?Java UserPermission怎么用?Java UserPermission使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UserPermission类属于org.hive2hive.core.model包,在下文中一共展示了UserPermission类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onFileShare
import org.hive2hive.core.model.UserPermission; //导入依赖的package包/类
@Override
@Handler
public void onFileShare(IFileShareEvent fileEvent) {
String permissionStr = "";
for (UserPermission p : fileEvent.getUserPermissions()) {
permissionStr = permissionStr.concat(p.getUserId() + " ");
if(p.getPermission() == PermissionType.READ){
permissionStr = permissionStr.concat("Read");
} else {
permissionStr = permissionStr.concat("Read / Write");
}
}
logger.info("Share: Invited by: {}, Permission: [{}]", fileEvent.getInvitedBy(), permissionStr, fileEvent.getFile());
fileEvent.getInvitedBy();
Set<UserPermission> permissions = fileEvent.getUserPermissions();
String invitedBy = fileEvent.getInvitedBy();
FileInfo file = new FileInfo(fileEvent);
StringBuilder sb = new StringBuilder();
sb.append("User ").append(invitedBy).append(" shared the folder ").
append(fileEvent.getFile().toPath()).append(" with you.");
getMessageBus().post(new InformationNotification("Shared folder", sb.toString())).now();
publishMessage(new RemoteShareFolderMessage(file, permissions, invitedBy));
}
示例2: onShareSucceeded
import org.hive2hive.core.model.UserPermission; //导入依赖的package包/类
private void onShareSucceeded() {
Runnable succeeded = new Runnable() {
@Override
public void run() {
setStatus("Sharing succeeded.");
setBusy(false);
Alert dlg = DialogUtils.createAlert(AlertType.INFORMATION);
dlg.setTitle("Folder Sharing");
dlg.setHeaderText("Folder sharing finished");
dlg.setContentText("The user is granted access to the folder.");
dlg.showAndWait();
getStage().close();
}
};
if (Platform.isFxApplicationThread()) {
succeeded.run();
} else {
Platform.runLater(succeeded);
}
FileInfo file = new FileInfo(folderToShare, true);
UserPermission permission = new UserPermission(getUsername(), PermissionType.WRITE);
messageBus.publish(new LocalShareFolderMessage(file, permission));
}
示例3: initialize
import org.hive2hive.core.model.UserPermission; //导入依赖的package包/类
@Override
public void initialize(URL arg0, ResourceBundle arg1) {
logger.debug("Initialize Properties!");
if(item != null && item.getPermissions() != null){
for(UserPermission perm : item.getPermissions()){
StringBuilder sb = new StringBuilder();
sb.append(perm.getUserId());
PermissionType type = perm.getPermission();
if(type == PermissionType.READ){
sb.append(" (Read)");
} else {
sb.append(" (Read + Write)");
}
ImageView icon = SynchronizationUtils.getSharedFolderSuccessIcon();
Label label = new Label(sb.toString());
label.setGraphic(icon);
sharedListView.getItems().add(label);
}
}
}
示例4: createShareProcess
import org.hive2hive.core.model.UserPermission; //导入依赖的package包/类
@Override
public IProcessComponent<Void> createShareProcess(File folder, String userId, PermissionType permission)
throws NoPeerConnectionException, NoSessionException, IllegalArgumentException {
if (folder == null) {
throw new IllegalArgumentException("Folder to share cannot be null");
} else if (!folder.isDirectory()) {
throw new IllegalArgumentException("File has to be a folder.");
} else if (!folder.exists()) {
throw new IllegalArgumentException("Folder does not exist.");
}
H2HSession session = networkManager.getSession();
// folder must be in the given root directory
if (!FileUtil.isInH2HDirectory(session.getFileAgent(), folder)) {
throw new IllegalArgumentException("Folder must be in root of the H2H directory.");
}
// sharing root folder is not allowed
if (folder.equals(session.getRootFile())) {
throw new IllegalArgumentException("Root folder of the H2H directory can't be shared.");
}
return ProcessFactory.instance().createShareProcess(folder, new UserPermission(userId, permission), networkManager);
}
示例5: createShareProcess
import org.hive2hive.core.model.UserPermission; //导入依赖的package包/类
public IProcessComponent<Void> createShareProcess(File folder, UserPermission permission, NetworkManager networkManager)
throws NoPeerConnectionException, NoSessionException {
ShareProcessContext context = new ShareProcessContext(folder, permission);
// process composition
SyncProcess process = new SyncProcess();
process.add(new VerifyFriendIdStep(networkManager.getSession().getKeyManager(), permission.getUserId()));
process.add(new UpdateUserProfileStep(context, networkManager.getSession(), networkManager.getEncryption()));
process.add(new InitializeMetaUpdateStep(context, networkManager.getDataManager()));
process.add(new PrepareNotificationsStep(context, networkManager.getUserId(), networkManager.getEncryption()));
process.add(createNotificationProcess(context, networkManager));
process.setName("Share Process");
return process;
}
示例6: createItem
import org.hive2hive.core.model.UserPermission; //导入依赖的package包/类
private SyncTreeItem createItem(Path path, boolean isSynched,
boolean isFile, Set<UserPermission> permissions) {
PathItem pathItem = new PathItem(path, isFile, permissions);
SyncTreeItem newItem = new SyncTreeItem(pathItem);
newItem.updateIsSelectedInUIThread(isSynched);
newItem.setSelected(isSynched);
return newItem;
}
示例7: FSTSerializer
import org.hive2hive.core.model.UserPermission; //导入依赖的package包/类
/**
* Create a FST serializer (faster and more efficient than Java default serialization).
*
* @param useUnsafe <code>true</code> to use <code>sun.misc.Unsafe</code> class, otherwise, a fallback is
* used.
* @param securityProvider the security provider, needed to decode key pairs correctly
*/
public FSTSerializer(boolean useUnsafe, ISecurityClassProvider securityProvider) {
if (!useUnsafe) {
// don't use sun.misc.Unsafe class
FSTUtil.unFlaggedUnsafe = null;
logger.debug("Disabled the use of 'sun.misc.Unsafe' for the serialization");
}
fst = FSTConfiguration.createDefaultConfiguration();
// register all often serialized classes for speedup. Note that every peer should have the same
// configuration, which also depends on the order! Changing these registrations might break backward
// compatibility!
fst.registerClass(UserProfile.class, FolderIndex.class, FileIndex.class, UserPermission.class, Locations.class,
UserPublicKey.class, MetaFileSmall.class, MetaFileLarge.class, FileVersion.class, MetaChunk.class,
Chunk.class, EncryptedNetworkContent.class, ContactPeerMessage.class, ResponseMessage.class);
// for all public / private keys for full compatibility among multiple security providers
fst.registerClass(securityProvider.getRSAPublicKeyClass(), securityProvider.getRSAPrivateKeyClass(),
securityProvider.getRSAPrivateCrtKeyClass());
// for performance improvements, native TomP2P classes which are serialized quite often
fst.registerClass(PeerAddress.class, PeerSocketAddress.class, Number160.class);
// Since PeerAddresses are serialized very often, this is just an efficiency improvement
fst.registerSerializer(PeerAddress.class, new FSTPeerAddressSerializer(), false);
// register the acceptance reply enum
fst.registerClass(AcceptanceReply.class);
}
示例8: getUserPermission
import org.hive2hive.core.model.UserPermission; //导入依赖的package包/类
@Override
public UserPermission getUserPermission(String userId) {
for (UserPermission userPermission : permissions) {
if (userPermission.getUserId().equalsIgnoreCase(userId)) {
return userPermission;
}
}
return null;
}
示例9: FileNode
import org.hive2hive.core.model.UserPermission; //导入依赖的package包/类
public FileNode(FileNode parent, File file, String path, byte[] contentHash, Set<UserPermission> userPermissions) {
this.parent = parent;
this.file = file;
this.path = path;
this.contentHash = contentHash;
this.userPermissions = userPermissions;
this.children = new ArrayList<FileNode>();
}
示例10: copyTree
import org.hive2hive.core.model.UserPermission; //导入依赖的package包/类
private FileNode copyTree(Index current, FileNode parent) {
if (current == null) {
return parent;
}
String path = current.getFullPath();
File file = new File(rootFile, path);
byte[] hash = null;
Set<UserPermission> userPermissions;
if (current.isFile()) {
FileIndex fileIndex = (FileIndex) current;
hash = fileIndex.getHash();
userPermissions = fileIndex.getParent().getCalculatedUserPermissions();
} else {
userPermissions = ((FolderIndex) current).getCalculatedUserPermissions();
}
FileNode node = new FileNode(parent, file, path, hash, userPermissions);
if (parent != null) {
parent.getChildren().add(node);
}
if (current.isFolder()) {
// current is a folder, visit recursively
for (Index child : ((FolderIndex) current).getChildren()) {
copyTree(child, node);
}
}
return node;
}
示例11: checkMovedIndex
import org.hive2hive.core.model.UserPermission; //导入依赖的package包/类
private void checkMovedIndex(File movedFile, File root, UserProfile userProfile) throws GetFailedException,
NoSessionException {
Index index = userProfile.getFileByPath(movedFile, root);
Assert.assertNotNull(index);
// check isShared flag
Assert.assertFalse(index.isShared());
// check if content protection keys are the default content protection key
Assert.assertTrue(index.getProtectionKeys().getPrivate().equals(userProfile.getProtectionKeys().getPrivate()));
Assert.assertTrue(index.getProtectionKeys().getPublic().equals(userProfile.getProtectionKeys().getPublic()));
// check write access
Assert.assertTrue(index.canWrite());
// check user permissions
Set<String> users = index.getCalculatedUserList();
Assert.assertEquals(1, users.size());
Assert.assertTrue(users.contains(userProfile.getUserId()));
// check user permissions in case of a folder
if (movedFile.isDirectory()) {
Assert.assertTrue(index.isFolder());
Set<UserPermission> permissions = ((FolderIndex) index).getCalculatedUserPermissions();
Assert.assertEquals(1, permissions.size());
Assert.assertTrue(permissions.contains(new UserPermission(userProfile.getUserId(), PermissionType.WRITE)));
} else {
Assert.assertTrue(index.isFile());
}
}
示例12: checkIndexesAfterMoving
import org.hive2hive.core.model.UserPermission; //导入依赖的package包/类
private void checkIndexesAfterMoving(File oldFileA, File oldFileB, File newFileA) throws GetFailedException,
NoSessionException {
UserProfile userProfileA = nodeA.getSession().getProfileManager().readUserProfile();
Index indexOldA = userProfileA.getFileByPath(oldFileA, nodeA.getSession().getRootFile());
// should have been deleted
Assert.assertNull(indexOldA);
UserProfile userProfileB = nodeB.getSession().getProfileManager().readUserProfile();
Index indexOldB = userProfileB.getFileByPath(oldFileB, nodeB.getSession().getRootFile());
// should have been deleted
Assert.assertNull(indexOldB);
Index indexNew = userProfileA.getFileByPath(newFileA, nodeA.getSession().getRootFile());
// should have been created
Assert.assertNotNull(indexNew);
// check isShared flag
Assert.assertFalse(indexNew.isShared());
// check if content protection keys are the default content protection key
Assert.assertTrue(indexNew.getProtectionKeys().getPrivate().equals(userProfileA.getProtectionKeys().getPrivate()));
Assert.assertTrue(indexNew.getProtectionKeys().getPublic().equals(userProfileA.getProtectionKeys().getPublic()));
// check write access
Assert.assertTrue(indexNew.canWrite());
// check user permissions
Set<String> users = indexNew.getCalculatedUserList();
Assert.assertEquals(1, users.size());
Assert.assertTrue(users.contains(userProfileA.getUserId()));
// check user permissions in case of a folder
if (indexNew.isFolder()) {
Set<UserPermission> permissions = ((FolderIndex) indexNew).getCalculatedUserPermissions();
Assert.assertEquals(1, permissions.size());
Assert.assertTrue(permissions.contains(new UserPermission(userProfileA.getUserId(), PermissionType.WRITE)));
}
}
示例13: RemoteShareFolderMessage
import org.hive2hive.core.model.UserPermission; //导入依赖的package包/类
public RemoteShareFolderMessage(FileInfo file, Set<UserPermission> permissions, String invitedBy) {
super(file);
this.permissions = permissions;
this.invitedBy = invitedBy;
}
示例14: getUserPermissions
import org.hive2hive.core.model.UserPermission; //导入依赖的package包/类
public Set<UserPermission> getUserPermissions() {
return permissions;
}
示例15: LocalShareFolderMessage
import org.hive2hive.core.model.UserPermission; //导入依赖的package包/类
public LocalShareFolderMessage(FileInfo file, UserPermission newPermission) {
super(file);
this.newPermission = newPermission;
}