public String getCustomMapping() { if ("XWiki.XWikiPreferences".equals(getName())) { return "internal"; } if (this.customMapping == null) { return ""; } return this.customMapping; }
@Override public String getClassName() { BaseClass bclass = getxWikiClass(); return (bclass == null) ? "" : bclass.getName(); }
public List getMembers(XWikiContext context) throws XWikiException { List objs = doc.getObjects(Group.getXWikiGroupsClass(context).getName()); Iterator it = objs.iterator(); List members = new ArrayList(); while (it.hasNext()) { members.add(((Object) it.next()).get("member")); } return members; }
public List getUsersPageName(XWikiContext context) throws XWikiException { List usersPageName = new ArrayList(); List objs = doc.getObjects(getXWikiGroupsClass(context).getName()); Iterator it = objs.iterator(); while (it.hasNext()) { usersPageName.add(((Object) it.next()).get("member")); } return usersPageName; }
/** * @param userDocument the user profile page. * @return the dn store in the user profile. Null if it can't find any or if it's empty. */ public String getDn(XWikiDocument userDocument) { BaseObject ldapObject = userDocument.getObject(this.ldapClass.getName()); return ldapObject == null ? null : getDn(ldapObject); }
/** * @param userDocument the user profile page. * @return the uid store in the user profile. Null if it can't find any or if it's empty. */ public String getUid(XWikiDocument userDocument) { BaseObject ldapObject = userDocument.getObject(this.ldapClass.getName()); return ldapObject == null ? null : getUid(ldapObject); }
public String makeQuery(XWikiCriteria query) { List<String> criteriaList = new ArrayList<String>(); for (PropertyClass property : (Collection<PropertyClass>) getFieldList()) { String name = property.getName(); Map<String, Object> map = query.getParameters(getName() + "_" + name); if (map.size() > 0) { property.makeQuery(map, "", query, criteriaList); } } return StringUtils.join(criteriaList.toArray(), " and "); }
private void removeParent(String name, XWikiContext context) throws XWikiException { String className = getXWikiGroupRelationClass(context).getName(); Vector objs = doc.getObjects(className); Iterator it = objs.iterator(); while (it.hasNext()) { Object obj = (Object) it.next(); if (obj.get("parentpage").equals(name)) { doc.removeObject(obj); return; } } }
/** * @param context * @return the list of parent group's page * @throws XWikiException */ public List getParentPages(XWikiContext context) throws XWikiException { ArrayList parents = new ArrayList(); Vector objs = doc.getObjects(getXWikiGroupRelationClass(context).getName()); if (objs == null) return parents; Iterator it = objs.iterator(); while (it.hasNext()) { Object obj = (Object) it.next(); String parentsPage = (String) obj.get("parentpage"); if (parentsPage != null && parentsPage.length() > 0) parents.add(parentsPage); } return parents; }
/** * Configure BaseClass. * * @param baseClass the baseClass to configure. * @return true if <code>baseClass</code> modified. */ protected boolean updateBaseClass(BaseClass baseClass) { boolean needUpdate = false; if (!baseClass.getName().equals(getClassFullName())) { baseClass.setName(getClassFullName()); needUpdate = true; } return needUpdate; }
public boolean removeUser(String docName, XWikiContext context) throws XWikiException { if (!isMember(docName, context)) return false; String className = getXWikiGroupsClass(context).getName(); Vector objs = doc.getObjects(className); Object obj; Iterator it = objs.iterator(); while (it.hasNext()) { obj = (Object) it.next(); if (obj.get("member").equals(docName)) { doc.removeObject(obj); return true; } } return false; }
public void reload(Document doc, XWikiContext context) throws XWikiException { if (doc == null) doc = context.getWiki().getDocument(this.doc.getFullName(), context).newDocument(context); this.doc = doc; BaseClass dirGrpClass = getXWikiDirectoryGroupClass(context); Object obj; if ((obj = doc.getObject(dirGrpClass.getName())) == null) { doc.createNewObject(dirGrpClass.getName()); obj = doc.getObject(dirGrpClass.getName()); this.isNew = true; } this.objDirectoryGroup = obj; }
public List getCustomMappingPropertyList(BaseClass bclass) { List list = new ArrayList(); Configuration hibconfig; if (bclass.hasExternalCustomMapping()) { hibconfig = makeMapping(bclass.getName(), bclass.getCustomMapping()); } else { hibconfig = getConfiguration(); } PersistentClass mapping = hibconfig.getClassMapping(bclass.getName()); if (mapping == null) { return null; } Iterator it = mapping.getPropertyIterator(); while (it.hasNext()) { Property hibprop = (Property) it.next(); String propname = hibprop.getName(); list.add(propname); } return list; }
public static List getAllGroupsPageName(XWikiContext context) throws XWikiException { String className = getXWikiDirectoryGroupClass(context).getName(); String hql = ", BaseObject as obj where obj.name=doc.fullName" + " and obj.className='" + className + "'"; return context.getWiki().getStore().searchDocumentsNames(hql, context); }
public static List getAllGroupsPageName(String orderBy, XWikiContext context) throws XWikiException { String className = getXWikiDirectoryGroupClass(context).getName(); String hql = ", BaseObject as obj, StringProperty as prop where obj.name=doc.fullName" + " and obj.className='" + className + "' and obj.id=prop.id.id and prop.name='" + orderBy + "' order by prop.value"; return context.getWiki().getStore().searchDocumentsNames(hql, context); } }
private boolean executeValidationScript(BaseObject obj, String validationScript, XWikiContext context) throws XWikiException { try { XWikiValidationInterface validObject = (XWikiValidationInterface) context.getWiki().parseGroovyFromPage(validationScript, context); return validObject.validateObject(obj, context); } catch (Throwable e) { XWikiValidationStatus.addExceptionToContext(getName(), "", e, context); return false; } }
private void addParentName(String name, XWikiContext context) throws XWikiException { String className = getXWikiGroupRelationClass(context).getName(); int nb = doc.createNewObject(className); Object obj = doc.getObject(className, nb); obj.set("parentpage", name); }
public static boolean isValidGroup(String grpName, XWikiContext context) throws XWikiException { Document doc = context.getWiki().getDocument(grpName, context).newDocument(context); if (doc.isNew()) return false; return (doc.getObjects(getXWikiDirectoryGroupClass(context).getName()).size() > 0); }
/** * @param name * @param context * @return * @throws XWikiException */ public boolean addUser(String name, XWikiContext context) throws XWikiException { if (isMember(name, context)) return false; String className = getXWikiGroupsClass(context).getName(); int nb = doc.createNewObject(className); Object obj = doc.getObject(className, nb); obj.set("member", name); return true; }