From: Dmitriy S. <sha...@gm...> - 2010-07-14 15:30:21
|
Hello, Can we move user/security related functions to separate module? -- Cheers, Dmitriy Shabanov On Wed, 2010-07-14 at 00:31 +0000, ix...@us... wrote: > Revision: 11959 > http://exist.svn.sourceforge.net/exist/?rev=11959&view=rev > Author: ixitar > Date: 2010-07-14 00:31:14 +0000 (Wed, 14 Jul 2010) > > Log Message: > ----------- > [feature] Adding the function xmldb:get-current-user-attribute-names() > > Modified Paths: > -------------- > trunk/eXist/src/org/exist/xquery/functions/xmldb/XMLDBGetCurrentUserAttribute.java > trunk/eXist/src/org/exist/xquery/functions/xmldb/XMLDBModule.java > > Added Paths: > ----------- > trunk/eXist/src/org/exist/xquery/functions/xmldb/XMLDBGetCurrentUserAttributeNames.java > > Modified: trunk/eXist/src/org/exist/xquery/functions/xmldb/XMLDBGetCurrentUserAttribute.java > =================================================================== > --- trunk/eXist/src/org/exist/xquery/functions/xmldb/XMLDBGetCurrentUserAttribute.java 2010-07-13 12:34:12 UTC (rev 11958) > +++ trunk/eXist/src/org/exist/xquery/functions/xmldb/XMLDBGetCurrentUserAttribute.java 2010-07-14 00:31:14 UTC (rev 11959) > @@ -63,7 +63,7 @@ > public Sequence eval(Sequence args[], Sequence contextSequence) throws XPathException > { > if( args[0].isEmpty() ) { > - return BooleanValue.FALSE; > + return Sequence.EMPTY_SEQUENCE; > } > > String attributeName = args[0].getStringValue(); > > Added: trunk/eXist/src/org/exist/xquery/functions/xmldb/XMLDBGetCurrentUserAttributeNames.java > =================================================================== > --- trunk/eXist/src/org/exist/xquery/functions/xmldb/XMLDBGetCurrentUserAttributeNames.java (rev 0) > +++ trunk/eXist/src/org/exist/xquery/functions/xmldb/XMLDBGetCurrentUserAttributeNames.java 2010-07-14 00:31:14 UTC (rev 11959) > @@ -0,0 +1,64 @@ > +/* > + * eXist Open Source Native XML Database > + * Copyright (C) 2010 The eXist Project > + * http://exist-db.org > + * > + * This program is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public License > + * as published by the Free Software Foundation; either version 2 > + * of the License, or (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public License > + * along with this program; if not, write to the Free Software Foundation > + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. > + * > + * $Id $ > + */ > +package org.exist.xquery.functions.xmldb; > + > +import org.apache.log4j.Logger; > +import org.exist.dom.QName; > +import org.exist.xquery.*; > +import org.exist.xquery.value.*; > + > +import java.util.Set; > + > +/** > + * Created by IntelliJ IDEA. > + * User: lcahlander > + * Date: Jul 13, 2010 > + * Time: 1:51:11 PM > + * To change this template use File | Settings | File Templates. > + */ > +public class XMLDBGetCurrentUserAttributeNames extends BasicFunction { > + protected static final Logger logger = Logger.getLogger(XMLDBGetCurrentUserAttribute.class); > + > + public final static FunctionSignature signature = > + new FunctionSignature( > + new QName("get-current-user-attribute-names", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), > + "Returns the names of the attributes of the current user from the xquery context.", > + null, > + new FunctionReturnSequenceType(Type.STRING, Cardinality.ZERO_OR_MORE, "the attribute names of the current user") > + ); > + > + public XMLDBGetCurrentUserAttributeNames(XQueryContext context, FunctionSignature signature) > + { > + super(context, signature); > + } > + > + public Sequence eval(Sequence args[], Sequence contextSequence) throws XPathException > + { > + Set<String> values = context.getUser().getAttributeNames(); > + Sequence retval = new ValueSequence(); > + for (String value : values) > + { > + retval.add(new StringValue(value)); > + } > + return retval; > + } > +} > > > Property changes on: trunk/eXist/src/org/exist/xquery/functions/xmldb/XMLDBGetCurrentUserAttributeNames.java > ___________________________________________________________________ > Added: svn:keywords > + Id > > Modified: trunk/eXist/src/org/exist/xquery/functions/xmldb/XMLDBModule.java > =================================================================== > --- trunk/eXist/src/org/exist/xquery/functions/xmldb/XMLDBModule.java 2010-07-13 12:34:12 UTC (rev 11958) > +++ trunk/eXist/src/org/exist/xquery/functions/xmldb/XMLDBModule.java 2010-07-14 00:31:14 UTC (rev 11959) > @@ -60,6 +60,7 @@ > new FunctionDef(XMLDBAuthenticate.loginSignatures[1], XMLDBAuthenticate.class), > new FunctionDef(XMLDBGetCurrentUser.signature, XMLDBGetCurrentUser.class), > new FunctionDef(XMLDBGetCurrentUserAttribute.signature, XMLDBGetCurrentUserAttribute.class), > + new FunctionDef(XMLDBGetCurrentUserAttributeNames.signature, XMLDBGetCurrentUserAttributeNames.class), > new FunctionDef(XMLDBXUpdate.signature, XMLDBXUpdate.class), > new FunctionDef(XMLDBCopy.signatures[0], XMLDBCopy.class), > new FunctionDef(XMLDBCopy.signatures[1], XMLDBCopy.class), |