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); } } }
rule = pm.getRule(_c.getId()); if ((rule == null) || (isSettingSet(settings, JetspeedSerializer.KEY_OVERWRITE_EXISTING))) pm.storeProfilingRule(rule); if (defaultRuleID != null) ProfilingRule defaultRule = pm.getRule(defaultRuleID); if (defaultRule != null) pm.setDefaultRule(defaultRuleID);
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(); } } }
@DELETE @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public UpdateResultBean deleteProfiles(List<String> profileIds, @Context HttpServletRequest servletRequest) { if (log.isDebugEnabled()) { log.debug(String.format("processing DELETE on /profiler for %s", profileIds)); } checkPrivilege(servletRequest, JetspeedActions.VIEW); if (profileIds == null || profileIds.size() == 0) { throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( new UpdateResultBean(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), "Profile ids to delete not specified")).build()); } try { //profileIds = PathSegmentUtils.parseNames(profileIdsString); for (String id : profileIds) { ProfilingRule rule = profiler.getRule(id); if (rule != null) { profiler.deleteProfilingRule(rule); } } return new UpdateResultBean(Response.Status.OK.getStatusCode(), "OK"); } catch (Exception e) { String message = String.format("Error converting profiler ids [%s]", profileIds); log.debug(message); throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( new UpdateResultBean(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), message)).build()); } }
ProfilingRule rule = profiler.getRule(dtoProfile.getId()); if (rule == null) { rule = profiler.createProfilingRule(dtoProfile.getConcreteClass().indexOf("StandardProfilingRule") > -1); rule.setId(dtoProfile.getId()); isAdd = true; RuleCriterion rc = rulesMap.get(dto.getName()); if (rc == null) { rc = profiler.createRuleCriterion(); rc.setName(dto.getName()); rc.setValue(dto.getValue()); profiler.storeProfilingRule(rule); return new UpdateResultBean(Response.Status.OK.getStatusCode(), "OK");
Collection<PrincipalRule> userRules = profiler.getRulesForPrincipal(user); PrincipalRule deleteRule = null; for (PrincipalRule userRule : userRules) { profiler.deletePrincipalRule(deleteRule); ProfilingRule profilingRule = profiler.getRule(rule); if (profilingRule != null) { profiler.setRuleForPrincipal(user, profilingRule, ProfileLocator.PAGE_LOCATOR);
try ProfilingRule tempStandardRule = pm.createProfilingRule(true); standardRuleClass = tempStandardRule.getClass(); try list = pm.getRules().iterator(); ProfilingRule defaultRule = pm.getDefaultRule(); if (defaultRule != null) snapshot.setDefaultRule(defaultRule.getId());
rule = profiler.getRule(jsp.getId()); if (jsp.isStandardRule()) rule = profiler.createProfilingRule(true); else rule = profiler.createProfilingRule(false); rule.setId(jsp.getId());
ProfilingRule profilingRule = profiler.getRule(rule); if (profilingRule != null) profiler.setRuleForPrincipal(user, profilingRule, ProfileLocator.PAGE_LOCATOR);
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 ""; }
protected List<String> getProfilingRuleNames() { List<String> names = new ArrayList<>(); names.add(""); Collection<ProfilingRule> rules = profiler.getRules(); for (ProfilingRule rule : rules) { names.add(rule.getId()); } return names; }
@GET @Path("/edit/{id}/") public ProfileEditBean lookupProfile(@Context HttpServletRequest servletRequest, @Context UriInfo uriInfo, @PathParam("id") String profileId) { checkPrivilege(servletRequest, JetspeedActions.VIEW); if (StringUtils.isBlank(profileId)) { throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).entity( new UpdateResultBean(Response.Status.BAD_REQUEST.getStatusCode(), "Profile id not specified")).build()); } ProfilingRule rule = profiler.getRule(profileId); if (rule == null) { throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).entity( new UpdateResultBean(Response.Status.BAD_REQUEST.getStatusCode(), "Profile id not found with the specified id: " + profileId)).build()); } ProfileEditBean editBean = new ProfileEditBean(rule.getId(), rule.getTitle(), rule.getClassname()); for (RuleCriterion criterion : rule.getRuleCriteria()) { editBean.add(new ProfileCriterionBean(criterion.getName(), criterion.getValue(), criterion.getType(), criterion.getFallbackType(), criterion.getFallbackOrder())); } return editBean; }
RuleCriterion c = profiler.createRuleCriterion(); if (c == null) throw new SerializerException(SerializerException.CREATE_OBJECT_FAILED.create(
locator = service.createLocator(context); criteria = this.getRuleCriteria().iterator(); while (criteria.hasNext())
ProfilingRule rule = profiler.getRule(entry.getValue()); if (rule != null) { profiler.setRuleForPrincipal(user, rule, entry.getKey());
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); } } } } }
/** * 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); }
locator = service.createLocator(context); criteria = this.getRuleCriteria().iterator(); while (criteria.hasNext())