use of org.jbei.ice.lib.account.AccountController in project ice by JBEI.
the class ModelToInfoFactory method getTipViewCommon.
private static PartData getTipViewCommon(Entry entry) {
EntryType type = EntryType.nameToType(entry.getRecordType());
PartData view = new PartData(type);
view.setId(entry.getId());
view.setRecordId(entry.getRecordId());
view.setPartId(entry.getPartNumber());
view.setName(entry.getName());
view.setAlias(entry.getAlias());
view.setCreator(entry.getCreator());
view.setCreatorEmail(entry.getCreatorEmail());
view.setStatus(entry.getStatus());
view.setOwner(entry.getOwner());
view.setOwnerEmail(entry.getOwnerEmail());
view.setSelectionMarkers(EntryUtil.getSelectionMarkersAsList(entry.getSelectionMarkers()));
AccountController accountController = new AccountController();
Account account;
String ownerEmail = entry.getOwnerEmail();
if (ownerEmail != null && (account = accountController.getByEmail(ownerEmail)) != null)
view.setOwnerId(account.getId());
String creatorEmail = entry.getCreatorEmail();
if (creatorEmail != null && (account = accountController.getByEmail(creatorEmail)) != null)
view.setCreatorId(account.getId());
view.setKeywords(entry.getKeywords());
view.setShortDescription(entry.getShortDescription());
view.setCreationTime(entry.getCreationTime().getTime());
view.setModificationTime(entry.getModificationTime().getTime());
view.setBioSafetyLevel(entry.getBioSafetyLevel());
view.setFundingSource(entry.getFundingSource());
view.setPrincipalInvestigator(entry.getPrincipalInvestigator());
return view;
}
use of org.jbei.ice.lib.account.AccountController in project ice by JBEI.
the class ApplicationInitialize method startUp.
/**
* Responsible for initializing the system and checking for the existence of needed
* data (such as settings) and creating as needed
*/
public static void startUp() {
// check for and create public group
GroupController groupController = new GroupController();
groupController.createOrRetrievePublicGroup();
// check for and create admin account
AccountController accountController = new AccountController();
accountController.createAdminAccount();
// check for and create default settings
ConfigurationController configurationController = new ConfigurationController();
configurationController.initPropertyValues();
// check blast
BlastPlus.scheduleBlastIndexRebuildTask(false);
AutoAnnotationBlastDbBuildTask autoAnnotationBlastDbBuildTask = new AutoAnnotationBlastDbBuildTask();
IceExecutorService.getInstance().runTask(autoAnnotationBlastDbBuildTask);
}
use of org.jbei.ice.lib.account.AccountController in project ice by JBEI.
the class UserIdAuthentication method authenticates.
@Override
public String authenticates(String userId, String password) throws AuthenticationException {
AccountController retriever = new AccountController();
Account account = retriever.getByEmail(userId);
if (account == null)
return null;
return account.getEmail();
}
use of org.jbei.ice.lib.account.AccountController in project ice by JBEI.
the class Groups method get.
/**
* Retrieves groups that user is either a member of. Users are implicit members of the groups
* that they create so call also returns those groups
*
* @param userId id of account whose groups are being requested
* @return list of groups that user is a member of
*/
public Results<UserGroup> get(long userId) {
AccountController accountController = new AccountController();
Account userIdAccount = accountDAO.get(userId);
Account account = accountDAO.getByEmail(this.userId);
// TODO : account authorization
if (!accountController.isAdministrator(account.getEmail()) && account.getId() != userIdAccount.getId())
return null;
List<Group> result = dao.retrieveMemberGroups(account);
Results<UserGroup> groupResults = new Results<>();
for (Group group : result) {
UserGroup user = group.toDataTransferObject();
long count = dao.getMemberCount(group.getUuid());
// get clients
count += DAOFactory.getRemoteClientModelDAO().getClientCount(group);
user.setMemberCount(count);
groupResults.getData().add(user);
}
return groupResults;
}
use of org.jbei.ice.lib.account.AccountController in project ice by JBEI.
the class HibernateSearch method checkEnableSecurityFilter.
/**
* Enables the security filter if the account does not have administrative privileges
*
* @param userId identifier for account which is checked for administrative privs
* @param fullTextQuery search fulltextquery for which filter is enabled
*/
protected FullTextQuery checkEnableSecurityFilter(String userId, FullTextQuery fullTextQuery) {
Set<String> groupUUIDs;
if (StringUtils.isEmpty(userId)) {
groupUUIDs = new HashSet<>();
groupUUIDs.add(GroupController.PUBLIC_GROUP_UUID);
} else {
AccountController accountController = new AccountController();
if (accountController.isAdministrator(userId)) {
return fullTextQuery;
}
groupUUIDs = new GroupController().retrieveAccountGroupUUIDs(userId);
}
fullTextQuery.enableFullTextFilter("security").setParameter("account", userId).setParameter("groupUUids", groupUUIDs);
return fullTextQuery;
}
Aggregations