Examples of BundleGroup


Examples of org.rhq.core.domain.bundle.BundleGroup

    @Override
    @RequiredPermission(Permission.MANAGE_BUNDLE_GROUPS)
    public void deleteBundleGroups(Subject subject, int[] bundleGroupIds) throws Exception {

        for (int bundleGroupId : bundleGroupIds) {
            BundleGroup bundleGroup = this.entityManager.find(BundleGroup.class, bundleGroupId);
            if (null == bundleGroup) {
                return;
            }

            // unassign any bundles assigned to the bundle group
            // wrap in new HashSet to avoid ConcurrentModificationExceptions.
            Set<Bundle> bundlesToRemove = new HashSet<Bundle>(bundleGroup.getBundles());
            for (Bundle b : bundlesToRemove) {
                bundleGroup.removeBundle(b);
            }

            // remove from any roles
            for (Role r : bundleGroup.getRoles()) {
                r.removeBundleGroup(bundleGroup);
            }

            bundleGroup = entityManager.merge(bundleGroup);
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleGroup

        if (null == bundleGroupIds || null == bundleIds) {
            return;
        }

        for (int bundleGroupId : bundleGroupIds) {
            BundleGroup bundleGroup = entityManager.find(BundleGroup.class, bundleGroupId);
            if (null == bundleGroup) {
                throw new IllegalArgumentException("BundleGroup does not exist for bundleGroupId [" + bundleGroupId
                    + "]");
            }

            checkUnassignBundleGroupAuthz(subject, bundleGroupId, bundleIds);

            for (int bundleId : bundleIds) {
                Bundle bundle = entityManager.find(Bundle.class, bundleId);
                if (null == bundle) {
                    throw new IllegalArgumentException("Bundle does not exist for bundleId [" + bundleId + "]");
                }

                bundleGroup.removeBundle(bundle);
            }
        }
    }
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleGroup

        throw new PermissionException(msg);
    }

    @Override
    public BundleGroup updateBundleGroup(Subject subject, BundleGroup bundleGroup) throws Exception {
        BundleGroup attachedBundleGroup = entityManager.find(BundleGroup.class, bundleGroup.getId());
        if (attachedBundleGroup == null) {
            throw new IllegalArgumentException("Cannot update " + bundleGroup
                + ", because no bundle group exists with id [" + bundleGroup.getId() + "].");
        }

        // First update the simple fields and the permissions.
        attachedBundleGroup.setName(bundleGroup.getName());
        attachedBundleGroup.setDescription(bundleGroup.getDescription());

        Set<Bundle> newBundles = bundleGroup.getBundles();
        if (newBundles != null) {
            // wrap in new HashSet to avoid ConcurrentModificationExceptions.
            Set<Bundle> currentBundles = attachedBundleGroup.getBundles();
            Set<Bundle> BundlesToRemove = new HashSet<Bundle>(currentBundles);
            for (Bundle bg : newBundles) {
                BundlesToRemove.remove(bg);
            }
            for (Bundle bg : BundlesToRemove) {
                attachedBundleGroup.removeBundle(bg);
            }

            for (Bundle bg : newBundles) {
                Bundle attachedBundle = entityManager.find(Bundle.class, bg.getId());
                attachedBundleGroup.addBundle(attachedBundle);
            }
        }

        // Fetch the lazy Set for the return
        attachedBundleGroup.getBundles().size();

        return attachedBundleGroup;
    }
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleGroup

            for (BundleGroup bg : bundleGroupsToRemove) {
                attachedRole.removeBundleGroup(bg);
            }

            for (BundleGroup bg : newBundleGroups) {
                BundleGroup attachedBundleGroup = entityManager.find(BundleGroup.class, bg.getId());
                attachedRole.addBundleGroup(attachedBundleGroup);
            }
        }

        // Fetch the lazy Sets on the Role to be returned.
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleGroup

                throw new IllegalArgumentException("Could not find role[" + roleId + "] in order to add resourceGroups");
            }
            role.getBundleGroups().size(); // load them in

            for (Integer bundleGroupId : bundleGroupIds) {
                BundleGroup bundleGroup = entityManager.find(BundleGroup.class, bundleGroupId);
                if (bundleGroup == null) {
                    throw new IllegalArgumentException("Tried to add BundleGroup[" + bundleGroupId + "] to role["
                        + roleId + "], but bundleGroup was not found.");
                }
                role.addBundleGroup(bundleGroup);
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleGroup

                    + "] in order to remove BundleGroups");
            }
            role.getBundleGroups().size(); // load them in

            for (Integer bundleGroupId : bundleGroupIds) {
                BundleGroup bundleGroup = entityManager.find(BundleGroup.class, bundleGroupId);
                if (bundleGroup == null) {
                    throw new IllegalArgumentException("Tried to remove BundleGroup[" + bundleGroupId + "] from role["
                        + roleId + "], but BundleGroup was not found");
                }
                role.removeBundleGroup(bundleGroup);
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleGroup

    @Override
    @RequiredPermission(Permission.MANAGE_SECURITY)
    public void removeRolesFromBundleGroup(Subject subject, int bundleGroupId, int[] roleIds) {
        if ((roleIds != null) && (roleIds.length > 0)) {
            BundleGroup bundleGroup = entityManager.find(BundleGroup.class, bundleGroupId);
            if (bundleGroup == null) {
                throw new IllegalArgumentException("Could not find BundleGroup[" + bundleGroupId
                    + "] in order to remove roles");
            }
            bundleGroup.getRoles().size(); // load them in

            for (Integer roleId : roleIds) {
                Role doomedRole = entityManager.find(Role.class, roleId);
                if (doomedRole == null) {
                    throw new IllegalArgumentException("Tried to remove role[" + roleId + "] from BundleGroup["
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleGroup

    @Override
    @RequiredPermission(Permission.MANAGE_SECURITY)
    public void addRolesToBundleGroup(Subject subject, int bundleGroupId, int[] roleIds) {
        if ((roleIds != null) && (roleIds.length > 0)) {
            BundleGroup bundleGroup = entityManager.find(BundleGroup.class, bundleGroupId);
            if (bundleGroup == null) {
                throw new IllegalArgumentException("Could not find bundleGroup[" + bundleGroupId
                    + "] in order to add roles");
            }
            bundleGroup.getRoles().size(); // load them in

            for (Integer roleId : roleIds) {
                Role role = entityManager.find(Role.class, roleId);
                if (role == null) {
                    throw new IllegalArgumentException("Tried to add role[" + roleId + "] to bundleGroup["
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleGroup

        return criteria;
    }

    @Override
    protected void executeAdd(final Record recordToAdd, final DSRequest request, final DSResponse response) {
        final BundleGroup newBundleGroup = copyValues(recordToAdd);

        bundleService.createBundleGroup(newBundleGroup, new AsyncCallback<BundleGroup>() {
            public void onFailure(Throwable caught) {
                // TODO: Throw more specific SLSB exceptions so we can set the right validation errors.
                String message = caught.getMessage();
                if (message != null && message.contains("javax.persistence.EntityExistsException")) {
                    Map<String, String> errorMessages = new HashMap<String, String>();
                    errorMessages.put(Field.NAME, MSG.view_bundle_fail_existingName(newBundleGroup.getName()));
                    sendValidationErrorResponse(request, response, errorMessages);
                } else {
                    throw new RuntimeException(caught);
                }
            }
View Full Code Here

Examples of org.rhq.core.domain.bundle.BundleGroup

    }

    @Override
    protected void executeUpdate(final Record editedBundleGroupRecord, Record oldBundleGroupRecord,
        final DSRequest request, final DSResponse response) {
        final BundleGroup editedBundleGroup = copyValues(editedBundleGroupRecord);

        bundleService.updateBundleGroup(editedBundleGroup, new AsyncCallback<BundleGroup>() {
            public void onFailure(Throwable caught) {
                String message = "Failed to update bundle group [" + editedBundleGroup.getName() + "].";
                sendFailureResponse(request, response, message, caught);
            }

            public void onSuccess(final BundleGroup updatedBundleGroup) {
                sendSuccessResponse(request, response, editedBundleGroupRecord);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.