Search in sources :

Example 11 with AccountController

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;
}
Also used : AccountController(org.jbei.ice.lib.account.AccountController)

Example 12 with AccountController

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);
}
Also used : ConfigurationController(org.jbei.ice.lib.config.ConfigurationController) GroupController(org.jbei.ice.lib.group.GroupController) AutoAnnotationBlastDbBuildTask(org.jbei.ice.lib.entry.sequence.annotation.AutoAnnotationBlastDbBuildTask) AccountController(org.jbei.ice.lib.account.AccountController)

Example 13 with AccountController

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();
}
Also used : Account(org.jbei.ice.storage.model.Account) AccountController(org.jbei.ice.lib.account.AccountController)

Example 14 with AccountController

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;
}
Also used : Account(org.jbei.ice.storage.model.Account) Group(org.jbei.ice.storage.model.Group) UserGroup(org.jbei.ice.lib.dto.group.UserGroup) Results(org.jbei.ice.lib.dto.common.Results) AccountController(org.jbei.ice.lib.account.AccountController) UserGroup(org.jbei.ice.lib.dto.group.UserGroup)

Example 15 with AccountController

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;
}
Also used : GroupController(org.jbei.ice.lib.group.GroupController) AccountController(org.jbei.ice.lib.account.AccountController)

Aggregations

AccountController (org.jbei.ice.lib.account.AccountController)15 Account (org.jbei.ice.storage.model.Account)5 PermissionException (org.jbei.ice.lib.access.PermissionException)3 GroupController (org.jbei.ice.lib.group.GroupController)3 Configuration (org.jbei.ice.storage.model.Configuration)3 ArrayList (java.util.ArrayList)2 ConfigurationKey (org.jbei.ice.lib.dto.ConfigurationKey)2 Group (org.jbei.ice.storage.model.Group)2 RemotePartner (org.jbei.ice.storage.model.RemotePartner)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 Path (java.nio.file.Path)1 Date (java.util.Date)1 AccountTransfer (org.jbei.ice.lib.account.AccountTransfer)1 ConfigurationController (org.jbei.ice.lib.config.ConfigurationController)1 Setting (org.jbei.ice.lib.dto.Setting)1 Results (org.jbei.ice.lib.dto.common.Results)1 UserGroup (org.jbei.ice.lib.dto.group.UserGroup)1 RegistryPartner (org.jbei.ice.lib.dto.web.RegistryPartner)1