当前位置: 首页>>代码示例>>Java>>正文


Java Nature类代码示例

本文整理汇总了Java中nl.strohalm.cyclos.entities.groups.Group.Nature的典型用法代码示例。如果您正苦于以下问题:Java Nature类的具体用法?Java Nature怎么用?Java Nature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Nature类属于nl.strohalm.cyclos.entities.groups.Group包,在下文中一共展示了Nature类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: register

import nl.strohalm.cyclos.entities.groups.Group.Nature; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object register(final Element element, final boolean forceChangePassword, final String remoteAddress) {
    // We need the group in order to check anything
    if (element.getGroup() == null) {
        throw new ValidationException();
    }

    if (LoggedUser.hasUser()) {
        // When no logged user, we don't need to check permission here - it will only validate the given initial group
        permissionService.checkManages(element.getGroup());
        Nature groupNature = element.getGroup().getNature();
        permissionService.permission()
                .admin(groupNature == Group.Nature.MEMBER || groupNature == Group.Nature.BROKER ? AdminMemberPermission.MEMBERS_REGISTER : AdminAdminPermission.ADMINS_REGISTER)
                .broker(BrokerPermission.MEMBERS_REGISTER)
                .member(MemberPermission.OPERATORS_MANAGE)
                .check();
    }
    // Check the initial group
    PermissionHelper.checkContains((Collection<Group>) getPossibleInitialGroups(element), element.getGroup());

    return elementService.register(element, forceChangePassword, remoteAddress);
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:24,代码来源:ElementServiceSecurity.java

示例2: readGroup

import nl.strohalm.cyclos.entities.groups.Group.Nature; //导入依赖的package包/类
private Group readGroup(final ActionContext context) {
    final EditGroupForm form = context.getForm();
    final long id = form.getGroupId();
    Group.Nature nature;
    final boolean isInsert = (id <= 0L);
    if (isInsert) {
        nature = getGroupNature(context, false);
        // On insert, empty status means normal
        final String status = (String) form.getGroup("status");
        if (StringUtils.isEmpty(status)) {
            form.setGroup("status", Group.Status.NORMAL.name());
        }
    } else {
        nature = groupService.load(id).getNature();
    }
    final Group group = getDataBinder(nature).readFromString(form.getGroup());
    if (nature == Nature.OPERATOR) {
        // Ensure to set the logged member on operator groups, as this is not read from request
        final Member member = (Member) context.getElement();
        final OperatorGroup operatorGroup = (OperatorGroup) group;
        operatorGroup.setMember(member);
    }
    return group;
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:25,代码来源:EditGroupAction.java

示例3: applyAllowedDocumentNatures

import nl.strohalm.cyclos.entities.groups.Group.Nature; //导入依赖的package包/类
/**
 * Filters the natures query parameter
 */
private boolean applyAllowedDocumentNatures(final DocumentQuery documentQuery) {
    List<Document.Nature> allowedNatures = new ArrayList<Document.Nature>();

    if (LoggedUser.isAdministrator()) {
        // Administrator through a member's profile, only member and dynamic documents
        if (documentQuery.getMember() != null) {
            allowedNatures.add(Document.Nature.DYNAMIC);
            allowedNatures.add(Document.Nature.MEMBER);
        } else {
            // Administrator viewing global documents, only dynamic and static
            allowedNatures.add(Document.Nature.DYNAMIC);
            allowedNatures.add(Document.Nature.STATIC);
        }
    } else if (LoggedUser.isMember()) {
        Member member = fetchService.fetch(documentQuery.getMember(), Member.Relationships.BROKER);
        if (LoggedUser.isBroker() && !LoggedUser.member().equals(member)) {
            // Brokers can only view member and dynamic documents of his brokered members.
            if ((member.getBroker() != null) && member.getBroker().equals(LoggedUser.member())) {
                allowedNatures.add(Document.Nature.DYNAMIC);
                allowedNatures.add(Document.Nature.MEMBER);
            } else { // It's the broker documents.
                allowedNatures.add(Document.Nature.DYNAMIC);
                allowedNatures.add(Document.Nature.MEMBER);
                allowedNatures.add(Document.Nature.STATIC);
            }
        } else {
            // Members are allowed to view all types of documents.
            allowedNatures.add(Document.Nature.DYNAMIC);
            allowedNatures.add(Document.Nature.MEMBER);
            allowedNatures.add(Document.Nature.STATIC);
        }
    }

    Collection<Document.Nature> natures = PermissionHelper.checkSelection(allowedNatures, documentQuery.getNatures());
    documentQuery.setNatures(natures);
    return natures != null;
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:41,代码来源:DocumentServiceSecurity.java

示例4: checkView

import nl.strohalm.cyclos.entities.groups.Group.Nature; //导入依赖的package包/类
private void checkView(final Document doc) {

        if (doc instanceof MemberDocument) {
            MemberDocument mDoc = (MemberDocument) doc;
            mDoc = fetchService.fetch(mDoc, MemberDocument.Relationships.MEMBER);
            final MemberDocument.Visibility visibility = mDoc.getVisibility();

            // Check the visibility of the document
            if (((LoggedUser.group().getNature() == Nature.MEMBER) && visibility != MemberDocument.Visibility.MEMBER) || (LoggedUser.isBroker() && visibility == MemberDocument.Visibility.ADMIN)) {
                throw new PermissionDeniedException();
            }

            // Check the permission
            permissionService.permission(mDoc.getMember())
                    .admin(AdminMemberPermission.DOCUMENTS_MANAGE_MEMBER)
                    .broker(BrokerPermission.DOCUMENTS_VIEW_MEMBER)
                    .member()
                    .check();

        } else {
            // Check whether the document can be viewed by the logged user
            permissionService.permission()
                    .adminFor(AdminMemberPermission.DOCUMENTS_DETAILS, doc)
                    .brokerFor(BrokerPermission.DOCUMENTS_VIEW, doc)
                    .memberFor(MemberPermission.DOCUMENTS_VIEW, doc).check();
        }
    }
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:28,代码来源:DocumentServiceSecurity.java

示例5: getGroupNature

import nl.strohalm.cyclos.entities.groups.Group.Nature; //导入依赖的package包/类
private static Group.Nature getGroupNature(final ActionContext context, final boolean acceptEmpty) {
    try {
        final EditGroupForm form = context.getForm();
        final String nature = (String) form.getGroup("nature");
        if (acceptEmpty && StringUtils.isBlank(nature)) {
            return null;
        } else {
            return Group.Nature.valueOf(nature);
        }
    } catch (final Exception e) {
        throw new ValidationException();
    }
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:14,代码来源:EditGroupAction.java

示例6: getDataBinder

import nl.strohalm.cyclos.entities.groups.Group.Nature; //导入依赖的package包/类
public DataBinder<? extends Group> getDataBinder(final Group.Nature nature) {
    if (dataBinders == null) {
        dataBinders = new EnumMap<Group.Nature, DataBinder<? extends Group>>(Group.Nature.class);

        final BeanBinder<BasicGroupSettings> basicSettingsBinder = BeanBinder.instance(BasicGroupSettings.class, "basicSettings");
        final BeanBinder<MemberGroupSettings> memberSettingsBinder = BeanBinder.instance(MemberGroupSettings.class, "memberSettings");

        final BeanBinder<AdminGroup> adminGroupBinder = BeanBinder.instance(AdminGroup.class);
        initBasic(adminGroupBinder, basicSettingsBinder);
        initSystem(adminGroupBinder);
        dataBinders.put(Group.Nature.ADMIN, adminGroupBinder);

        final BeanBinder<MemberGroup> memberGroupBinder = BeanBinder.instance(MemberGroup.class);
        initBasic(memberGroupBinder, basicSettingsBinder);
        initSystem(memberGroupBinder);
        initMember(memberGroupBinder, memberSettingsBinder);
        dataBinders.put(Group.Nature.MEMBER, memberGroupBinder);

        final BeanBinder<OperatorGroup> operatorGroupBinder = BeanBinder.instance(OperatorGroup.class);
        initBasic(operatorGroupBinder, basicSettingsBinder);
        initOperator(operatorGroupBinder);
        dataBinders.put(Group.Nature.OPERATOR, operatorGroupBinder);

        final BeanBinder<BrokerGroup> brokerGroupBinder = BeanBinder.instance(BrokerGroup.class);
        initBasic(brokerGroupBinder, basicSettingsBinder);
        initSystem(brokerGroupBinder);
        initMember(brokerGroupBinder, memberSettingsBinder);
        initBroker(brokerGroupBinder);
        dataBinders.put(Group.Nature.BROKER, brokerGroupBinder);
    }
    return dataBinders.get(nature);
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:33,代码来源:EditGroupAction.java

示例7: search

import nl.strohalm.cyclos.entities.groups.Group.Nature; //导入依赖的package包/类
@Override
public List<Session> search(final SessionQuery query) {
    Map<String, Object> params = new HashMap<String, Object>();
    StringBuilder hql = new StringBuilder();
    hql.append(" select s ");
    hql.append(" from Session s left join fetch s.user u left join fetch u.element e left join fetch e.group g ");
    hql.append(" where s.expirationDate > CURRENT_TIMESTAMP ");

    // Filter by nature - use the discriminator directly
    Collection<Nature> natures = query.getNatures();
    if (CollectionUtils.isNotEmpty(natures)) {
        Collection<String> values = new ArrayList<String>(natures.size());
        for (Nature nature : natures) {
            values.add(nature.getDiscriminator());
        }
        JpaQueryHelper.addInParameterToQuery(hql, params, "s.user.element.group.class", values);
    }

    // Apply the filter by group, which has a distinct semantic on operators
    boolean hasOperator = CollectionUtils.isEmpty(natures) || natures.contains(Group.Nature.OPERATOR);
    if (hasOperator) {
        // The groups may be for either the group or, if operators, the member group
        hql.append("and (s.user.element.group in :groups or exists (");
        hql.append("    select o.id");
        hql.append("    from Operator o");
        hql.append("    where o = s.user.element");
        hql.append("      and o.member.group in :groups");
        hql.append("))");
        params.put("groups", query.getGroups());
    } else {
        // Group filter will apply directly
        JpaQueryHelper.addInParameterToQuery(hql, params, "s.user.element.group", query.getGroups());
    }

    // Filter by operator member
    if (query.getMember() != null) {
        hql.append("and exists (");
        hql.append("    select o.id");
        hql.append("    from Operator o");
        hql.append("    where o = s.user.element");
        hql.append("      and o.member = :member");
        hql.append(")");
        params.put("member", query.getMember());
    }
    JpaQueryHelper.appendOrder(hql, "s.user.element.name");
    return list(query, hql.toString(), params);
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:48,代码来源:SessionDAOImpl.java

示例8: searchSessions

import nl.strohalm.cyclos.entities.groups.Group.Nature; //导入依赖的package包/类
@Override
public List<Session> searchSessions(final SessionQuery query) {
    if (LoggedUser.isAdministrator()) {
        Collection<Nature> natures = query.getNatures();
        if (CollectionUtils.isEmpty(natures)) {
            // As usual, empty means all. We want to ensure one-by-one, so we add them here
            natures = EnumSet.allOf(Nature.class);
        }
        if (!permissionService.hasPermission(AdminSystemPermission.STATUS_VIEW_CONNECTED_ADMINS)) {
            natures.remove(Nature.ADMIN);
        }
        if (!permissionService.hasPermission(AdminSystemPermission.STATUS_VIEW_CONNECTED_MEMBERS)) {
            natures.remove(Nature.MEMBER);
        }
        if (!permissionService.hasPermission(AdminSystemPermission.STATUS_VIEW_CONNECTED_BROKERS)) {
            natures.remove(Nature.BROKER);
        }
        if (!permissionService.hasPermission(AdminSystemPermission.STATUS_VIEW_CONNECTED_OPERATORS)) {
            natures.remove(Nature.OPERATOR);
        }
        if (natures.isEmpty()) {
            // Nothing left to see
            throw new PermissionDeniedException();
        }
        // Apply the allowed groups
        Collection<Group> allowedGroups = new HashSet<Group>();
        allowedGroups.addAll(permissionService.getVisibleMemberGroups());
        if (natures.contains(Nature.ADMIN)) {
            // Add all admin groups, as they are not present on the permissionService.getVisibleMemberGroups()
            GroupQuery admins = new GroupQuery();
            admins.setNatures(Group.Nature.ADMIN);
            allowedGroups.addAll(groupService.search(admins));
        }
        if (natures.contains(Nature.OPERATOR)) {
            // Add all operator groups, as they are not present on the permissionService.getVisibleMemberGroups()
            GroupQuery operators = new GroupQuery();
            operators.setIgnoreManagedBy(true);
            operators.setNatures(Group.Nature.OPERATOR);
            allowedGroups.addAll(groupService.search(operators));
        }
        query.setGroups(PermissionHelper.checkSelection(allowedGroups, query.getGroups()));
    } else {
        // Members can only view connected operators
        permissionService.permission(query.getMember()).member(MemberPermission.OPERATORS_MANAGE).check();
    }
    return accessService.searchSessions(query);
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:48,代码来源:AccessServiceSecurity.java

示例9: create

import nl.strohalm.cyclos.entities.groups.Group.Nature; //导入依赖的package包/类
public static GroupActionPolicy create(final Nature... nature) {
    return new GroupActionPolicy(nature);
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:4,代码来源:GroupActionPolicy.java

示例10: GroupActionPolicy

import nl.strohalm.cyclos.entities.groups.Group.Nature; //导入依赖的package包/类
private GroupActionPolicy(final Nature... natures) {
    this.natures = new HashSet<Nature>();
    CollectionUtils.addAll(this.natures, natures);
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:5,代码来源:GroupActionPolicy.java

示例11: search

import nl.strohalm.cyclos.entities.groups.Group.Nature; //导入依赖的package包/类
@Override
public List<Session> search(final SessionQuery query) {
    Map<String, Object> params = new HashMap<String, Object>();
    StringBuilder hql = new StringBuilder();
    hql.append(" select s ");
    hql.append(" from Session s left join fetch s.user u left join fetch u.element e left join fetch e.group g ");
    hql.append(" where s.expirationDate > now() ");

    // Filter by nature - use the discriminator directly
    Collection<Nature> natures = query.getNatures();
    if (CollectionUtils.isNotEmpty(natures)) {
        Collection<String> values = new ArrayList<String>(natures.size());
        for (Nature nature : natures) {
            values.add(nature.getDiscriminator());
        }
        HibernateHelper.addInParameterToQuery(hql, params, "s.user.element.group.class", values);
    }

    // Apply the filter by group, which has a distinct semantic on operators
    boolean hasOperator = CollectionUtils.isEmpty(natures) || natures.contains(Group.Nature.OPERATOR);
    if (hasOperator) {
        // The groups may be for either the group or, if operators, the member group
        hql.append("and (s.user.element.group in (:groups) or exists (");
        hql.append("    select o.id");
        hql.append("    from Operator o");
        hql.append("    where o = s.user.element");
        hql.append("      and o.member.group in (:groups)");
        hql.append("))");
        params.put("groups", query.getGroups());
    } else {
        // Group filter will apply directly
        HibernateHelper.addInParameterToQuery(hql, params, "s.user.element.group", query.getGroups());
    }

    // Filter by operator member
    if (query.getMember() != null) {
        hql.append("and exists (");
        hql.append("    select o.id");
        hql.append("    from Operator o");
        hql.append("    where o = s.user.element");
        hql.append("      and o.member = :member");
        hql.append(")");
        params.put("member", query.getMember());
    }
    HibernateHelper.appendOrder(hql, "s.user.element.name");
    return list(query, hql.toString(), params);
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:48,代码来源:SessionDAOImpl.java


注:本文中的nl.strohalm.cyclos.entities.groups.Group.Nature类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。