Package org.rhq.core.domain.bundle.composite

Examples of org.rhq.core.domain.bundle.composite.BundleGroupAssignmentComposite


    @Override
    public BundleGroupAssignmentComposite getAssignableBundleGroups(int bundleId) throws RuntimeException {
        try {
            Subject subject = getSessionSubject();
            BundleGroupAssignmentComposite results = bundleManager
                .getAssignableBundleGroups(subject, subject, bundleId);
            return SerialUtility.prepare(results, "getAssignableBundleGroups");
        } catch (Throwable t) {
            throw getExceptionToThrowToClient(t);
        }
View Full Code Here


            if (null == bundle) {
                throw new BundleNotFoundException("Bundle ID [" + bundleId + "]");
            }
        }

        BundleGroupAssignmentComposite result = new BundleGroupAssignmentComposite(assigningSubject, bundle);
        Set<Permission> globalPermissions = authorizationManager.getExplicitGlobalPermissions(assigningSubject);
        boolean hasManageBundleGroups = globalPermissions.contains(Permission.MANAGE_BUNDLE_GROUPS);

        // can assign any bundle anywhere, or leave unassigned
        if (hasManageBundleGroups) {
            BundleGroupCriteria criteria = new BundleGroupCriteria();
            // just get all the bundle groups by using overlord and no filters
            List<BundleGroup> bundleGroups = findBundleGroupsByCriteria(subjectManager.getOverlord(), criteria);
            result.setCanBeUnassigned(true);
            result.setBundleGroupMap(populateBundleGroupMap(bundleGroups, bundle));
            return result;
        }

        boolean hasViewBundles = globalPermissions.contains(Permission.VIEW_BUNDLES);
        boolean hasCreateBundles = globalPermissions.contains(Permission.CREATE_BUNDLES);
        boolean isNewBundle = (null == bundle);
        ArrayList<Permission> permFilter = new ArrayList<Permission>(1);

        if (isNewBundle) {
            // set whether can leave unassigned
            result.setCanBeUnassigned(hasCreateBundles && hasViewBundles);
            // can assign to bundle groups for which he has create_bundles_in_group
            permFilter.add(Permission.CREATE_BUNDLES_IN_GROUP);

        } else {
            // if necessary, make sure the bundle is viewable
            if (!hasViewBundles && !authorizationManager.canViewBundle(assigningSubject, bundleId)) {
                throw new PermissionException("Bundle ID [" + bundleId + "] is not viewable by subject ["
                    + assigningSubject.getName() + "]");
            }

            // can assign to bundle groups for which he has create_bundles_in_group or assign_bundles_to_group
            permFilter.add(Permission.CREATE_BUNDLES_IN_GROUP);
            permFilter.add(Permission.ASSIGN_BUNDLES_TO_GROUP);
        }

        List<BundleGroup> bundleGroups;
        if (hasCreateBundles) {
            // can assign to any viewable bundle group
            // get all the viewable bundle groups for the subject, no filters
            BundleGroupCriteria criteria = new BundleGroupCriteria();
            bundleGroups = findBundleGroupsByCriteria(assigningSubject, criteria);

        } else {
            // can only assign to bundle groups for which he has the necessary permissions
            RoleCriteria criteria = new RoleCriteria();
            criteria.addFilterSubjectId(assigningSubject.getId());
            criteria.addFilterPermissions(permFilter);
            criteria.fetchBundleGroups(true);
            List<Role> roles = LookupUtil.getRoleManager().findRolesByCriteria(subjectManager.getOverlord(), criteria);
            bundleGroups = new ArrayList<BundleGroup>();
            for (Role role : roles) {
                for (BundleGroup bundleGroup : role.getBundleGroups()) {
                    if (!bundleGroups.contains(bundleGroup)) {
                        bundleGroups.add(bundleGroup);
                    }
                }
            }
        }

        result.setBundleGroupMap(populateBundleGroupMap(bundleGroups, bundle));
        return result;
    }
View Full Code Here

        return canvas;
    }

    private void prepareInitialVersionCanvas(final EnhancedVLayout canvas) {
        BundleGroupAssignmentComposite composite = wizard.getBundleGroupAssignmentComposite();
        final Map<BundleGroup, Boolean> map = composite.getBundleGroupMap();

        if (composite.isCanBeUnassigned()) {
            radioForm = new DynamicForm();
            radioForm.setNumCols(1);
            radioForm.setColWidths(350);

            final RadioGroupItem radioGroupItem = new RadioGroupItem("RadioOptions");
View Full Code Here

            CoreGUI.getErrorHandler().handleError(MSG.view_bundle_createWizard_groupsStep_noAssignable());
        }
    }

    private void prepareNonInitialVersionCanvas(EnhancedVLayout canvas) {
        BundleGroupAssignmentComposite composite = wizard.getBundleGroupAssignmentComposite();
        final Map<BundleGroup, Boolean> map = composite.getBundleGroupMap();
        selector = getSelector(map, true);

        if (!selector.hasInitialSelection()) {
            selector.destroy();
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.bundle.composite.BundleGroupAssignmentComposite

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.