Package com.adito.properties

Examples of com.adito.properties.PropertyProfile


        int baseOn = ((Integer) seq.getAttribute(ProfileDetailsForm.ATTR_BASE_ON, null)).intValue();
        String username = Constants.SCOPE_GLOBAL.equals(scope) ? null : user.getPrincipalName();
        int realmId = user.getRealm().getRealmID();
        String shortName = (String) seq.getAttribute(ProfileDetailsForm.ATTR_RESOURCE_NAME, null);
        String description = (String) seq.getAttribute(ProfileDetailsForm.ATTR_RESOURCE_DESCRIPTION, null);
        PropertyProfile newProfile = null;
        try {
            try {
                // TODO get the creating resource permission
                newProfile = ProfilesFactory.getInstance().createPropertyProfile(username, shortName, description, baseOn, realmId);
                CoreServlet.getServlet().fireCoreEvent(
View Full Code Here


        super(Arrays.asList(new PropertyClass[] { PropertyClassManager.getInstance().getPropertyClass(ProfileProperties.NAME) } ), true);
    }

    public boolean getEnabled() {
        try {
            PropertyProfile profile = ProfilesFactory.getInstance()
                            .getPropertyProfile(getSelectedPropertyProfile());
            boolean global = profile.getOwnerUsername() == null || profile.getOwnerUsername().equals("");
            return (Constants.SCOPE_PERSONAL.equals(getProfileScope()) && !global) || (Constants.SCOPE_GLOBAL.equals(getProfileScope()) && global);
        } catch (Exception e) {
            log.error("Failed to get property profile details. Disabling form.", e);
            return false;
        }
View Full Code Here

   
    public void initialize(List globalResources, List personalResources, HttpSession session, int selectedProfile) {
        super.initialize(globalResources, PropertyProfile.class, PropertyProfileItem.class, session, "name");
        if(personalResources != null) {
            for(Iterator i = personalResources.iterator(); i.hasNext(); ) {
                PropertyProfile p = (PropertyProfile)i.next();
                if(p.getOwnerUsername() != null){
                    getModel().addItem(new PropertyProfileItem(p, new ArrayList()));
                }
            }
        }
        this.selectedProfile = String.valueOf(selectedProfile);
View Full Code Here

    public ActionForward commit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        ActionMessages messages = new ActionMessages();
        User user = LogonControllerFactory.getInstance().getUser(request);
        PropertyProfileForm profileForm = (PropertyProfileForm) form;
        PropertyProfile profile = (PropertyProfile) profileForm.getResource();
        if (profileForm.getPropertyScope().equals(Constants.SCOPE_GLOBAL)) {
            PolicyUtil.checkPermissions(PolicyConstants.PROFILE_RESOURCE_TYPE, new Permission[] {
                            PolicyConstants.PERM_CREATE_EDIT_AND_ASSIGN, PolicyConstants.PERM_EDIT_AND_ASSIGN,
                            PolicyConstants.PERM_ASSIGN }, request);
        } else {
            PolicyUtil.checkPermission(PolicyConstants.PERSONAL_PROFILE_RESOURCE_TYPE, PolicyConstants.PERM_MAINTAIN, request);
        }
        profileForm.apply();
        if (profileForm.getEditing()) {
            PolicyDatabaseFactory.getInstance().attachResourceToPolicyList(profile, profileForm.getSelectedPoliciesList(),
                getSessionInfo(request));
            profile.getResourceType().updateResource(profile, getSessionInfo(request));
        } else {
            int baseOn = profileForm.getSelectedPropertyProfile();
            User owner = profileForm.getOwner();
            int realmId = user.getRealm().getRealmID();

            try {
                PropertyProfile newProfile = ProfilesFactory.getInstance().createPropertyProfile(
                    owner == null ? null : owner.getPrincipalName(), profile.getResourceName(), profile.getResourceDescription(),
                    baseOn, realmId);

                PolicyDatabaseFactory.getInstance().attachResourceToPolicyList(newProfile, profileForm.getSelectedPoliciesList(),
                    getSessionInfo(request));
View Full Code Here

            globalProfiles = ResourceUtil.filterOwned(ResourceUtil.getGrantedResource(
                            getSessionInfo(request), getResourceType()));           
            personalProfiles = ResourceUtil.filterResources(session.getUser(), ProfilesFactory.getInstance().getPropertyProfiles(
                session.getUser().getPrincipalName(), true, session.getUser().getRealm().getResourceId()), false);
        }
        PropertyProfile profile = (PropertyProfile) request.getSession().getAttribute(Constants.SELECTED_PROFILE);
        if (profile != null) {
            profilesForm.initialize(globalProfiles, personalProfiles, request.getSession(), profile.getResourceId());
        } else {
            profilesForm.initialize(globalProfiles, personalProfiles, request.getSession(), -1);
        }
        profilesForm.checkSelectedView(request, response);
        return fwd;
View Full Code Here

     * @throws Exception
     */
    public ActionForward confirmRemove(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                    HttpServletResponse response) throws Exception {
        ProfilesForm f = (ProfilesForm) form;
        PropertyProfile profile = (PropertyProfile) getResourceById(f.getSelectedResource());
        if (profile == null) {
            throw new Exception("Selected profile '" + f.getSelectedResource() + "' doesn't exist.");
        }
        if(profile.getOwnerUsername() != null) {
            SessionInfo session = getSessionInfo(request);
            if(!session.getUser().getPrincipalName().equals(profile.getOwnerUsername())) {
                throw new Exception("Cannot delete profiles owned by others.");
            }
            return mapping.findForward("confirmRemove");
        }
        else {
View Full Code Here

     */
    public ActionForward remove(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        ProfilesForm f = (ProfilesForm) form;
        ActionMessages errors = new ActionMessages();
        PropertyProfile profile = (PropertyProfile) getResourceById(f.getSelectedResource());
        if (profile == null) {
            throw new Exception("Selected profile '" + f.getSelectedResource() + "' doesn't exist.");
        }
        if (profile.getOwnerUsername() == null && Constants.SCOPE_PERSONAL.equals(f.getProfileScope())) {
            errors.add(Globals.ERROR_KEY, new ActionMessage("error.deleteProfile.cantDeleteGlobalProfile"));
        }
        if (profile.getResourceName().equalsIgnoreCase("Default")
                        && (profile.getOwnerUsername() == null || profile.getOwnerUsername().equals(""))) {
            errors.add(Globals.ERROR_KEY, new ActionMessage("error.deleteProfile.cantDeleteDefaultProfile"));
        }
        saveErrors(request, errors);
        CoreUtil.resetMainNavigation(request.getSession());
        if (errors.size() > 0) {
View Full Code Here

     * @throws Exception on any error
     */
    public ActionForward select(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        ProfilesForm f = (ProfilesForm) form;
        PropertyProfile profile = ProfilesFactory.getInstance().getPropertyProfile(f.getSelectedResource());
        SessionInfo session = getSessionInfo(request);
        ResourceUtil.checkResourceAccessRights(profile, session);
        request.getSession().setAttribute(Constants.SELECTED_PROFILE, profile);
        ActionMessages messages = new ActionMessages();
        messages.add(Globals.MESSAGES_KEY, new ActionMessage("message.profileSelected", profile.getResourceName()));
        saveMessages(request, messages);
        return mapping.findForward("refresh");
    }
View Full Code Here

   

    @Override
    public ActionForward commit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        ProfilePropertiesForm f = (ProfilePropertiesForm) form;    
        PropertyProfile profile = ProfilesFactory.getInstance().getPropertyProfile(f.getSelectedPropertyProfile());
        ResourceUtil.checkResourceManagementRights(profile, getSessionInfo(request), new Permission[] {PolicyConstants.PERM_CHANGE});
        return super.commit(mapping, form, request, response);
    }
View Full Code Here

                pf.setSelectedPropertyProfile(((PropertyProfile) request.getSession().getAttribute(Constants.SELECTED_PROFILE)).getResourceId());
            } else {
                pf.setSelectedPropertyProfile(0);
            }
        }
        PropertyProfile selectedPropertyProfile = ProfilesFactory.getInstance().getPropertyProfile(pf.getSelectedPropertyProfile());
        if (selectedPropertyProfile == null) {
            selectedPropertyProfile = ProfilesFactory.getInstance().getPropertyProfile(getSessionInfo(request).getUser().getPrincipalName(),
                "Default", getSessionInfo(request).getUser().getRealm().getResourceId());
            if (selectedPropertyProfile == null) {
                selectedPropertyProfile = ProfilesFactory.getInstance().getPropertyProfile(null, "Default",
                                UserDatabaseManager.getInstance().getDefaultUserDatabase().getRealm().getResourceId());
            }
        }
        ResourceStack.pushToEditingStack(request.getSession(), selectedPropertyProfile);
       
        // Get the property profiles
        List propertyProfiles = (List)request.getSession().getAttribute(Constants.PROFILES);
        if (selectedPropertyProfile == null) {
            for (Iterator i = propertyProfiles.iterator(); i.hasNext();) {
                selectedPropertyProfile = (PropertyProfile) i.next();
                if (selectedPropertyProfile.getResourceName().equals("Default")) {
                    break;
                }
            }
        }
        pf.setPropertyProfiles(propertyProfiles);
        pf.setSelectedPropertyProfile(selectedPropertyProfile.getResourceId());
       
        // Build an display
        return rebuildItems(mapping, pf.getParentCategory(), pf, request, getSessionInfo(request).getUser());
    }
View Full Code Here

TOP

Related Classes of com.adito.properties.PropertyProfile

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.