From: <sha...@us...> - 2009-05-23 16:31:29
|
Revision: 9069 http://exist.svn.sourceforge.net/exist/?rev=9069&view=rev Author: shabanovd Date: 2009-05-23 16:31:25 +0000 (Sat, 23 May 2009) Log Message: ----------- [ignore] merge trunk Modified Paths: -------------- branches/shabanovd/xslt/.classpath branches/shabanovd/xslt/conf.xml.tmpl branches/shabanovd/xslt/mime-types.xml.tmpl branches/shabanovd/xslt/nbproject/build-impl.xml branches/shabanovd/xslt/nbproject/genfiles.properties branches/shabanovd/xslt/nbproject/project.properties branches/shabanovd/xslt/src/org/exist/collections/Collection.java branches/shabanovd/xslt/src/org/exist/collections/CollectionConfiguration.java branches/shabanovd/xslt/src/org/exist/util/Configuration.java branches/shabanovd/xslt/test/src/org/exist/performance/xquery/RandomText.java branches/shabanovd/xslt/tools/ircbot/src/org/exist/irc/XBot.java Added Paths: ----------- branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/ branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/Client.java branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/ClientsManager.java branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/DatabaseUnderLoadTest.java branches/shabanovd/xslt/webapp/xproc/ branches/shabanovd/xslt/webapp/xproc/examples.xml branches/shabanovd/xslt/webapp/xproc/hello.xproc branches/shabanovd/xslt/webapp/xproc/run.xql branches/shabanovd/xslt/webapp/xproc/sidebar.xml branches/shabanovd/xslt/webapp/xproc/twitter-view.xql branches/shabanovd/xslt/webapp/xproc/twitter.xproc branches/shabanovd/xslt/webapp/xproc/xslt-identity.xproc Removed Paths: ------------- branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/Client.java branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/ClientsManager.java branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/DatabaseUnderLoadTest.java branches/shabanovd/xslt/webapp/xproc/examples.xml branches/shabanovd/xslt/webapp/xproc/hello.xproc branches/shabanovd/xslt/webapp/xproc/run.xql branches/shabanovd/xslt/webapp/xproc/sidebar.xml branches/shabanovd/xslt/webapp/xproc/twitter-view.xql branches/shabanovd/xslt/webapp/xproc/twitter.xproc branches/shabanovd/xslt/webapp/xproc/xslt-identity.xproc Modified: branches/shabanovd/xslt/.classpath =================================================================== --- branches/shabanovd/xslt/.classpath 2009-05-23 16:28:37 UTC (rev 9068) +++ branches/shabanovd/xslt/.classpath 2009-05-23 16:31:25 UTC (rev 9069) @@ -110,7 +110,5 @@ <classpathentry kind="lib" path="lib/user/svnkit.jar"/> <classpathentry kind="lib" path="lib/user/jfreechart-1.0.12.jar"/> <classpathentry kind="lib" path="lib/user/jcommon-1.0.15.jar"/> - <classpathentry kind="lib" path="lib/user/mina-core-2.0.0-M5.jar"/> - <classpathentry kind="lib" path="lib/user/slf4j-api-1.5.2.jar"/> <classpathentry kind="output" path="test/classes"/> </classpath> Modified: branches/shabanovd/xslt/conf.xml.tmpl =================================================================== --- branches/shabanovd/xslt/conf.xml.tmpl 2009-05-23 16:28:37 UTC (rev 9068) +++ branches/shabanovd/xslt/conf.xml.tmpl 2009-05-23 16:31:25 UTC (rev 9069) @@ -713,9 +713,32 @@ --> <!-- Versioning --> - <!--module src="resource:org/exist/versioning/xquery/versioning.xqm" - uri="http://exist-db.org/versioning"/--> + <module src="resource:org/exist/versioning/xquery/versioning.xqm" + uri="http://exist-db.org/versioning"/> + <!-- expath module imports (for p:http-request)//--> + <module class="org.exist.xquery.modules.httpclient.HTTPClientModule" + uri="http://exist-db.org/xquery/httpclient" /> + <module src="resource:org/expath/www/mod/http-client/http-client.xqm" + uri="http://www.expath.org/mod/http-client"/> + <!-- xprocxq module imports //--> + <module src="resource:net/xproc/xprocxq/src/xquery/const.xqm" + uri="http://xproc.net/xproc/const"/> + <module src="resource:net/xproc/xprocxq/src/xquery/xproc.xqm" + uri="http://xproc.net/xproc"/> + <module src="resource:net/xproc/xprocxq/src/xquery/util.xqm" + uri="http://xproc.net/xproc/util"/> + <module src="resource:net/xproc/xprocxq/src/xquery/functions.xqm" + uri="http://xproc.net/xproc/functions"/> + <module src="resource:net/xproc/xprocxq/src/xquery/std.xqm" + uri="http://xproc.net/xproc/std"/> + <module src="resource:net/xproc/xprocxq/src/xquery/ext.xqm" + uri="http://xproc.net/xproc/ext"/> + <module src="resource:net/xproc/xprocxq/src/xquery/opt.xqm" + uri="http://xproc.net/xproc/opt"/> + <module src="resource:net/xproc/xprocxq/src/xquery/naming.xqm" + uri="http://xproc.net/xproc/naming"/> + <!-- Optional Modules --> <!-- <module class="org.exist.xquery.modules.compression.CompressionModule" Modified: branches/shabanovd/xslt/mime-types.xml.tmpl =================================================================== --- branches/shabanovd/xslt/mime-types.xml.tmpl 2009-05-23 16:28:37 UTC (rev 9068) +++ branches/shabanovd/xslt/mime-types.xml.tmpl 2009-05-23 16:31:25 UTC (rev 9069) @@ -22,7 +22,7 @@ <!-- Mime types stored as XML --> <mime-type name="text/xml" type="xml"> <description>XML document</description> - <extensions>.xml,.xsl,.xslt,.xsd,.rng,.mods,.xmp,.xmi,.xconf,.xmap,.xsp,.wsdl,.x3d,.rdf,.owl,.dbx,.tei,.xces,.ead,.xqx,.xform,.gml,.fo,.nvdl,.sch</extensions> + <extensions>.xml,.xsl,.xslt,.xsd,.rng,.mods,.xmp,.xmi,.xconf,.xmap,.xsp,.wsdl,.x3d,.rdf,.owl,.dbx,.tei,.xces,.ead,.xqx,.xform,.gml,.fo,.nvdl,.sch,.imdi</extensions> </mime-type> <mime-type name="application/xml" type="xml"> <description>XML document</description> Modified: branches/shabanovd/xslt/nbproject/build-impl.xml =================================================================== --- branches/shabanovd/xslt/nbproject/build-impl.xml 2009-05-23 16:28:37 UTC (rev 9068) +++ branches/shabanovd/xslt/nbproject/build-impl.xml 2009-05-23 16:31:25 UTC (rev 9069) @@ -164,7 +164,7 @@ <attribute default="${includes}" name="includes"/> <attribute default="${excludes}" name="excludes"/> <attribute default="${javac.debug}" name="debug"/> - <attribute default="" name="sourcepath"/> + <attribute default="/does/not/exist" name="sourcepath"/> <element name="customize" optional="true"/> <sequential> <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}"> Modified: branches/shabanovd/xslt/nbproject/genfiles.properties =================================================================== --- branches/shabanovd/xslt/nbproject/genfiles.properties 2009-05-23 16:28:37 UTC (rev 9068) +++ branches/shabanovd/xslt/nbproject/genfiles.properties 2009-05-23 16:31:25 UTC (rev 9069) @@ -4,5 +4,5 @@ # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=7cecdd33 -nbproject/build-impl.xml.script.CRC32=d244f64d -nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5 +nbproject/build-impl.xml.script.CRC32=bbeb66ae +nbproject/build-impl.xml.stylesheet.CRC32=65b8de21 Modified: branches/shabanovd/xslt/nbproject/project.properties =================================================================== --- branches/shabanovd/xslt/nbproject/project.properties 2009-05-23 16:28:37 UTC (rev 9068) +++ branches/shabanovd/xslt/nbproject/project.properties 2009-05-23 16:31:25 UTC (rev 9069) @@ -191,7 +191,7 @@ jmx.rmi.use.port=true meta.inf.dir=${src.dir}/META-INF file.reference.xalan-2.7.1.jar=lib/endorsed/xalan-2.7.1.jar -excludes=**/spatial/*, **/modules/svn/*, **/modules/xslfo/*,**/modules/mail/* +excludes=**/spatial/*, **/modules/svn/*, **/modules/xslfo/*,**/modules/mail/*,**/modules/jfreechart/* application.title=eXist-1.3 file.reference.excalibur-sourceresolve-1.1.jar=lib/cocoon/excalibur-sourceresolve-1.1.jar file.reference.logkit-1.2.2.jar=lib/cocoon/logkit-1.2.2.jar Modified: branches/shabanovd/xslt/src/org/exist/collections/Collection.java =================================================================== --- branches/shabanovd/xslt/src/org/exist/collections/Collection.java 2009-05-23 16:28:37 UTC (rev 9068) +++ branches/shabanovd/xslt/src/org/exist/collections/Collection.java 2009-05-23 16:31:25 UTC (rev 9069) @@ -181,9 +181,16 @@ if (!subcollections.contains(childName)) subcollections.add(childName); if (isNew) { + User user = broker.getUser(); + child.setCreationTime(System.currentTimeMillis()); + child.permissions.setOwner(user); CollectionConfiguration config = getConfiguration(broker); - if (config != null) + String group = null; + if (config != null){ + group = config.getDefCollGroup(user); child.permissions.setPermissions(config.getDefCollPermissions()); + } + child.permissions.setGroup(group); } } @@ -1170,12 +1177,6 @@ DocumentImpl document = new DocumentImpl(broker.getBrokerPool(), this, docUri); oldDoc = (DocumentImpl) documents.get(docUri.getRawCollectionPath()); - if (oldDoc == null) { - if (config != null) { - document.setPermissions(config.getDefResPermissions()); - } - } else - document.setPermissions(oldDoc.getPermissions().getPermissions()); checkPermissions(transaction, broker, oldDoc); manageDocumentInformation(broker, oldDoc, document ); @@ -1295,9 +1296,18 @@ metadata.setLastModified(System.currentTimeMillis()); document.setPermissions(oldDoc.getPermissions()); } else { + User user = broker.getUser(); metadata.setCreated(System.currentTimeMillis()); - document.getPermissions().setOwner(broker.getUser()); - document.getPermissions().setGroup(broker.getUser().getPrimaryGroup()); + document.getPermissions().setOwner(user); + String group; + CollectionConfiguration config = getConfiguration(broker); + if (config != null) { + document.setPermissions(config.getDefResPermissions()); + group = config.getDefResGroup(user); + } else { + group = user.getPrimaryGroup(); + } + document.getPermissions().setGroup(group); } document.setMetadata(metadata); } Modified: branches/shabanovd/xslt/src/org/exist/collections/CollectionConfiguration.java =================================================================== --- branches/shabanovd/xslt/src/org/exist/collections/CollectionConfiguration.java 2009-05-23 16:28:37 UTC (rev 9068) +++ branches/shabanovd/xslt/src/org/exist/collections/CollectionConfiguration.java 2009-05-23 16:31:25 UTC (rev 9069) @@ -20,9 +20,15 @@ */ package org.exist.collections; +import java.util.HashMap; +import java.util.Map; +import java.util.StringTokenizer; + import org.apache.log4j.Logger; import org.exist.collections.triggers.Trigger; import org.exist.dom.DocumentImpl; +import org.exist.security.SecurityManager; +import org.exist.security.User; import org.exist.storage.BrokerPool; import org.exist.storage.DBBroker; import org.exist.storage.IndexSpec; @@ -34,10 +40,6 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import java.util.HashMap; -import java.util.Map; -import java.util.StringTokenizer; - public class CollectionConfiguration { public final static String COLLECTION_CONFIG_SUFFIX = ".xconf"; @@ -58,8 +60,9 @@ /** First level element in a collection configuration document */ private final static String INDEX_ELEMENT = "index"; private final static String PERMISSIONS_ELEMENT = "default-permissions"; - private final static String RESOURCE_PERMISSIONS_ATTR = "resource"; - private final static String COLLECTION_PERMISSIONS_ATTR = "collection"; + private final static String GROUP_ELEMENT = "default-group"; + private final static String RESOURCE_ATTR = "resource"; + private final static String COLLECTION_ATTR = "collection"; private final static String VALIDATION_ELEMENT = "validation"; private final static String VALIDATION_MODE_ATTR = "mode"; @@ -76,12 +79,18 @@ private int defCollPermissions; private int defResPermissions; - private int validationMode=XMLReaderObjectFactory.VALIDATION_UNKNOWN; + private String defCollGroup = null; + private String defResGroup = null; + + private int validationMode=XMLReaderObjectFactory.VALIDATION_UNKNOWN; + + private SecurityManager secman; public CollectionConfiguration(BrokerPool pool) { - this.defResPermissions = pool.getSecurityManager().getResourceDefaultPerms(); - this.defCollPermissions = pool.getSecurityManager().getCollectionDefaultPerms(); - } + secman = pool.getSecurityManager(); + defResPermissions = secman.getResourceDefaultPerms(); + defCollPermissions = secman.getCollectionDefaultPerms(); + } public static boolean isCollectionConfigDocument(XmldbURI docName) { @@ -154,7 +163,7 @@ } else if (PERMISSIONS_ELEMENT.equals(node.getLocalName())) { Element elem = (Element) node; - String permsOpt = elem.getAttribute(RESOURCE_PERMISSIONS_ATTR); + String permsOpt = elem.getAttribute(RESOURCE_ATTR); if (permsOpt != null && permsOpt.length() > 0) { LOG.debug("RESOURCE: " + permsOpt); try { @@ -168,7 +177,7 @@ e.getMessage(), e); } } - permsOpt = elem.getAttribute(COLLECTION_PERMISSIONS_ATTR); + permsOpt = elem.getAttribute(COLLECTION_ATTR); if (permsOpt != null && permsOpt.length() > 0) { LOG.debug("COLLECTION: " + permsOpt); try { @@ -183,6 +192,33 @@ } } + } else if (GROUP_ELEMENT.equals(node.getLocalName())) { + Element elem = (Element) node; + String groupOpt = elem.getAttribute(RESOURCE_ATTR); + if (groupOpt != null && groupOpt.length() > 0) { + LOG.debug("RESOURCE: " + groupOpt); + if (secman.getGroup(groupOpt)!=null){ + defResGroup = groupOpt; + } else { + if (checkOnly) + throw new CollectionConfigurationException("Ilegal value for group in configuration document : " + groupOpt); + else + LOG.warn("Ilegal value for group in configuration document : " + groupOpt); + } + } + groupOpt = elem.getAttribute(COLLECTION_ATTR); + if (groupOpt != null && groupOpt.length() > 0) { + LOG.debug("COLLECTION: " + groupOpt); + if (secman.getGroup(groupOpt)!=null){ + defCollGroup = groupOpt; + } else { + if (checkOnly) + throw new CollectionConfigurationException("Ilegal value for group in configuration document : " + groupOpt); + else + LOG.warn("Ilegal value for group in configuration document : " + groupOpt); + } + } + } else if (VALIDATION_ELEMENT.equals(node.getLocalName())) { Element elem = (Element) node; String mode = elem.getAttribute(VALIDATION_MODE_ATTR); @@ -223,6 +259,7 @@ public XmldbURI getSourceCollectionURI() { return srcCollectionURI; } + public int getDefCollPermissions() { return defCollPermissions; } @@ -231,6 +268,14 @@ return defResPermissions; } + public String getDefCollGroup(User user) { + return (defCollGroup != null) ? defCollGroup : user.getPrimaryGroup(); + } + + public String getDefResGroup(User user) { + return (defResGroup != null) ? defResGroup : user.getPrimaryGroup(); + } + public int getValidationMode() { return validationMode; } Modified: branches/shabanovd/xslt/src/org/exist/util/Configuration.java =================================================================== --- branches/shabanovd/xslt/src/org/exist/util/Configuration.java 2009-05-23 16:28:37 UTC (rev 9068) +++ branches/shabanovd/xslt/src/org/exist/util/Configuration.java 2009-05-23 16:31:25 UTC (rev 9069) @@ -51,9 +51,7 @@ import org.exist.validation.GrammarPool; import org.exist.validation.resolver.eXistXMLCatalogResolver; import org.exist.xmldb.DatabaseImpl; -import org.exist.xquery.FunctionFactory; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.XQueryWatchDog; +import org.exist.xquery.*; import org.exist.xslt.TransformerFactoryAllocator; import org.quartz.SimpleTrigger; import org.w3c.dom.Document; @@ -429,6 +427,9 @@ String raiseErrorOnFailedRetrieval = xquery.getAttribute(XQueryContext.XQUERY_RAISE_ERROR_ON_FAILED_RETRIEVAL_ATTRIBUTE); config.put(XQueryContext.PROPERTY_XQUERY_RAISE_ERROR_ON_FAILED_RETRIEVAL, Configuration.parseBoolean(raiseErrorOnFailedRetrieval, XQueryContext.XQUERY_RAISE_ERROR_ON_FAILED_RETRIEVAL_DEFAULT)); LOG.debug(XQueryContext.PROPERTY_XQUERY_RAISE_ERROR_ON_FAILED_RETRIEVAL + ": " + config.get(XQueryContext.PROPERTY_XQUERY_RAISE_ERROR_ON_FAILED_RETRIEVAL)); + + String trace = xquery.getAttribute(PerformanceStats.CONFIG_ATTR_TRACE); + config.put(PerformanceStats.CONFIG_PROPERTY_TRACE, trace); //built-in-modules Map classMap = new HashMap(); Deleted: branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/Client.java =================================================================== --- trunk/eXist/test/src/org/exist/http/underheavyload/Client.java 2009-05-23 12:17:08 UTC (rev 9064) +++ branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/Client.java 2009-05-23 16:31:25 UTC (rev 9069) @@ -1,101 +0,0 @@ -/** - * - */ -package org.exist.http.underheavyload; - -import java.util.List; - -import org.apache.commons.httpclient.Header; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.URI; -import org.apache.commons.httpclient.methods.PostMethod; -import org.apache.log4j.Logger; - -/** - * @author dmitriy - * - */ -public class Client implements Runnable { - - private static final Logger LOG = Logger.getLogger(Client.class); - - private boolean running; - - private ClientsManager manager; - - public Client() { - running = true; - } - - public Client(ClientsManager clients) { - this.manager = clients; - running = true; - } - -// @Override - public void run() { - HttpClient client = new HttpClient(); - - // connect to a login page to retrieve session ID - PostMethod method = new PostMethod(getURL()); - - // post auth information with it - method.setParameter("username", "admin"); - method.setParameter("password", ""); - - try { - client.executeMethod(method); - String redirectLocation = null; - Header locationHeader = method.getResponseHeader("location"); - if (locationHeader != null) { - redirectLocation = locationHeader.getValue(); - } else { - // The response is invalid and did not provide the new location for - // the resource. Report an error or possibly handle the response - // like a 404 Not Found error. - //LOG.debug(method.getResponseBodyAsString()); - } - method.setURI(new URI(redirectLocation, true)); - client.executeMethod(method); - - // store the session info for the next call - Header[] headers = method.getResponseHeaders(); - - //TODO: fetch links - - while (running) { - Thread.sleep(1000); - - // connect to a page you're interested... - PostMethod getMethod = new PostMethod("http://localhost:8080/exist/admin/admin.xql?panel=xqueries"); - - // ...using the session ID retrieved before - for (Header header : headers) { - getMethod.setRequestHeader(header); - } - client.executeMethod(method); - - // log the page source - //LOG.info(method.getResponseBodyAsString()); - } - } catch (Exception e) { - LOG.error(e); - } - } - - protected void shutdown() { - running = false; - } - - private String getURL() { - if (manager == null) - return "http://localhost:8080/exist/admin"; - else - return manager.getURL(); - } - - public static void main(String[] args) { - Client client = new Client(); - client.run(); - } -} Copied: branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/Client.java (from rev 9064, trunk/eXist/test/src/org/exist/http/underheavyload/Client.java) =================================================================== --- branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/Client.java (rev 0) +++ branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/Client.java 2009-05-23 16:31:25 UTC (rev 9069) @@ -0,0 +1,101 @@ +/** + * + */ +package org.exist.http.underheavyload; + +import java.util.List; + +import org.apache.commons.httpclient.Header; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.URI; +import org.apache.commons.httpclient.methods.PostMethod; +import org.apache.log4j.Logger; + +/** + * @author dmitriy + * + */ +public class Client implements Runnable { + + private static final Logger LOG = Logger.getLogger(Client.class); + + private boolean running; + + private ClientsManager manager; + + public Client() { + running = true; + } + + public Client(ClientsManager clients) { + this.manager = clients; + running = true; + } + +// @Override + public void run() { + HttpClient client = new HttpClient(); + + // connect to a login page to retrieve session ID + PostMethod method = new PostMethod(getURL()); + + // post auth information with it + method.setParameter("username", "admin"); + method.setParameter("password", ""); + + try { + client.executeMethod(method); + String redirectLocation = null; + Header locationHeader = method.getResponseHeader("location"); + if (locationHeader != null) { + redirectLocation = locationHeader.getValue(); + } else { + // The response is invalid and did not provide the new location for + // the resource. Report an error or possibly handle the response + // like a 404 Not Found error. + //LOG.debug(method.getResponseBodyAsString()); + } + method.setURI(new URI(redirectLocation, true)); + client.executeMethod(method); + + // store the session info for the next call + Header[] headers = method.getResponseHeaders(); + + //TODO: fetch links + + while (running) { + Thread.sleep(1000); + + // connect to a page you're interested... + PostMethod getMethod = new PostMethod("http://localhost:8080/exist/admin/admin.xql?panel=xqueries"); + + // ...using the session ID retrieved before + for (Header header : headers) { + getMethod.setRequestHeader(header); + } + client.executeMethod(method); + + // log the page source + //LOG.info(method.getResponseBodyAsString()); + } + } catch (Exception e) { + LOG.error(e); + } + } + + protected void shutdown() { + running = false; + } + + private String getURL() { + if (manager == null) + return "http://localhost:8080/exist/admin"; + else + return manager.getURL(); + } + + public static void main(String[] args) { + Client client = new Client(); + client.run(); + } +} Deleted: branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/ClientsManager.java =================================================================== --- trunk/eXist/test/src/org/exist/http/underheavyload/ClientsManager.java 2009-05-23 12:17:08 UTC (rev 9064) +++ branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/ClientsManager.java 2009-05-23 16:31:25 UTC (rev 9069) @@ -1,78 +0,0 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2009 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id:$ - */ -package org.exist.http.underheavyload; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author <a href="mailto:sha...@gm...">Dmitriy Shabanov</a> - * - */ -public class ClientsManager implements Runnable { - - private boolean running; - - private int number = 1; - protected String url; - - List<Client> list = new ArrayList<Client>(); - - public ClientsManager(int number, String url) { - this.number = number; - this.url = url; - - Thread thread = new Thread(this); - - running = true; - thread.start(); - } - - public void shutdown() { - running = false; - - for (Client client : list) { - client.shutdown(); - } - } - -// @Override - public void run() { - Client client = null; - while (running) { - if (list.size() >= number) { - running = false; - } else { - client = new Client(this); - Thread thread = new Thread(client); - thread.start(); - list.add(client); - } - } - } - - public String getURL() { - return url; - } - - -} Copied: branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/ClientsManager.java (from rev 9064, trunk/eXist/test/src/org/exist/http/underheavyload/ClientsManager.java) =================================================================== --- branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/ClientsManager.java (rev 0) +++ branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/ClientsManager.java 2009-05-23 16:31:25 UTC (rev 9069) @@ -0,0 +1,78 @@ +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2009 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id:$ + */ +package org.exist.http.underheavyload; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author <a href="mailto:sha...@gm...">Dmitriy Shabanov</a> + * + */ +public class ClientsManager implements Runnable { + + private boolean running; + + private int number = 1; + protected String url; + + List<Client> list = new ArrayList<Client>(); + + public ClientsManager(int number, String url) { + this.number = number; + this.url = url; + + Thread thread = new Thread(this); + + running = true; + thread.start(); + } + + public void shutdown() { + running = false; + + for (Client client : list) { + client.shutdown(); + } + } + +// @Override + public void run() { + Client client = null; + while (running) { + if (list.size() >= number) { + running = false; + } else { + client = new Client(this); + Thread thread = new Thread(client); + thread.start(); + list.add(client); + } + } + } + + public String getURL() { + return url; + } + + +} Deleted: branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/DatabaseUnderLoadTest.java =================================================================== --- trunk/eXist/test/src/org/exist/http/underheavyload/DatabaseUnderLoadTest.java 2009-05-23 12:17:08 UTC (rev 9064) +++ branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/DatabaseUnderLoadTest.java 2009-05-23 16:31:25 UTC (rev 9069) @@ -1,54 +0,0 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2009 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id:$ - */ -package org.exist.http.underheavyload; - - -import org.junit.Test; - -/** - * @author <a href="mailto:sha...@gm...">Dmitriy Shabanov</a> - * - */ -public class DatabaseUnderLoadTest { - - ClientsManager manager; - - org.exist.start.Main database; - - @Test - public void testHeavyLoad() { - database = new org.exist.start.Main("jetty"); - database.run(new String[]{"jetty"}); - - manager = new ClientsManager(5, "http://localhost:8080/exist/admin"); - - try { - Thread.sleep(60*60*1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - //TODO: catch errors somehow - - manager.shutdown(); - database.shutdown(); - } -} Copied: branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/DatabaseUnderLoadTest.java (from rev 9064, trunk/eXist/test/src/org/exist/http/underheavyload/DatabaseUnderLoadTest.java) =================================================================== --- branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/DatabaseUnderLoadTest.java (rev 0) +++ branches/shabanovd/xslt/test/src/org/exist/http/underheavyload/DatabaseUnderLoadTest.java 2009-05-23 16:31:25 UTC (rev 9069) @@ -0,0 +1,54 @@ +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2009 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id:$ + */ +package org.exist.http.underheavyload; + + +import org.junit.Test; + +/** + * @author <a href="mailto:sha...@gm...">Dmitriy Shabanov</a> + * + */ +public class DatabaseUnderLoadTest { + + ClientsManager manager; + + org.exist.start.Main database; + + @Test + public void testHeavyLoad() { + database = new org.exist.start.Main("jetty"); + database.run(new String[]{"jetty"}); + + manager = new ClientsManager(5, "http://localhost:8080/exist/admin"); + + try { + Thread.sleep(60*60*1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + //TODO: catch errors somehow + + manager.shutdown(); + database.shutdown(); + } +} Modified: branches/shabanovd/xslt/test/src/org/exist/performance/xquery/RandomText.java =================================================================== --- branches/shabanovd/xslt/test/src/org/exist/performance/xquery/RandomText.java 2009-05-23 16:28:37 UTC (rev 9068) +++ branches/shabanovd/xslt/test/src/org/exist/performance/xquery/RandomText.java 2009-05-23 16:31:25 UTC (rev 9069) @@ -78,7 +78,7 @@ words = new String[list.size()]; list.toArray(words); } catch (PermissionDeniedException e) { - throw new XPathException(getASTNode(), e.getMessage(), e); + throw new XPathException(this, e.getMessage(), e); } } } Modified: branches/shabanovd/xslt/tools/ircbot/src/org/exist/irc/XBot.java =================================================================== --- branches/shabanovd/xslt/tools/ircbot/src/org/exist/irc/XBot.java 2009-05-23 16:28:37 UTC (rev 9068) +++ branches/shabanovd/xslt/tools/ircbot/src/org/exist/irc/XBot.java 2009-05-23 16:31:25 UTC (rev 9069) @@ -42,7 +42,7 @@ private final static String VERSION = "0.2"; - private final static String URI = "xmldb:exist://localhost:8080/xmlrpc/db"; + private final static String URI = "xmldb:exist://localhost:8080/exist/xmlrpc/db"; private final static String COLLECTION = "ircbot"; Deleted: branches/shabanovd/xslt/webapp/xproc/examples.xml =================================================================== --- trunk/eXist/webapp/xproc/examples.xml 2009-05-23 12:17:08 UTC (rev 9064) +++ branches/shabanovd/xslt/webapp/xproc/examples.xml 2009-05-23 16:31:25 UTC (rev 9069) @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<article> - <articleinfo> - <graphic fileref="../logo.jpg"/> - <productname>Open Source Native XML Database</productname> - <title>XProc Examples</title> - <author> - <firstname>Wolfgang M.</firstname> - <surname>Meier</surname> - <affiliation> - <address format="linespecific"><email>wolfgang at exist-db.org</email></address> - </affiliation> - </author> - </articleinfo> - <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="sidebar.xml"/> - <section> - <title>XProc Examples</title> - <para>A few examples using the <ulink url="http://code.google.com/p/xprocxq/" - >xprocxq</ulink> pure-Query implementation of the XProc standard, which is closely - integrated with eXist.</para> - - <para>To run any of these examples, some files have to be stored into the database. This - can be done through the "Examples Setup" page on the <ulink url="../admin/">admin web - application</ulink>.</para> - <table frame="void"> - <caption>Examples</caption> - <tbody> - <tr> - <td> - <ulink url="hello.xproc">hello.xproc</ulink> - </td> - <td>"Hello world" in XProc</td> - </tr> - <tr> - <td> - <ulink url="xslt-identity.xproc">xslt-identity.xproc</ulink> - </td> - <td>Pass an XML fragment through an XSLT identity transformation.</td> - </tr> - <tr> - <td> - <ulink url="twitter.xproc">twitter.xproc</ulink> - </td> - <td>Retrieve a feed from twitter in Atom format and display it.</td> - </tr> - </tbody> - </table> - </section> -</article> Copied: branches/shabanovd/xslt/webapp/xproc/examples.xml (from rev 9064, trunk/eXist/webapp/xproc/examples.xml) =================================================================== --- branches/shabanovd/xslt/webapp/xproc/examples.xml (rev 0) +++ branches/shabanovd/xslt/webapp/xproc/examples.xml 2009-05-23 16:31:25 UTC (rev 9069) @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<article> + <articleinfo> + <graphic fileref="../logo.jpg"/> + <productname>Open Source Native XML Database</productname> + <title>XProc Examples</title> + <author> + <firstname>Wolfgang M.</firstname> + <surname>Meier</surname> + <affiliation> + <address format="linespecific"><email>wolfgang at exist-db.org</email></address> + </affiliation> + </author> + </articleinfo> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="sidebar.xml"/> + <section> + <title>XProc Examples</title> + <para>A few examples using the <ulink url="http://code.google.com/p/xprocxq/" + >xprocxq</ulink> pure-Query implementation of the XProc standard, which is closely + integrated with eXist.</para> + + <para>To run any of these examples, some files have to be stored into the database. This + can be done through the "Examples Setup" page on the <ulink url="../admin/">admin web + application</ulink>.</para> + <table frame="void"> + <caption>Examples</caption> + <tbody> + <tr> + <td> + <ulink url="hello.xproc">hello.xproc</ulink> + </td> + <td>"Hello world" in XProc</td> + </tr> + <tr> + <td> + <ulink url="xslt-identity.xproc">xslt-identity.xproc</ulink> + </td> + <td>Pass an XML fragment through an XSLT identity transformation.</td> + </tr> + <tr> + <td> + <ulink url="twitter.xproc">twitter.xproc</ulink> + </td> + <td>Retrieve a feed from twitter in Atom format and display it.</td> + </tr> + </tbody> + </table> + </section> +</article> Deleted: branches/shabanovd/xslt/webapp/xproc/hello.xproc =================================================================== --- trunk/eXist/webapp/xproc/hello.xproc 2009-05-23 12:17:08 UTC (rev 9064) +++ branches/shabanovd/xslt/webapp/xproc/hello.xproc 2009-05-23 16:31:25 UTC (rev 9069) @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<p:pipeline xmlns:c="http://www.w3.org/ns/xproc-step" xmlns:p="http://www.w3.org/ns/xproc" name="pipeline"><p:identity><p:input port="source" primary="yes"><p:inline><p>Hello world!</p></p:inline></p:input></p:identity></p:pipeline> \ No newline at end of file Copied: branches/shabanovd/xslt/webapp/xproc/hello.xproc (from rev 9064, trunk/eXist/webapp/xproc/hello.xproc) =================================================================== --- branches/shabanovd/xslt/webapp/xproc/hello.xproc (rev 0) +++ branches/shabanovd/xslt/webapp/xproc/hello.xproc 2009-05-23 16:31:25 UTC (rev 9069) @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<p:pipeline xmlns:c="http://www.w3.org/ns/xproc-step" xmlns:p="http://www.w3.org/ns/xproc" name="pipeline"><p:identity><p:input port="source" primary="yes"><p:inline><p>Hello world!</p></p:inline></p:input></p:identity></p:pipeline> \ No newline at end of file Deleted: branches/shabanovd/xslt/webapp/xproc/run.xql =================================================================== --- trunk/eXist/webapp/xproc/run.xql 2009-05-23 12:17:08 UTC (rev 9064) +++ branches/shabanovd/xslt/webapp/xproc/run.xql 2009-05-23 16:31:25 UTC (rev 9069) @@ -1,14 +0,0 @@ -xquery version "1.0"; - -import module namespace request = "http://exist-db.org/xquery/request"; -import module namespace const = "http://xproc.net/xproc/const"; -import module namespace xproc = "http://xproc.net/xproc"; -import module namespace u = "http://xproc.net/xproc/util"; - -declare option exist:serialize "method=xhtml media-type=html"; - -let $pipeline := request:get-parameter("xproc", ()) -let $stdin := request:get-parameter("stdin", ()) -let $indoc := if ($stdin) then doc($stdin) else () -return - xproc:run(doc($pipeline), $indoc, "0") \ No newline at end of file Copied: branches/shabanovd/xslt/webapp/xproc/run.xql (from rev 9064, trunk/eXist/webapp/xproc/run.xql) =================================================================== --- branches/shabanovd/xslt/webapp/xproc/run.xql (rev 0) +++ branches/shabanovd/xslt/webapp/xproc/run.xql 2009-05-23 16:31:25 UTC (rev 9069) @@ -0,0 +1,14 @@ +xquery version "1.0"; + +import module namespace request = "http://exist-db.org/xquery/request"; +import module namespace const = "http://xproc.net/xproc/const"; +import module namespace xproc = "http://xproc.net/xproc"; +import module namespace u = "http://xproc.net/xproc/util"; + +declare option exist:serialize "method=xhtml media-type=html"; + +let $pipeline := request:get-parameter("xproc", ()) +let $stdin := request:get-parameter("stdin", ()) +let $indoc := if ($stdin) then doc($stdin) else () +return + xproc:run(doc($pipeline), $indoc, "0") \ No newline at end of file Deleted: branches/shabanovd/xslt/webapp/xproc/sidebar.xml =================================================================== --- trunk/eXist/webapp/xproc/sidebar.xml 2009-05-23 12:17:08 UTC (rev 9064) +++ branches/shabanovd/xslt/webapp/xproc/sidebar.xml 2009-05-23 16:31:25 UTC (rev 9069) @@ -1,130 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<sidebar title="Navigation" xmlns="http://exist-db.org/NS/sidebar"> - <search href="../search.xql"/> - <toolbar> - <link href="../index.xml">Home</link> - <link href="../download.xml">Download</link> - <link href="http://atomic.exist-db.org">Wiki</link> - <link href="../examples.xml">Demo</link> - </toolbar> - - <group name="About Us"> - <item> - <link href="../credits.xml">Who we are</link> - </item> - <item> - <link href="../acknowledge.xml">Acknowledgements</link> - </item> - </group> - <group name="Documentation"> - <item> - <link href="../quickstart.xml">Quick Start</link> - </item> - <item> - <link href="../xquery/functions.xql">Function Library</link> - </item> - <item> - <link href="../extensions.xml">Extension Modules</link> - </item> - <item> - <link href="../documentation.xml">Main Documentation</link> - </item> - <item> - <link href="../facts.xml">Feature Sheet</link> - </item> - <item> - <link href="http://en.wikibooks.org/wiki/XQuery">XQuery Wikibook</link> - </item> - </group> - <group name="Examples"> - <item> - <link href="../sandbox/sandbox.xql">XQuery Sandbox</link> - </item> - <item> - <link href="../xquery/acronyms.xql">XML Acronyms</link> - </item> - <item> - <link href="../cocoon/biblio.xq">Bibliographic</link> - </item> - <item> - <link href="../examples.xml">All Examples</link> - </item> - </group> - <group name="Community"> - <item> - <link href="../index.xml#mailing">Mailing List/IRC</link> - </item> - <item> - <link href="applications.xml">Powered By eXist</link> - </item> - <!--item> - <link href="http://wiki.exist-db.org/space/ThirdPartyTools"> - Third Party Tools - </link> - </item--> - </group> - <group name="Development"> - <item> - <link href="../roadmap.xml">Roadmap</link> - </item> - <item> - <link href="../api/index.html">Javadocs</link> - </item> - <item> - <link href="http://demo.exist-db.org/exist/xquery/svnlog.xql">ChangeLog</link> - </item> - <item> - <link href="http://sourceforge.net/tracker/?group_id=17691&atid=117691">Bug - Tracker</link> - </item> - <item> - <link href="http://sourceforge.net/svn/?group_id=17691">Subversion</link> - </item> - <item> - <link - href="http://sourceforge.net/tracker/?atid=317691&group_id=17691&func=browse" - >Submit Patches</link> - </item> - </group> - <group name="Administration"> - <item> - <link href="../admin/admin.xql">Admin</link> - </item> - <item> - <link href="../cocoon/status">Server Status</link> - </item> - <item> - <link href="../webstart/exist.jnlp">Webstart Client</link> - </item> - <item> - <link href="../webstart/exist.jnlp"> - <img src="../resources/webstart.small.jpg" border="0"/> - </link> - </item> - </group> - - <banner> - <link href="http://exist-db.org"> - <img alt="powered by eXist" border="0" src="resources/powered.gif"/> - </link> - </banner> - - <banner name="" empty="true"> - <link href="http://sourceforge.net/projects/exist"> - <img src="http://sourceforge.net/sflogo.php?group_id=17691&type=4" width="125" - height="37" border="0" alt="SourceForge Logo"/> - </link> - </banner> - - <banner> - <link href="http://www.java.net"> - <img src="resources/javanet_button_90.gif" border="0" alt="java.net Member Button"/> - </link> - </banner> - - <reference> - <link href="http://www.izforge.com/izpack/"> - <img src="resources/izpack-88x31.png" border="0" alt="IzPack Installer Generator"/> - </link> - </reference> -</sidebar> Copied: branches/shabanovd/xslt/webapp/xproc/sidebar.xml (from rev 9064, trunk/eXist/webapp/xproc/sidebar.xml) =================================================================== --- branches/shabanovd/xslt/webapp/xproc/sidebar.xml (rev 0) +++ branches/shabanovd/xslt/webapp/xproc/sidebar.xml 2009-05-23 16:31:25 UTC (rev 9069) @@ -0,0 +1,130 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sidebar title="Navigation" xmlns="http://exist-db.org/NS/sidebar"> + <search href="../search.xql"/> + <toolbar> + <link href="../index.xml">Home</link> + <link href="../download.xml">Download</link> + <link href="http://atomic.exist-db.org">Wiki</link> + <link href="../examples.xml">Demo</link> + </toolbar> + + <group name="About Us"> + <item> + <link href="../credits.xml">Who we are</link> + </item> + <item> + <link href="../acknowledge.xml">Acknowledgements</link> + </item> + </group> + <group name="Documentation"> + <item> + <link href="../quickstart.xml">Quick Start</link> + </item> + <item> + <link href="../xquery/functions.xql">Function Library</link> + </item> + <item> + <link href="../extensions.xml">Extension Modules</link> + </item> + <item> + <link href="../documentation.xml">Main Documentation</link> + </item> + <item> + <link href="../facts.xml">Feature Sheet</link> + </item> + <item> + <link href="http://en.wikibooks.org/wiki/XQuery">XQuery Wikibook</link> + </item> + </group> + <group name="Examples"> + <item> + <link href="../sandbox/sandbox.xql">XQuery Sandbox</link> + </item> + <item> + <link href="../xquery/acronyms.xql">XML Acronyms</link> + </item> + <item> + <link href="../cocoon/biblio.xq">Bibliographic</link> + </item> + <item> + <link href="../examples.xml">All Examples</link> + </item> + </group> + <group name="Community"> + <item> + <link href="../index.xml#mailing">Mailing List/IRC</link> + </item> + <item> + <link href="applications.xml">Powered By eXist</link> + </item> + <!--item> + <link href="http://wiki.exist-db.org/space/ThirdPartyTools"> + Third Party Tools + </link> + </item--> + </group> + <group name="Development"> + <item> + <link href="../roadmap.xml">Roadmap</link> + </item> + <item> + <link href="../api/index.html">Javadocs</link> + </item> + <item> + <link href="http://demo.exist-db.org/exist/xquery/svnlog.xql">ChangeLog</link> + </item> + <item> + <link href="http://sourceforge.net/tracker/?group_id=17691&atid=117691">Bug + Tracker</link> + </item> + <item> + <link href="http://sourceforge.net/svn/?group_id=17691">Subversion</link> + </item> + <item> + <link + href="http://sourceforge.net/tracker/?atid=317691&group_id=17691&func=browse" + >Submit Patches</link> + </item> + </group> + <group name="Administration"> + <item> + <link href="../admin/admin.xql">Admin</link> + </item> + <item> + <link href="../cocoon/status">Server Status</link> + </item> + <item> + <link href="../webstart/exist.jnlp">Webstart Client</link> + </item> + <item> + <link href="../webstart/exist.jnlp"> + <img src="../resources/webstart.small.jpg" border="0"/> + </link> + </item> + </group> + + <banner> + <link href="http://exist-db.org"> + <img alt="powered by eXist" border="0" src="resources/powered.gif"/> + </link> + </banner> + + <banner name="" empty="true"> + <link href="http://sourceforge.net/projects/exist"> + <img src="http://sourceforge.net/sflogo.php?group_id=17691&type=4" width="125" + height="37" border="0" alt="SourceForge Logo"/> + </link> + </banner> + + <banner> + <link href="http://www.java.net"> + <img src="resources/javanet_button_90.gif" border="0" alt="java.net Member Button"/> + </link> + </banner> + + <reference> + <link href="http://www.izforge.com/izpack/"> + <img src="resources/izpack-88x31.png" border="0" alt="IzPack Installer Generator"/> + </link> + </reference> +</sidebar> Deleted: branches/shabanovd/xslt/webapp/xproc/twitter-view.xql =================================================================== --- trunk/eXist/webapp/xproc/twitter-view.xql 2009-05-23 12:17:08 UTC (rev 9064) +++ branches/shabanovd/xslt/webapp/xproc/twitter-view.xql 2009-05-23 16:31:25 UTC (rev 9069) @@ -1,103 +0,0 @@ -xquery version "1.0"; - -(: This is the view part of the twitter client app. twitter.xql forwards - the twitter timeline in the request attribute "twitter.feed". :) - -declare namespace tc="http://exist-db.org/xquery/twitter-client"; -declare namespace atom="http://www.w3.org/2005/Atom"; -declare namespace html="http://www.w3.org/1999/xhtml"; - -(: Parse the twitter message string. This function will recognize user names, links - and tags. :) -declare function tc:parse-content($content as xs:string) { - let $filtered_text := $content - let $filtered_text := replace($filtered_text,"(http://[A-z0-9/\.?=&\-_%]+)",'<a href="$1" class="url" target="new">$1</a>') - let $filtered_text := replace($filtered_text,"@([A-z0-9/\.\-_]+)", '<a href="http://twitter.com/$1" class="username">@$1</a>') - let $filtered_text := replace($filtered_text,"&#([x0-9]+);","entity:$1") - let $filtered_text := replace($filtered_text,"(&)","$1amp;") - let $filtered_text := replace($filtered_text,"#([A-z0-9/\-_]+)", '<a href="http://search.twitter.com/search?q=%23$1">#$1</a>') - let $filtered_text := replace($filtered_text,"\[\[entity:([x0-9]+)\]\]","&#$1;") - let $filtered_text := concat("<span xmlns='http://www.w3.org/1999/xhtml' class='tw-body'>", $filtered_text, "</span>") - return util:parse($filtered_text) -}; - -(: Format an atom entry :) -declare function tc:print-entry($entry as element(atom:entry)) { - let $currentDate := adjust-date-to-timezone(current-date(), xs:dayTimeDuration("PT0H")) - let $date := xs:dateTime($entry/atom:published) - let $dateLine := - if (xs:date($date) eq $currentDate) then - xs:time($date) - else - $date - return - <li xmlns="http://www.w3.org/1999/xhtml"> - <span class="tw-thumb"> - <img src="{$entry/atom:link[@rel = 'image']/@href}" height="48" width="48"/> - </span> - <span class="tw-content"> - {tc:parse-content($entry/atom:content/node())} - <span class="tw-date">{$dateLine}</span> - </span> - </li> -}; - -(: scan a set of HTML option elements and select the one whose value matches - the $select argument :) -declare function tc:set-options($select as xs:string, $options as element(html:option)+) { - for $opt in $options - return - element { node-name($opt) } { - if ($opt/@value eq $select) then - attribute selected { "true" } - else - (), - $opt/@*, $opt/node() - } -}; - -(: twitter.xql passes the timeline feed in request attribute "twitter.feed" :) -let $feed := (.//atom:feed) -return - <html xmlns="http://www.w3.org/1999/xhtml"> - <head> - <style type="text/css"> - body {{ margin: 0; font-family: "Bitstream Vera Sans", sans-serif; }} - #container {{ margin: 20px auto; width: 620px; }} - p {{ font-size: smaller; }} - ul {{ list-style: none; padding: 0;}} - .twitter li {{ position: relative; padding: 10px 0; }} - .tw-thumb {{ height: 50px; display: block; - position: absolute; left: 0; overflow: hidden; - }} - .tw-content {{ display: block; min-height: 50px; margin-left: 65px; - line-height: 1.25em; - }} - .tw-body {{ display: block; }} - .tw-date {{ display: block; font-size: small; color: #C0C0C0; padding-top: 4px; - font-family: "Georgia", serif; - }} - .username {{ font-weight: bold; }} - a {{ text-decoration: none; }} - </style> - </head> - <body> - <div id="container"> - <p>To view the friends timeline, edit twitter.xql and set variable - $tc:login to a valid twitter user/password.</p> - <ul class="twitter"> - { - if ($feed) then - if ($feed instance of xs:string) then - <li>Twitter reported an error: {$feed}</li> - else - for $entry in $feed/atom:entry - order by xs:dateTime($entry/atom:published) descending - return - tc:print-entry($entry) - else () - } - </ul> - </div> - </body> - </html> \ No newline at end of file Copied: branches/shabanovd/xslt/webapp/xproc/twitter-view.xql (from rev 9064, trunk/eXist/webapp/xproc/twitter-view.xql) =================================================================== --- branches/shabanovd/xslt/webapp/xproc/twitter-view.xql (rev 0) +++ branches/shabanovd/xslt/webapp/xproc/twitter-view.xql 2009-05-23 16:31:25 UTC (rev 9069) @@ -0,0 +1,103 @@ +xquery version "1.0"; + +(: This is the view part of the twitter client app. twitter.xql forwards + the twitter timeline in the request attribute "twitter.feed". :) + +declare namespace tc="http://exist-db.org/xquery/twitter-client"; +declare namespace atom="http://www.w3.org/2005/Atom"; +declare namespace html="http://www.w3.org/1999/xhtml"; + +(: Parse the twitter message string. This function will recognize user names, links + and tags. :) +declare function tc:parse-content($content as xs:string) { + let $filtered_text := $content + let $filtered_text := replace($filtered_text,"(http://[A-z0-9/\.?=&\-_%]+)",'<a href="$1" class="url" target="new">$1</a>') + let $filtered_text := replace($filtered_text,"@([A-z0-9/\.\-_]+)", '<a href="http://twitter.com/$1" class="username">@$1</a>') + let $filtered_text := replace($filtered_text,"&#([x0-9]+);","entity:$1") + let $filtered_text := replace($filtered_text,"(&)","$1amp;") + let $filtered_text := replace($filtered_text,"#([A-z0-9/\-_]+)", '<a href="http://search.twitter.com/search?q=%23$1">#$1</a>') + let $filtered_text := replace($filtered_text,"\[\[entity:([x0-9]+)\]\]","&#$1;") + let $filtered_text := concat("<span xmlns='http://www.w3.org/1999/xhtml' class='tw-body'>", $filtered_text, "</span>") + return util:parse($filtered_text) +}; + +(: Format an atom entry :) +declare function tc:print-entry($entry as element(atom:entry)) { + let $currentDate := adjust-date-to-timezone(current-date(), xs:dayTimeDuration("PT0H")) + let $date := xs:dateTime($entry/atom:published) + let $dateLine := + if (xs:date($date) eq $currentDate) then + xs:time($date) + else + $date + return + <li xmlns="http://www.w3.org/1999/xhtml"> + <span class="tw-thumb"> + <img src="{$entry/atom:link[@rel = 'image']/@href}" height="48" width="48"/> + </span> + <span class="tw-content"> + {tc:parse-content($entry/atom:content/node())} + <span class="tw-date">{$dateLine}</span> + </span> + </li> +}; + +(: scan a set of HTML option elements and select the one whose value matches + the $select argument :) +declare function tc:set-options($select as xs:string, $options as element(html:option)+) { + for $opt in $options + return + element { node-name($opt) } { + if ($opt/@value eq $select) then + attribute selected { "true" } + else + (), + $opt/@*, $opt/node() + } +}; + +(: twitter.xql passes the timeline feed in request attribute "twitter.feed" :) +let $feed := (.//atom:feed) +return + <html xmlns="http://www.w3.org/1999/xhtml"> + ... [truncated message content] |