use of org.jbei.ice.lib.group.GroupController in project ice by JBEI.
the class FolderPermissions method disablePublicReadAccess.
public boolean disablePublicReadAccess() {
authorization.expectWrite(userId, folder);
GroupController groupController = new GroupController();
Group publicGroup = groupController.createOrRetrievePublicGroup();
permissionDAO.removePermission(null, folder, null, null, publicGroup, true, false);
if (folder.isPropagatePermissions()) {
for (Entry folderContent : folder.getContents()) {
EntryPermissions entryPermissions = new EntryPermissions(Long.toString(folderContent.getId()), userId);
entryPermissions.disablePublicReadAccess();
}
}
return true;
}
use of org.jbei.ice.lib.group.GroupController in project ice by JBEI.
the class FolderPermissions method enablePublicReadAccess.
public boolean enablePublicReadAccess() {
AccessPermission permission = new AccessPermission();
permission.setType(AccessPermission.Type.READ_FOLDER);
permission.setTypeId(folder.getId());
permission.setArticle(AccessPermission.Article.GROUP);
GroupController groupController = new GroupController();
permission.setArticleId(groupController.createOrRetrievePublicGroup().getId());
return createPermission(permission) != null;
}
use of org.jbei.ice.lib.group.GroupController in project ice by JBEI.
the class Folders method getAccountGroups.
private Set<Group> getAccountGroups(Account account) {
Set<Group> accountGroups = new HashSet<>(account.getGroups());
GroupController controller = new GroupController();
Group everybodyGroup = controller.createOrRetrievePublicGroup();
accountGroups.add(everybodyGroup);
return accountGroups;
}
use of org.jbei.ice.lib.group.GroupController in project ice by JBEI.
the class FolderController method getPublicEntries.
/**
* Retrieves entries that are made available publicly
*
* @param sort order of retrieval for the entries
* @param offset start of retrieval
* @param limit maximum number of entries to retrieve
* @param asc whether to retrieve the entries in ascending order
* @return wrapper around the retrieved entries
*/
public FolderDetails getPublicEntries(ColumnField sort, int offset, int limit, boolean asc, List<String> fields) {
Group publicGroup = new GroupController().createOrRetrievePublicGroup();
Set<Group> groups = new HashSet<>();
groups.add(publicGroup);
EntryDAO entryDAO = DAOFactory.getEntryDAO();
List<Long> results = entryDAO.retrieveVisibleEntries(null, groups, sort, asc, offset, limit, null);
long visibleCount = entryDAO.visibleEntryCount(null, groups, null);
FolderDetails details = new FolderDetails();
details.setCount(visibleCount);
for (Long id : results) {
try {
PartData info = ModelToInfoFactory.createTableView(id, fields);
info.setPublicRead(true);
details.getEntries().add(info);
} catch (Exception e) {
Logger.error(e);
}
}
return details;
}
use of org.jbei.ice.lib.group.GroupController in project ice by JBEI.
the class FolderControllerTest method testGetPublicFolders.
@Test
public void testGetPublicFolders() throws Exception {
Account account = AccountCreator.createTestAccount("testGetPublicFolders", false);
Assert.assertNotNull(account);
String userId = account.getEmail();
FolderDetails details = new FolderDetails();
details.setName("test1");
details = controller.createPersonalFolder(userId, details);
Assert.assertNotNull(details);
PermissionsController permissionsController = new PermissionsController();
AccessPermission accessPermission = new AccessPermission();
accessPermission.setArticle(AccessPermission.Article.GROUP);
long publicGroupId = new GroupController().createOrRetrievePublicGroup().getId();
accessPermission.setArticleId(publicGroupId);
accessPermission.setType(AccessPermission.Type.READ_FOLDER);
accessPermission.setTypeId(details.getId());
permissionsController.addPermission(userId, accessPermission);
ArrayList<FolderDetails> results = controller.getPublicFolders();
Assert.assertFalse(results.isEmpty());
Assert.assertEquals(details.getName(), results.get(0).getName());
}
Aggregations