protected String getProfilingRuleForUser(User user) { Collection<PrincipalRule> userRules = profiler.getRulesForPrincipal(user); for (PrincipalRule userRule : userRules) { if (userRule.getLocatorName().equals(ProfileLocator.PAGE_LOCATOR)) { return userRule.getProfilingRule().getId(); } } return ""; }
public String getLocatorPath(ProfileLocatorProperty [] properties) { StringBuffer key = new StringBuffer(); if (properties != null) for (int i = 0; (i < properties.length); i++) { if (i > 0) key.append(ProfileLocator.PATH_SEPARATOR); key.append(properties[i].getName()); key.append(ProfileLocator.PATH_SEPARATOR); key.append(properties[i].getValue()); } return key.toString(); }
/** * locatorRequestPath - extract request specific path from profile locator * using request path from locator * * @param locator request profile locator * @return request path */ private static String locatorRequestPath(ProfileLocator locator) { // use request path in locator as default return locatorRequestPath(locator, locator.getRequestPath()); }
Iterator<RuleCriterion> criteria = this.getRuleCriteria().iterator(); while (criteria.hasNext()) if (criterion.getType() == null) RuleCriterionResolver resolver = getResolver(criterion.getType()); if (resolver == null) resolver = getDefaultResolver(); String value = resolver.resolve(context, criterion); key.append(criterion.getName()); key.append(ProfileLocator.PATH_SEPARATOR); key.append(value); ProfileLocator locator = getLocatorFromCache(locatorKey); if (locator != null) locator = service.createLocator(context); criteria = this.getRuleCriteria().iterator(); while (criteria.hasNext()) if (criterion.getType() == null) RuleCriterionResolver resolver = getResolver(criterion.getType()); if (resolver != null) String value = resolver.resolve(context, criterion); boolean isControl = resolver.isControl(criterion);
Iterator<RuleCriterion> criteria = this.getRuleCriteria().iterator(); while (criteria.hasNext()) if (criterion.getType() == null) RuleCriterionResolver resolver = getResolver(criterion.getType()); if (resolver == null) resolver = getDefaultResolver(); String value = resolver.resolve(context, criterion); if (value != null && (resolver instanceof FallbackCriterionResolver)) key.append(criterion.getName()); key.append(ProfileLocator.PATH_SEPARATOR); key.append(token); key.append(criterion.getName()); key.append(ProfileLocator.PATH_SEPARATOR); key.append(value); ProfileLocator locator = getLocatorFromCache(locatorKey); if (locator != null) locator = service.createLocator(context); criteria = this.getRuleCriteria().iterator(); while (criteria.hasNext()) if (criterion.getType() == null)
RuleCriterion c = profiler.createRuleCriterion(); if (c == null) throw new SerializerException(SerializerException.CREATE_OBJECT_FAILED.create( "org.apache.jetspeed.profiler.rules.RuleCriterion", "returned null")); c.setFallbackOrder(jsr.getFallBackOrder()); c.setFallbackType(jsr.getFallBackType()); c.setName(jsr.getName()); c.setType(jsr.getType()); c.setValue(jsr.getValue()); c.setRuleId(rule.getId()); return c;
ProfileLocatorProperty [] properties0 = locator0.iterator().next(); ProfileLocatorProperty [] properties1 = locator1.iterator().next(); if ((properties0 != null) || (properties1 != null)) if (!properties0[i].getName().equals(properties1[i].getName()) || (properties0[i].isControl() && !properties1[i].isControl()) || (properties0[i].isNavigation() && !properties1[i].isNavigation()) || ((properties0[i].isControl() || properties0[i].isNavigation()) && (((properties0[i].getValue() == null) && (properties1[i].getValue() != null)) || ((properties0[i].getValue() != null) && !properties0[i].getValue().equals(properties1[i].getValue())))))
private void recreatePrincipalRules(JSPrincipalRules rules, String principalName) { for (JSPrincipalRule pr : rules) { ProfilingRule pRule = pm.getRule(pr.getRule()); try { PrincipalRule p1 = pm.createPrincipalRule(); p1.setLocatorName(pr.getLocator()); p1.setProfilingRule(pRule); p1.setPrincipalName(principalName); pm.storePrincipalRule(p1); } catch (Exception eRole) { eRole.printStackTrace(); } } }
protected void deleteData(Map<String,Object> settings, Logger log) throws SerializerException { if (isSettingSet(settings, JetspeedSerializer.KEY_PROCESS_PROFILER)) { log.info("deleting profiling rules and user profiling rules"); try { String anonymousUser = userManager.getAnonymousUser(); for (User _user : userManager.getUsers("")) { for (PrincipalRule rule : pm.getRulesForPrincipal(_user)) { pm.deletePrincipalRule(rule); } } Iterator<ProfilingRule> _itRules = pm.getRules().iterator(); while ( _itRules.hasNext() ) { pm.deleteProfilingRule(_itRules.next()); } } catch (Exception e) { throw new SerializerException(e); } } }
public ProfileLocator getDefaultProfile(RequestContext context, String locatorName) throws ProfilerException { // find a profiling rule for the default principal ProfilingRule rule = getRuleForPrincipal(DEFAULT_RULE_PRINCIPAL, locatorName); if (null == rule) { log.warn("Could not find profiling rule for principal: " + DEFAULT_RULE_PRINCIPAL); rule = this.getDefaultRule(); } if (null == rule) { String msg = "Couldn't find any profiling rules including default rule for principal " + DEFAULT_RULE_PRINCIPAL; log.error(msg); throw new ProfilerException(msg); } // create a profile locator for given rule return rule.apply(context, this); }
/** * Setup and maintain profiler context to be used to reap rule caches * for principals on session end. * * @param context request context * @throws ProfilerException when subject or principal not available */ private void setupProfilerContext(RequestContext context) throws ProfilerException { // validate profiler context ProfilerContext profilerContext = (ProfilerContext) context.getSessionAttribute(PROFILER_CONTEXT_ATTRIBUTE_NAME); try { // access session principal and test for change Principal principal = SubjectHelper.getBestPrincipal(context.getSubject(), UserSubjectPrincipal.class); if (principal == null) { throw new NullPointerException("Principal not found"); } if ((profilerContext == null) || (profilerContext.getPrincipal() != principal)) { // setup/reset profiler context context.setSessionAttribute(PROFILER_CONTEXT_ATTRIBUTE_NAME, new ProfilerContext(this, principal)); } } catch (Exception e) { String message = "Unable to access principal in pipeline: " + e; log.error(message, e); throw new ProfilerException(message, e); } }
public ProfileLocatorProperty [] next() { ProfileLocatorProperty [] properties = null; if (last >= 0) { // generate properties list to return List elements = locator.getElements(); properties = new ProfileLocatorProperty[last+1]; ProfileLocatorProperty lastElement = null; Iterator it = elements.listIterator(); for (int count = 0; (count <= last) && it.hasNext(); count++) { lastElement = (ProfileLocatorProperty)it.next(); properties[count] = lastElement; } // modify iterator state based on fallback type; // performed here to prevent multiple calls to // hasNext() from changing iterator state state = lastElement.getFallbackType(); last--; } return properties; } }
/** * Find users according to query parameters. * * @param servletRequest * @param uriInfo * @return */ @GET @Path("/list") public ProfileDataTableBean listProfiles(@Context HttpServletRequest servletRequest, @Context UriInfo uriInfo) { checkPrivilege(servletRequest, JetspeedActions.VIEW); Collection<ProfilingRule> rules = profiler.getRules(); return new ProfileDataTableBean(rules); }
public ProfileLocator createLocator(RequestContext context) { try { ProfileLocator locator = (ProfileLocator) beanFactory.getBean( this.locatorBean, ProfileLocator.class); locator.init(this, context.getPath(), ((context.getRequest() != null) ? context.getRequest().getServerName() : null)); return locator; } catch (Exception e) { log.error("Failed to create locator for " + this.locatorBean + " error : " + e.getLocalizedMessage()); } return null; }
ProfileLocatorProperty [] properties = locator.iterator().next(); for (int i = 0, limit = properties.length; (i < limit); i++) if (!properties[i].isControl() && !properties[i].isNavigation() && (properties[i].getValue() != null)) String locatorPath = properties[i].getValue();
private void exportUserPrincipalRules(JSSnapshot snapshot, Map<String,Object> settings, Logger log) throws SerializerException { // get Rules for each user for (JSPrincipal _user : snapshot.getPrincipals()) { if (JetspeedPrincipalType.USER.equals(_user.getType())) { Principal principal = _user.getPrincipal(); if (principal != null) { for (PrincipalRule p1 : pm.getRulesForPrincipal(principal)) { JSPrincipalRule pr = new JSPrincipalRule(p1.getLocatorName(), p1.getProfilingRule().getId()); _user.getRules().add(pr); } } } } }
String msg = "Invalid (null) Subject in request pipeline"; log.error(msg); throw new ProfilerException(msg); String msg = "Could not find a principle for subject in request pipeline"; log.error(msg); throw new ProfilerException(msg); setupProfilerContext(context); ProfilingRule rule = getRuleForPrincipal(principal, locatorName); if (null == rule) { log.warn("Could not find profiling rule for principal: " + principal); rule = this.getDefaultRule(); + principal; log.error(msg); throw new ProfilerException(msg); return rule.apply(context, this);
String requestPath = locator.getRequestPath(); Iterator<ProfileLocatorProperty []> locatorIter = locator.iterator(); if (locatorIter.hasNext()) for (int i = 0; (i < properties.length); i++) if (!properties[i].isControl() && !properties[i].isNavigation()) String path = properties[i].getValue(); if (path != null)
Iterator<ProfileLocatorProperty []> locatorIter = locator.iterator(); while (locatorIter.hasNext()) for (int i = 0; (i < properties.length); i++) if (properties[i].isNavigation()) if (properties[i].getValue() != null) pathRoot = properties[i].getValue(); int pathRootDepth = 0; if (!pathRoot.startsWith(Folder.PATH_SEPARATOR)) else if (properties[i].isControl()) if (properties[i].getValue() != null) String propertyName = properties[i].getName().toLowerCase(); String propertyValue = properties[i].getValue();