Package org.apache.jetspeed.profiler

Examples of org.apache.jetspeed.profiler.Profiler


                        if(!StringUtils.isEmpty(requiredRole))
                        {
                            roleManager.addRoleToUser(getUserName(), requiredRole);
                        }
                       
                        Profiler profiler = getServiceLocator().getProfiler();
                       
                        if (!StringUtils.isEmpty(getProfilingRule()))
                        {
                            ProfilingRule profilingRule = profiler.getRule(getProfilingRule());
                           
                            if (profilingRule != null)
                            {
                                profiler.setRuleForPrincipal(principal, profilingRule, "default");
                            }
                            else
                            {
                                log.error("Failed to set profiling rule for principal. Invalid profiling rule: " + getProfilingRule());
                            }
                        }
                        else if (!StringUtils.isEmpty(defaultProfile))
                        {
                            ProfilingRule defaultProfilingRule = profiler.getRule(defaultProfile);
                           
                            if (defaultProfilingRule != null)
                            {
                                profiler.setRuleForPrincipal(principal, defaultProfilingRule, "default");
                            }
                            else
                            {
                                if (log.isDebugEnabled())
                                {
View Full Code Here


                    if (locatorName != null && locatorName.trim().length() > 0)
                    {
                        try
                        {
                            String ruleName = getRuleName();
                            Profiler profiler = getServiceLocator().getProfiler();
                            ProfilingRule profilingRule = profiler.getRule(ruleName);
                            if (profilingRule != null)
                            {
                                profiler.setRuleForPrincipal(getPrincipal(), profilingRule, locatorName);
                            }
                            else
                            {
                                log.error("Failed to set profiling rule for the principal. Invalid profiling rule: " + ruleName);
                            }
View Full Code Here

        // button the create a new rule
        Button newRuleButton = new Button("newRuleButton", new ResourceModel("profiler.rule.new")) {

            @Override
            public void onSubmit() {
                Profiler profiler = getServiceLocator().getProfiler();
                try
                {
                    Class defaultClass = profiler.getClass().getClassLoader().loadClass("org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule");
                    setProfilingRule((ProfilingRule)defaultClass.newInstance());
                    ruleEditPanel.setVisible(true);
                    ruleEditPanel.hideCriterionEditPanel();
                    ruleEditPanel.ruleIdFieldReadOnly(false);
                }
View Full Code Here

           
            Button ruleSaveButton = new Button("ruleSaveButton", new ResourceModel("profiler.rule.save")) {

                @Override
                public void onSubmit() {
                    Profiler profiler = getServiceLocator().getProfiler();
                    try {
                        profiler.storeProfilingRule(profilingRule);
                        if (!getRules().contains(profilingRule)) {
                            getRules().add(profilingRule);
                        }
                        ruleIdFieldReadOnly(true);
                    } catch (ProfilerException e) {
                        logger.error("Failed to update rule: " + profilingRule, e);
                    }
                }
               
            };

            Button ruleRemoveButton = new Button("ruleRemoveButton", new ResourceModel("profiler.rule.remove")) {

                @Override
                public void onSubmit() {
                    Profiler profiler = getServiceLocator().getProfiler();
                    try {
                        if (getRules().contains(profilingRule)) {
                            getRules().remove(profilingRule);
                        }
                        profiler.deleteProfilingRule(profilingRule);
                        profilingRule = null;
                        RuleEditPanel.this.setVisible(false);
                    } catch (ProfilerException e) {
                        logger.error("Failed to REMOVE: " + profilingRule, e);
                    }
                }
               
            };
           
            ruleEditForm.add(ruleIdField);
            ruleEditForm.add(ruleTitleField);
            ruleEditForm.add(ruleClassField);
            ruleEditForm.add(ruleSaveButton);
            ruleEditForm.add(ruleRemoveButton);

           
            // the list of criteria for the selected rule
           
            ruleEditForm.add(new Label("ruleCriteriaLabel",new ResourceModel("criteria.title")));
           
            SortableDataProvider dataProvider = new SortableDataProvider()
            {
                public int size()
                {
                    return profilingRule.getRuleCriteria().size();
                }

                public IModel model(Object object)
                {
                    RuleCriterion ruleCriterion = (RuleCriterion) object;
                    return new Model(ruleCriterion);
                }

                public Iterator iterator(int first, int count)
                {
                    return new ArrayList(profilingRule.getRuleCriteria()).subList(first, first + count).iterator();
                }
            };
            IColumn[] columns = { new AbstractColumn(new Model("Name")) {

                public void populateItem(Item cellItem, String componentId, IModel rowModel) {
                    //cellItem.add(new CriterionLink(componentId, rowModel));
                    cellItem.add(new ActionPanel(componentId, rowModel, new Link("link", rowModel) {
                        public void onClick()
                        {
                            setCriterion((RuleCriterion) getModelObject());
                            criterionEditPanel.setVisible(true);
                        }
                    }, "name"));
                }
               
            },
                    new PropertyColumn(new Model("Value"), "value"),
                    new PropertyColumn(new Model("Resolver Type"), "type"),
                    new PropertyColumn(new Model("Fallback Type"), "fallbackType"),
                    new PropertyColumn(new Model("Order"), "fallbackOrder") };
           
            DataTable ruleCriteriaTable = new DataTable("ruleCriteriaTable", columns, dataProvider, 10);

            ruleCriteriaTable.addTopToolbar(new HeadersToolbar(ruleCriteriaTable, dataProvider));
            ruleCriteriaTable.addBottomToolbar(new NavigationToolbar(ruleCriteriaTable));
            ruleEditForm.add(ruleCriteriaTable);

            Button newCriterionButton = new Button("newCriterionButton",new ResourceModel("criteria.new")) {

                @Override
                public void onSubmit() {
                   
                    if(StringUtils.isEmpty(getProfilingRule().getId()))
                    {
                        error(getLocalizer().getString("ruleIdField.Required",this));
                        return;
                    }
                   
                    Profiler profiler = getServiceLocator().getProfiler();
                    try {
                        criterion = profiler.createRuleCriterion();
                       
                        criterionEditPanel.setVisible(true);
                    } catch (ClassNotFoundException e) {
                        logger.error("Could not create new rule criterion.", e);
                    }
View Full Code Here

                        }
                        if (!profilingRule.getRuleCriteria().contains(criterion)) {
                            profilingRule.getRuleCriteria().add(criterion);
                        }
                        try {
                            Profiler profiler = getServiceLocator().getProfiler();
                            profiler.storeProfilingRule(profilingRule);
                        }
                        catch (ProfilerException e) {
                            logger.error("Could not save rule criterion {}: {}", criterion.getName(), e.getMessage());
                        }
                    }
                   
                };
               
                Button removeCriterionButton = new Button("removeCriterionButton",new ResourceModel("criteria.remove")) {

                    @Override
                    public void onSubmit() {
                        if (profilingRule.getRuleCriteria().contains(criterion)) {
                            profilingRule.getRuleCriteria().remove(criterion);
                        }
                        try {
                            Profiler profiler = getServiceLocator().getProfiler();
                            profiler.storeProfilingRule(profilingRule);
                        }
                        catch (ProfilerException e) {
                            logger.error("Could not save rule criterion {}: {}", criterion.getName(), e.getMessage());
                        }
                    }
View Full Code Here

{
   
    public Collection getExtent()
    {
        Map appMap = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
        Profiler profiler = (Profiler)appMap.get(CommonPortletServices.CPS_PROFILER_COMPONENT);
        return profiler.getRules(); // TODO: optimize with cache
    }
View Full Code Here

     */
    private void recreateUserPrincipalRules() throws SerializerException
    {
      logMe("recreateUserPrincipalRules - started");
     
        Profiler pm = (Profiler) getCM()
        .getComponent("org.apache.jetspeed.profiler.Profiler");
        if (pm == null)

          throw new SerializerException(
            SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                    .create("org.apache.jetspeed.profiler.Profiler"));
        UserManager userManager = (UserManager) getCM()
        .getComponent("org.apache.jetspeed.security.UserManager");
        if (userManager == null)
          throw new SerializerException(
            SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                    .create("org.apache.jetspeed.security.UserManager"));

        // get Rules for each user

        Iterator _itUsers = ((JSSeedData)getSnapshot()).getUsers().iterator();
        while (_itUsers.hasNext())
        {
            JSUser _user = (JSUser) _itUsers.next();
            JSPrincipalRules jsRules = _user.getRules();
            try
            {
              User user = userManager.getUser(_user.getName());
              Principal principal = getUserPrincipal(user);
              if (jsRules != null)
              {
                Iterator _itRoles = jsRules.iterator();
                  while (_itRoles.hasNext())
                  {
                    JSPrincipalRule pr = (JSPrincipalRule) _itRoles.next();
                    ProfilingRule pRule = pm.getRule(pr.getRule());
                   
                    try
                    {
                      PrincipalRule p1 = pm.createPrincipalRule();
                      p1.setLocatorName(pr.getLocator());
                      p1.setProfilingRule(pRule);
                      p1.setPrincipalName(principal.getName());
                      pm.storePrincipalRule(p1);
                    }
                    catch (Exception eRole)
                    {
                      eRole.printStackTrace();
                    }
View Full Code Here

     * @throws SerializerException
     */
    private void getProfilingRules() throws SerializerException
    {
        getPermissions();
        Profiler pm = (Profiler) getCM()
                .getComponent("org.apache.jetspeed.profiler.Profiler");
        if (pm == null)

            throw new SerializerException(
                    SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                            .create("org.apache.jetspeed.profiler.Profiler"));
        Class standardRuleClass = null;
        try
        {
          ProfilingRule tempStandardRule = pm.createProfilingRule(true);
          standardRuleClass = tempStandardRule.getClass();
        }
        catch (Exception e)
        {
          throw new SerializerException(
                SerializerException.CREATE_OBJECT_FAILED
                        .create(new String[]
                        { "Standard Rule", e.getMessage()}));
        }
       
        Iterator list = null;
        try
        {
            list = pm.getRules().iterator();
        } catch (Exception e)
        {
            throw new SerializerException(
                    SerializerException.GET_EXISTING_OBJECTS
                            .create(new String[]
                            { "ProfilingRules", e.getMessage()}));
        }
        while (list.hasNext())
        {
            try
            {
                ProfilingRule p = (ProfilingRule) list.next();
                if (!(this.rulesMap.containsKey(p.getId())))
                {
                    JSProfilingRule rule = createProfilingRule(p, (standardRuleClass == p.getClass()));
                    rulesMap.put(rule.getId(), rule);
                    ((JSSeedData)getSnapshot()).getRules().add(rule);

                }
            } catch (Exception e)
            {
                throw new SerializerException(
                        SerializerException.CREATE_SERIALIZED_OBJECT_FAILED
                                .create(new String[]
                                { "ProfilingRules", e.getMessage()}));
            }
        }

        // determine the defualt rule
        ProfilingRule defaultRule = pm.getDefaultRule();
        if (defaultRule != null)
          ((JSSeedData)getSnapshot()).setDefaultRule(defaultRule.getId());

        // get Rules for each user

        Iterator _itUsers = this.userMap.values().iterator();
        while (_itUsers.hasNext())
        {
            JSUser _user = (JSUser) _itUsers.next();
            Principal principal = _user.getPrincipal();
            if (principal != null)
            {
                Collection col = pm.getRulesForPrincipal(principal);
                Iterator _itCol = col.iterator();
                while (_itCol.hasNext())
                {
                    PrincipalRule p1 = (PrincipalRule) _itCol.next();
                    JSPrincipalRule pr = new JSPrincipalRule(p1
View Full Code Here

     
     
     private void recreateProfilingRules () throws SerializerException
      {
        logMe("recreateProfilingRules - processing");
          Profiler pm = (Profiler) getCM()
            .getComponent("org.apache.jetspeed.profiler.Profiler");
          if (pm == null)
            throw new SerializerException(
                SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                          .create("org.apache.jetspeed.profiler.Profiler"));
        JSProfilingRules rules = ((JSSeedData)getSnapshot()).getRules();
        if ((rules != null) && (rules.size() > 0))
        {
          Iterator _it = rules.iterator();
          while (_it.hasNext())
          {
            JSProfilingRule _c = (JSProfilingRule)_it.next();

            try
            {
              ProfilingRule rule = null;
                
                 rule = pm.getRule(_c.getId());
                 if ((rule == null) || (this.getSetting(JetspeedSerializer.KEY_OVERWRITE_EXISTING)))
                 {
                   rule = recreateRule(pm,rule, _c);
                   pm.storeProfilingRule(rule);
                 }
            }
            catch (Exception e)
            {
              throw new SerializerException(
                        SerializerException.CREATE_OBJECT_FAILED
                          .create("org.apache.jetspeed.capabilities.Capabilities",e.getLocalizedMessage()));
         }
          }
          /** reset the default profiling rule */
          String defaultRuleID = ((JSSeedData)getSnapshot()).getDefaultRule();
          if (defaultRuleID != null)
          {
            ProfilingRule defaultRule = pm.getRule(defaultRuleID);
            if (defaultRule != null)
              pm.setDefaultRule(defaultRuleID);
          }
        }
        else
          logMe("NO PROFILING RULES?????");
        logMe("recreateProfilingRules - done");
View Full Code Here

     */
    private void recreateUserPrincipalRules() throws SerializerException
    {
      logMe("recreateUserPrincipalRules - started");
     
        Profiler pm = (Profiler) getCM()
        .getComponent("org.apache.jetspeed.profiler.Profiler");
        if (pm == null)

          throw new SerializerException(
            SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                    .create("org.apache.jetspeed.profiler.Profiler"));
        UserManager userManager = (UserManager) getCM()
        .getComponent("org.apache.jetspeed.security.UserManager");
        if (userManager == null)
          throw new SerializerException(
            SerializerException.COMPONENTMANAGER_DOES_NOT_EXIST
                    .create("org.apache.jetspeed.security.UserManager"));

        // get Rules for each user

        Iterator _itUsers = ((JSSeedData)getSnapshot()).getUsers().iterator();
        while (_itUsers.hasNext())
        {
            JSUser _user = (JSUser) _itUsers.next();
            JSPrincipalRules jsRules = _user.getRules();
            try
            {
              User user = userManager.getUser(_user.getName());
              Principal principal = getUserPrincipal(user);
              if (jsRules != null)
              {
                Iterator _itRoles = jsRules.iterator();
                  while (_itRoles.hasNext())
                  {
                    JSPrincipalRule pr = (JSPrincipalRule) _itRoles.next();
                    ProfilingRule pRule = pm.getRule(pr.getRule());
                   
                    try
                    {
                      PrincipalRule p1 = pm.createPrincipalRule();
                      p1.setLocatorName(pr.getLocator());
                      p1.setProfilingRule(pRule);
                      p1.setPrincipalName(principal.getName());
                      pm.storePrincipalRule(p1);
                    }
                    catch (Exception eRole)
                    {
                      eRole.printStackTrace();
                    }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.profiler.Profiler

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.