Merged DEV/SWIFT to HEAD

27168: Added generics for cannedQueryRegistry
   27169: Fixed formatting
   27170: SOLR queries
          - ALF-7072 RSOLR 013: Remote API to get ACLs and readers
            - Queries for ACL ChangeSets and ACLs
            - WebScripts for AclChangeSetsGet
          - ALF-7071 and ALF-7072: Fix naming conventions
   27171: Fixed MySQL create script (ALF-8336: RSOLR 013: DB upgrade scripts for ACL changes)
   27337: Initial draft of the publishing API
   27516: Get the basic WCM ML tests working, covering the simpler use cases
   27517: More on the WCM-QS multi lingual support, further on the aspect and the unit tests for it
   27518: Begin the WCM-QS webscript to return the translation details on a node
   27519: Push some WCM-QS ML search logic into SiteHelper, and add a unit test for it
   27542: - Initial skeleton of the channel API.
          - Initial draft of the publishing content model.
   27546: ALF-7481: RSOLR 018: Execute query against SOLR
          - pass authority filter in json body to avoid possible issue over-running the max URL length
   27559: Created a Web Site Generator tool which randomly generates WCM QS websites.
   27561: Created ChannelServiceImpl and implemented the ChannelType registry.
   27577: Start to pull across the WCM-QS ML custom action
   27579: More pulling across the WCM-QS ML custom action
   27580: More WCM-QS ML ui porting
   27588: ALF-8421: RSOLR 037: Encapsulate the CMIS Query Parser
   27589: Created a PublishingModel to hold Web Publishing constants.
   27610: ALF-7874 Add iWorks mimetype entries
   27624: Restructure index tracking
   27630: ALF-8182: SVC 03: Object Picker needs to use new NodeLocatorService to resolve startLocation parameter
          The picker now uses the NodeLocatorService to look up some start locations and most importantly allows
		  custom 'locators' to be used. All the current start location tokens are still supported
		  i.e. {companyhome}, {userhome}, {siteshome}, {doclib}, {self} and {parent}. A new one has been added called {ancestor},
		  this will allow an ancestor node to be located, the node can be selected by type or aspect, see example below.
          Some node locators can take parameters, a "startLocationParams" has therefore been added to allow these to be specified.

		  The example below shows how to configure a picker to start in the root folder of the site the node being edited is located within.

		  <field id="fdk:contentMultiple">
             <control>
                <control-param name="startLocation">{ancestor}</control-param>
                <control-param name="startLocationParams">type=st:site</control-param>
             </control>
          </field>
   27631: ALF-8182: SVC 03: Object Picker needs to use new NodeLocatorService to resolve startLocation parameter
          Centralised node locator classes to repo.nodelocator package
		  (moved out of repo.node package as that area is reserved for low level node processing)
		  and made all naming consistent i.e. nodelocator rather than nodelocation.
   27633: Fixed cmis:objectTypeId property definition (required = true, see CMIS 1.0 errata 1)
   27635: CMIS compliance fixes
   27638: - Initial operational publishing context with model bootstrapped.
          - First implementation of ChannelService.getChannels and ChannelService.createChannel. Test cases to follow imminently...

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28301 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2011-06-09 12:08:12 +00:00
parent efbd951a10
commit ae765f91d9
91 changed files with 2720 additions and 28122 deletions

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="source/java"/>
<classpathentry kind="src" path="source/test"/>
<classpathentry exported="true" kind="lib" path="config"/>
<classpathentry exported="true" kind="lib" path="source/test-resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>

View File

@@ -1160,6 +1160,7 @@
<!-- Share Data Lists model -->
<value>alfresco/model/datalistModel.xml</value>
</list>
</property>
<property name="labels">
@@ -1174,6 +1175,7 @@
<value>alfresco/messages/email-server-model</value>
<value>alfresco/messages/data-list-model</value>
<value>alfresco/messages/transfer-model</value>
<value>alfresco/messages/publishing-model</value>
</list>
</property>
</bean>

View File

@@ -100,7 +100,7 @@ CREATE TABLE alf_acl_change_set
(
id BIGINT NOT NULL AUTO_INCREMENT,
commit_time_ms BIGINT,
KEY idx_alf_acs_ctms (commit_time_ms)
KEY idx_alf_acs_ctms (commit_time_ms),
PRIMARY KEY (id)
) ENGINE=InnoDB;

View File

@@ -106,6 +106,9 @@ Inbound settings from iBatis
<!-- SOLR -->
<typeAlias alias="SOLRAclChangeSet" type="org.alfresco.repo.domain.solr.AclChangeSetEntity"/>
<typeAlias alias="SOLRAcl" type="org.alfresco.repo.domain.solr.AclEntity"/>
<typeAlias alias="SOLRAclEntry" type="org.alfresco.repo.domain.solr.AclEntryEntity"/>
<typeAlias alias="SOLRTransaction" type="org.alfresco.repo.domain.solr.TransactionEntity"/>
<typeAlias alias="SOLRNode" type="org.alfresco.repo.domain.node.NodeEntity"/>
<typeAlias alias="SOLRTrackingParameters" type="org.alfresco.repo.domain.solr.SOLRTrackingParameters"/>

View File

@@ -4,6 +4,32 @@
<mapper namespace="alfresco.solr">
<!-- RESULT MAPS -->
<resultMap id="result_AclChangeSet" type="SOLRAclChangeSet">
<result property="id" column="id" jdbcType="BIGINT" javaType="java.lang.Long"/>
<result property="commitTimeMs" column="commit_time_ms" jdbcType="BIGINT" javaType="java.lang.Long"/>
<result property="aclCount" column="acl_count" jdbcType="INTEGER" javaType="java.lang.Integer"/>
</resultMap>
<resultMap id="result_Acl_NoEntries" type="SOLRAcl">
<id property="id" column="acl_id" jdbcType="BIGINT" javaType="java.lang.Long"/>
<result property="aclChangeSetId" column="acl_changeset_id" jdbcType="BIGINT" javaType="java.lang.Long"/>
</resultMap>
<resultMap id="result_Acl_WithEntries" type="SOLRAcl" extends="result_Acl_NoEntries">
<association property="entries" resultMap="alfresco.solr.result_AclEntry"/>
</resultMap>
<resultMap id="result_AclEntry" type="SOLRAclEntry">
<id property="id" column="ace_id" jdbcType="BIGINT" javaType="java.lang.Long"/>
<result property="aclId" column="acl_id" jdbcType="BIGINT" javaType="java.lang.Long"/>
<result property="aclPermissionId" column="permission_id" jdbcType="BIGINT" javaType="java.lang.Long"/>
<result property="aclAuthority" column="authority" jdbcType="VARCHAR" javaType="java.lang.String"/>
</resultMap>
<resultMap id="result_Transaction" type="SOLRTransaction">
<result property="id" column="id" jdbcType="BIGINT" javaType="java.lang.Long"/>
<result property="commitTimeMs" column="commit_time_ms" jdbcType="BIGINT" javaType="java.lang.Long"/>
<result property="updates" column="updates" jdbcType="INTEGER" javaType="java.lang.Integer"/>
<result property="deletes" column="deletes" jdbcType="INTEGER" javaType="java.lang.Integer"/>
</resultMap>
<resultMap id="result_Node" type="SOLRNode">
<result property="id" column="id" jdbcType="BIGINT" javaType="java.lang.Long"/>
<result property="deleted" column="node_deleted" jdbcType="BIT" javaType="java.lang.Boolean" />
@@ -13,12 +39,74 @@
<result property="uuid" column="uuid" jdbcType="VARCHAR" javaType="java.lang.String"/>
</resultMap>
<resultMap id="result_Transaction" type="SOLRTransaction">
<result property="id" column="id" jdbcType="BIGINT" javaType="java.lang.Long"/>
<result property="commitTimeMs" column="commit_time_ms" jdbcType="BIGINT" javaType="java.lang.Long"/>
<result property="updates" column="updates" jdbcType="INTEGER" javaType="java.lang.Integer"/>
<result property="deletes" column="deletes" jdbcType="INTEGER" javaType="java.lang.Integer"/>
</resultMap>
<!-- SELECTS -->
<select id="select_ChangeSets_Summary" parameterType="SOLRTrackingParameters" resultMap="result_AclChangeSet">
select
acs.id as id,
acs.commit_time_ms as commit_time_ms,
(select
count(acl.id)
from
alf_access_control_list acl
where
acl.acl_change_set = acs.id
) as acl_count
from
alf_acl_change_set acs
<where>
<if test="fromCommitTimeInclusive != null">
<![CDATA[acs.commit_time_ms >= #{fromCommitTimeInclusive}]]>
</if>
<if test="fromIdInclusive != null">
<![CDATA[and acs.id >= #{fromIdInclusive}]]>
</if>
</where>
order by acs.commit_time_ms ASC, acs.id ASC
</select>
<select id="select_AclsByChangeSetIds" parameterType="SOLRTrackingParameters" resultMap="result_Acl_NoEntries">
select
acs.id as acl_changeset_id,
acl.id as acl_id
from
alf_acl_change_set acs
join alf_access_control_list acl on (acl.acl_change_set = acs.id)
<where>
<if test="ids != null">
acs.id in
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
order by
acs.id ASC,
acl.id ASC
</select>
<!--
<select id="select_ChangeSets_Detail" parameterType="SOLRTrackingParameters" resultMap="result_AclChangeSetDetails">
select
acs.id as id,
acs.commit_time_ms as commit_time_ms,
0 as acl_count,
acl.id as acl_id,
ace.id as ace_id,
ace.permission_id as permission_id,
auth.authority as authority
from
alf_acl_change_set acs
join alf_access_control_list acl on (acl.acl_change_set = acs.id)
join alf_acl_member acm on (acm.acl_id = acl.id)
join alf_access_control_entry ace on (ace.id = acm.ace_id)
join alf_authority auth on (auth.id = ace.authority_id)
order by
acs.id ASC,
acl.id ASC,
ace.id ASC
</select>
-->
<select id="select_Txns" parameterType="SOLRTrackingParameters" resultMap="result_Transaction">
select

View File

@@ -0,0 +1,20 @@
# Display labels for Publishing Model (publishingModel.xml)
pub_publishingmodel.description=Alfresco Publishing Content Model
pub_publishingmodel.type.pub_DeliveryChannel.title=Delivery Channel
pub_publishingmodel.type.pub_DeliveryChannel.description=The base type for all delivery channels
pub_publishingmodel.type.pub_DeliveryServer.title=Delivery Server
pub_publishingmodel.type.pub_DeliveryServer.description=The base type for all delivery servers
pub_publishingmodel.type.pub_Environment.title=Publishing Environment
pub_publishingmodel.type.pub_Environment.description=A container type that holds a set of delivery channels
pub_publishingmodel.type.pub_PublishingQueue.title=Publishing Queue
pub_publishingmodel.type.pub_PublishingQueue.description=A container type that holds publishing events that are yet to be processed
pub_publishingmodel.aspect.pub_ContentRoot.title=Content Root Aspect
pub_publishingmodel.aspect.pub_ContentRoot.description=Applied to a node that represents the root of a delivery channel's content hierarchy
pub_publishingmodel.association.pub_deliveryServers.title=Delivery Servers
pub_publishingmodel.association.pub_deliveryServers.description=The delivery servers associated with a delivery channel
pub_publishingmodel.association.pub_publishingQueue.title=Publishing Queue
pub_publishingmodel.association.pub_publishingQueue.description=The publishing queue for a publishing environment

View File

@@ -0,0 +1 @@
# Publish service externalised display strings

View File

@@ -0,0 +1,164 @@
<model name="pub:publishingmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<description>Alfresco Publishing Content Model</description>
<author>Alfresco</author>
<published>2011-05-04</published>
<version>1.0</version>
<imports>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
<import uri="http://www.alfresco.org/model/system/1.0" prefix="sys" />
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
</imports>
<namespaces>
<namespace uri="http://www.alfresco.org/model/publishing/1.0" prefix="pub" />
</namespaces>
<types>
<type name="pub:DeliveryChannel">
<title>Delivery Channel</title>
<description>The base type for all delivery channels</description>
<parent>cm:folder</parent>
<associations>
<child-association name="pub:deliveryServers">
<source>
<mandatory>false</mandatory>
<many>false</many>
</source>
<target>
<class>pub:DeliveryServer</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</child-association>
</associations>
</type>
<type name="pub:SiteChannelContainer">
<title>Delivery Channel Container</title>
<description>A container type that holds a set of delivery channels within a Share site</description>
<parent>cm:folder</parent>
<mandatory-aspects>
<aspect>st:siteContainer</aspect>
</mandatory-aspects>
</type>
<type name="pub:DeliveryServer">
<title>Delivery Server</title>
<description>The base type for all delivery servers</description>
<parent>sys:base</parent>
</type>
<type name="pub:Environment">
<title>Publishing Environment</title>
<description>A container type that holds a set of delivery channels</description>
<parent>cm:folder</parent>
<associations>
<child-association name="pub:publishingQueue">
<source>
<mandatory>false</mandatory>
<many>false</many>
</source>
<target>
<class>pub:PublishingQueue</class>
<mandatory>false</mandatory>
<many>false</many>
</target>
</child-association>
</associations>
</type>
<type name="pub:PublishingQueue">
<title>Publishing Queue</title>
<description>A container type that holds publishing events that are yet to be processed
</description>
<parent>sys:base</parent>
<associations>
<child-association name="pub:publishingEvent">
<source>
<mandatory>false</mandatory>
<many>false</many>
</source>
<target>
<class>pub:PublishingEvent</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</child-association>
</associations>
</type>
<type name="pub:PublishingEvent">
<title>Publishing Event</title>
<description>Holds details of a publishing event</description>
<parent>sys:base</parent>
<properties>
<property name="pub:publishingEventStatus">
<title>Status</title>
<type>d:text</type>
<mandatory>true</mandatory>
<constraints>
<constraint type="LIST">
<parameter name="allowedValues">
<list>
<value>SCHEDULED</value>
<value>IN_PROGRESS</value>
<value>COMPLETED</value>
<value>FAILED</value>
</list>
</parameter>
</constraint>
</constraints>
</property>
<property name="pub:publishingEventPayload">
<title>Payload</title>
<type>d:content</type>
<mandatory>false</mandatory>
</property>
<property name="pub:publishingEventNodesToPublish">
<title>Nodes to publish</title>
<type>d:text</type>
<multiple>true</multiple>
<index enabled="true">
<atomic>true</atomic>
<stored>false</stored>
<tokenised>false</tokenised>
</index>
</property>
<property name="pub:publishingEventNodesToUnpublish">
<title>Nodes to unpublish</title>
<type>d:text</type>
<multiple>true</multiple>
<index enabled="true">
<atomic>true</atomic>
<stored>false</stored>
<tokenised>false</tokenised>
</index>
</property>
<property name="pub:publishingEventNodesDependedOn">
<title>Nodes depended on</title>
<type>d:text</type>
<multiple>true</multiple>
<index enabled="true">
<atomic>true</atomic>
<stored>false</stored>
<tokenised>false</tokenised>
</index>
</property>
</properties>
</type>
</types>
<aspects>
<aspect name="pub:ContentRoot">
<title>Content Root Aspect</title>
<description>Applied to a node that represents the root of a delivery channel's content
hierarchy</description>
</aspect>
</aspects>
</model>

View File

@@ -4,44 +4,44 @@
<beans>
<!-- Node Locator Service Implementation -->
<bean id="nodeLocatorService" class="org.alfresco.repo.node.locator.NodeLocatorServiceImpl" />
<bean id="nodeLocatorService" class="org.alfresco.repo.nodelocator.NodeLocatorServiceImpl" />
<!-- Base Node Locator Implementation -->
<bean id="baseNodeLocator" class="org.alfresco.repo.node.locator.AbstractNodeLocator" abstract="true">
<bean id="baseNodeLocator" class="org.alfresco.repo.nodelocator.AbstractNodeLocator" abstract="true">
<property name="nodeLocatorService" ref="nodeLocatorService"/>
</bean>
<!-- Company Home Node Locator Implementation -->
<bean id="companyHomeNodeLocator" class="org.alfresco.repo.node.locator.CompanyHomeNodeLocator" parent="baseNodeLocator">
<bean id="companyHomeNodeLocator" class="org.alfresco.repo.nodelocator.CompanyHomeNodeLocator" parent="baseNodeLocator">
<property name="RepositoryHelper" ref="repositoryHelper" />
</bean>
<!-- User Home Node Locator Implementation -->
<bean id="userHomeNodeLocator" class="org.alfresco.repo.nodelocator.UserHomeNodeLocator" parent="baseNodeLocator">
<property name="RepositoryHelper" ref="repositoryHelper" />
</bean>
<!-- Sites Home Node Locator Implementation -->
<bean id="sitesHomeNodeLocator" class="org.alfresco.repo.node.locator.SitesHomeNodeLocator" parent="baseNodeLocator">
<bean id="sitesHomeNodeLocator" class="org.alfresco.repo.nodelocator.SitesHomeNodeLocator" parent="baseNodeLocator">
<property name="SiteService" ref="SiteService" />
</bean>
<!-- Document Library Node Locator Implementation -->
<bean id="docLibNodeLocator" class="org.alfresco.repo.node.locator.DocLibNodeLocator" parent="baseNodeLocator">
<property name="SiteService" ref="SiteService" />
<property name="RepositoryHelper" ref="repositoryHelper" />
</bean>
<!-- Document Library Node Locator Implementation -->
<bean id="userHomeNodeLocator" class="org.alfresco.repo.node.locator.UserHomeNodeLocator" parent="baseNodeLocator">
<property name="RepositoryHelper" ref="repositoryHelper" />
</bean>
<!-- Ancestor Node Locator Implementation -->
<bean id="ancestorNodeLocator" class="org.alfresco.repo.node.locator.AncestorNodeLocator" parent="baseNodeLocator">
<bean id="ancestorNodeLocator" class="org.alfresco.repo.nodelocator.AncestorNodeLocator" parent="baseNodeLocator">
<property name="NodeService" ref="NodeService" />
<property name="NamespaceService" ref="NamespaceService" />
</bean>
<!-- XPath Node Locator Implementation -->
<bean id="xpathNodeLocator" class="org.alfresco.repo.node.locator.XPathNodeLocator" parent="baseNodeLocator">
<bean id="xpathNodeLocator" class="org.alfresco.repo.nodelocator.XPathNodeLocator" parent="baseNodeLocator">
<property name="SearchService" ref="SearchService" />
<property name="DefaultStore" value="workspace://SpacesStore" />
</bean>
<!-- Document Library Node Locator Implementation -->
<bean id="docLibNodeLocator" class="org.alfresco.repo.site.DocLibNodeLocator" parent="baseNodeLocator">
<property name="SiteService" ref="SiteService" />
<property name="RepositoryHelper" ref="repositoryHelper" />
</bean>
</beans>

View File

@@ -0,0 +1,38 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="publishService_dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
<property name="models">
<list>
<value>alfresco/model/publishingModel.xml</value>
</list>
</property>
</bean>
<bean id="publishingResourceBundles" class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
<property name="resourceBundles">
<list>
<value>alfresco.messages.publish-service</value>
</list>
</property>
</bean>
<!-- Channel Service -->
<bean id="channelService" class="org.alfresco.repo.publishing.ChannelServiceImpl">
<property name="dictionaryService" ref="dictionaryService" />
<property name="nodeService" ref="nodeService" />
<property name="siteService" ref="siteService" />
<property name="environmentHelper" ref="environmentHelper" />
</bean>
<!-- Channel Type Implementations -->
<bean id="baseChannelType" class="org.alfresco.repo.publishing.AbstractChannelType" abstract="true" >
<property name="channelService" ref="channelService" />
</bean>
<bean id="environmentHelper" class="org.alfresco.repo.publishing.EnvironmentHelper">
<property name="nodeService" ref="nodeService" />
<property name="siteService" ref="siteService" />
</bean>
</beans>

View File

@@ -0,0 +1,12 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<import resource="classpath:alfresco/web-publishing-context.xml" />
<!-- Mock Channel Type -->
<bean id="mockChannelType" class="org.alfresco.repo.publishing.MockChannelType"
parent="baseChannelType" />
</beans>

View File

@@ -0,0 +1,60 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.opencmis.mapping;
import org.alfresco.model.ContentModel;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.PermissionService;
import org.apache.chemistry.opencmis.commons.enums.Action;
/**
* Alfresco Permission based Action Evaluator
*
* @author davidc
*/
public class CanCancelCheckOutActionEvaluator extends AbstractActionEvaluator<NodeRef>
{
private PermissionActionEvaluator permissionEvaluator;
private NodeService nodeService;
/**
* Construct
*
* @param serviceRegistry
* @param permission
*/
protected CanCancelCheckOutActionEvaluator(ServiceRegistry serviceRegistry)
{
super(serviceRegistry, Action.CAN_CANCEL_CHECK_OUT);
permissionEvaluator = new PermissionActionEvaluator(serviceRegistry, Action.CAN_CANCEL_CHECK_OUT,
PermissionService.CANCEL_CHECK_OUT);
nodeService = serviceRegistry.getNodeService();
}
public boolean isAllowed(NodeRef nodeRef)
{
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
{
return permissionEvaluator.isAllowed(nodeRef);
}
return false;
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.opencmis.mapping;
import org.alfresco.model.ContentModel;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.PermissionService;
import org.apache.chemistry.opencmis.commons.enums.Action;
/**
* Alfresco Permission based Action Evaluator
*
* @author davidc
*/
public class CanCheckInActionEvaluator extends AbstractActionEvaluator<NodeRef>
{
private PermissionActionEvaluator permissionEvaluator;
private NodeService nodeService;
/**
* Construct
*
* @param serviceRegistry
* @param permission
*/
protected CanCheckInActionEvaluator(ServiceRegistry serviceRegistry)
{
super(serviceRegistry, Action.CAN_CHECK_IN);
permissionEvaluator = new PermissionActionEvaluator(serviceRegistry, Action.CAN_CHECK_IN,
PermissionService.CHECK_IN);
nodeService = serviceRegistry.getNodeService();
}
public boolean isAllowed(NodeRef nodeRef)
{
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
{
return permissionEvaluator.isAllowed(nodeRef);
}
return false;
}
}

View File

@@ -43,10 +43,9 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
/**
* Registry of property accessors which map the retrieval and setting of properties
* within Alfresco.
* Registry of property accessors which map the retrieval and setting of
* properties within Alfresco.
*
* @author davidc
*/
@@ -65,7 +64,8 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
private Map<BaseTypeId, Map<Action, CMISActionEvaluator<? extends Object>>> actionEvaluators = new HashMap<BaseTypeId, Map<Action, CMISActionEvaluator<? extends Object>>>();
/**
* @param service registry
* @param service
* registry
*/
public void setServiceRegistry(ServiceRegistry serviceRegistry)
{
@@ -73,7 +73,8 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
}
/**
* @param cmis connector
* @param cmis
* connector
*/
public void setCmisConnector(CMISConnector cmisConnector)
{
@@ -81,7 +82,8 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
}
/**
* @param cmis mapping
* @param cmis
* mapping
*/
public void setCmisMapping(CMISMapping cmisMapping)
{
@@ -89,7 +91,8 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
}
/**
* @param cmis mapping
* @param cmis
* mapping
*/
public void setCmisDictionaryService(CMISDictionaryService cmisDictionaryService)
{
@@ -113,9 +116,12 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
registerPropertyAccessor(new ObjectTypeIdProperty(serviceRegistry, cmisDictionaryService));
registerPropertyAccessor(new BaseTypeIdProperty(serviceRegistry, cmisDictionaryService));
registerPropertyAccessor(new DirectProperty(serviceRegistry, PropertyIds.CREATED_BY, ContentModel.PROP_CREATOR));
registerPropertyAccessor(new DirectProperty(serviceRegistry, PropertyIds.CREATION_DATE, ContentModel.PROP_CREATED));
registerPropertyAccessor(new DirectProperty(serviceRegistry, PropertyIds.LAST_MODIFIED_BY, ContentModel.PROP_MODIFIER));
registerPropertyAccessor(new DirectProperty(serviceRegistry, PropertyIds.LAST_MODIFICATION_DATE, ContentModel.PROP_MODIFIED));
registerPropertyAccessor(new DirectProperty(serviceRegistry, PropertyIds.CREATION_DATE,
ContentModel.PROP_CREATED));
registerPropertyAccessor(new DirectProperty(serviceRegistry, PropertyIds.LAST_MODIFIED_BY,
ContentModel.PROP_MODIFIER));
registerPropertyAccessor(new DirectProperty(serviceRegistry, PropertyIds.LAST_MODIFICATION_DATE,
ContentModel.PROP_MODIFIED));
registerPropertyAccessor(new FixedValueProperty(serviceRegistry, PropertyIds.CHANGE_TOKEN, null));
registerPropertyAccessor(new DirectProperty(serviceRegistry, PropertyIds.NAME, ContentModel.PROP_NAME)
{
@@ -139,7 +145,8 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
registerPropertyAccessor(new ContentStreamLengthProperty(serviceRegistry));
registerPropertyAccessor(new ContentStreamMimetypeProperty(serviceRegistry));
registerPropertyAccessor(new ContentStreamIdProperty(serviceRegistry));
registerPropertyAccessor(new DirectProperty(serviceRegistry, PropertyIds.CONTENT_STREAM_FILE_NAME, ContentModel.PROP_NAME));
registerPropertyAccessor(new DirectProperty(serviceRegistry, PropertyIds.CONTENT_STREAM_FILE_NAME,
ContentModel.PROP_NAME));
registerPropertyAccessor(new ParentProperty(serviceRegistry));
registerPropertyAccessor(new PathProperty(serviceRegistry, cmisConnector));
registerPropertyAccessor(new AllowedChildObjectTypeIdsProperty(serviceRegistry, cmisMapping));
@@ -175,11 +182,8 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
PermissionService.WRITE_PROPERTIES, PermissionService.WRITE_CONTENT), false));
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new CurrentVersionEvaluator(serviceRegistry,
new CanCheckOutActionEvaluator(serviceRegistry), false));
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new CurrentVersionEvaluator(serviceRegistry,
new PermissionActionEvaluator(serviceRegistry, Action.CAN_CANCEL_CHECK_OUT,
PermissionService.CANCEL_CHECK_OUT), false));
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new PermissionActionEvaluator(serviceRegistry, Action.CAN_CHECK_IN,
PermissionService.CHECK_IN));
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new CanCancelCheckOutActionEvaluator(serviceRegistry));
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new CanCheckInActionEvaluator(serviceRegistry));
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new CurrentVersionEvaluator(serviceRegistry,
new PermissionActionEvaluator(serviceRegistry, Action.CAN_SET_CONTENT_STREAM,
PermissionService.WRITE_CONTENT), false));
@@ -290,7 +294,8 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
/**
* Gets a property accessor
*
* @param propertyId property id
* @param propertyId
* property id
* @return property accessor
*/
public CMISPropertyAccessor getPropertyAccessor(String propertyId)
@@ -301,9 +306,11 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
/**
* Create a direct node property accessor
*
* @param propertyId property id
* @param propertyName node property name
* @return property accessor
* @param propertyId
* property id
* @param propertyName
* node property name
* @return property accessor
*/
public CMISPropertyAccessor createDirectPropertyAccessor(String propertyId, QName propertyName)
{

View File

@@ -1,414 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.opencmis.search;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.repo.search.impl.lucene.AnalysisMode;
import org.alfresco.repo.search.impl.parsers.CMIS_FTSLexer;
import org.alfresco.repo.search.impl.parsers.CMIS_FTSParser;
import org.alfresco.repo.search.impl.parsers.FTSQueryException;
import org.alfresco.repo.search.impl.querymodel.Argument;
import org.alfresco.repo.search.impl.querymodel.Column;
import org.alfresco.repo.search.impl.querymodel.Constraint;
import org.alfresco.repo.search.impl.querymodel.Function;
import org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext;
import org.alfresco.repo.search.impl.querymodel.LiteralArgument;
import org.alfresco.repo.search.impl.querymodel.QueryModelFactory;
import org.alfresco.repo.search.impl.querymodel.Selector;
import org.alfresco.repo.search.impl.querymodel.Constraint.Occur;
import org.alfresco.repo.search.impl.querymodel.QueryOptions.Connective;
import org.alfresco.repo.search.impl.querymodel.impl.functions.FTSPhrase;
import org.alfresco.repo.search.impl.querymodel.impl.functions.FTSTerm;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CharStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.Token;
import org.antlr.runtime.tree.CommonTree;
import org.antlr.runtime.tree.Tree;
public class CMISFTSQueryParser
{
static public Constraint buildFTS(String ftsExpression, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext, Selector selector,
Map<String, Column> columnMap, String defaultField)
{
// TODO: Decode sql escape for '' should do in CMIS layer
// parse templates to trees ...
CMIS_FTSParser parser = null;
try
{
CharStream cs = new ANTLRStringStream(ftsExpression);
CMIS_FTSLexer lexer = new CMIS_FTSLexer(cs);
CommonTokenStream tokens = new CommonTokenStream(lexer);
parser = new CMIS_FTSParser(tokens);
CommonTree ftsNode = (CommonTree) parser.cmisFtsQuery().getTree();
return buildFTSConnective(ftsNode, factory, functionEvaluationContext, selector, columnMap, defaultField);
}
catch (RecognitionException e)
{
if (parser != null)
{
String[] tokenNames = parser.getTokenNames();
String hdr = parser.getErrorHeader(e);
String msg = parser.getErrorMessage(e, tokenNames);
throw new FTSQueryException(hdr + "\n" + msg, e);
}
return null;
}
}
static private Constraint buildFTSConnective(CommonTree node, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext,
Selector selector, Map<String, Column> columnMap, String defaultField)
{
Connective connective;
switch (node.getType())
{
case CMIS_FTSParser.DISJUNCTION:
connective = Connective.OR;
break;
case CMIS_FTSParser.CONJUNCTION:
connective = Connective.AND;
break;
default:
throw new FTSQueryException("Invalid connective ..." + node.getText());
}
List<Constraint> constraints = new ArrayList<Constraint>(node.getChildCount());
CommonTree testNode;
for (int i = 0; i < node.getChildCount(); i++)
{
CommonTree subNode = (CommonTree) node.getChild(i);
Constraint constraint;
switch (subNode.getType())
{
case CMIS_FTSParser.DISJUNCTION:
case CMIS_FTSParser.CONJUNCTION:
constraint = buildFTSConnective(subNode, factory, functionEvaluationContext, selector, columnMap, defaultField);
break;
case CMIS_FTSParser.DEFAULT:
testNode = (CommonTree) subNode.getChild(0);
constraint = buildFTSTest(testNode, factory, functionEvaluationContext, selector, columnMap, defaultField);
constraint.setOccur(Occur.DEFAULT);
break;
case CMIS_FTSParser.EXCLUDE:
testNode = (CommonTree) subNode.getChild(0);
constraint = buildFTSTest(testNode, factory, functionEvaluationContext, selector, columnMap, defaultField);
constraint.setOccur(Occur.EXCLUDE);
break;
default:
throw new FTSQueryException("Unsupported FTS option " + subNode.getText());
}
constraints.add(constraint);
}
if (constraints.size() == 1)
{
return constraints.get(0);
}
else
{
if (connective == Connective.OR)
{
return factory.createDisjunction(constraints);
}
else
{
return factory.createConjunction(constraints);
}
}
}
static private Constraint buildFTSTest(CommonTree argNode, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext,
Selector selector, Map<String, Column> columnMap, String defaultField)
{
CommonTree testNode = argNode;
switch (testNode.getType())
{
case CMIS_FTSParser.DISJUNCTION:
case CMIS_FTSParser.CONJUNCTION:
return buildFTSConnective(testNode, factory, functionEvaluationContext, selector, columnMap, defaultField);
case CMIS_FTSParser.TERM:
return buildTerm(testNode, factory, functionEvaluationContext, selector, columnMap);
case CMIS_FTSParser.PHRASE:
return buildPhrase(testNode, factory, functionEvaluationContext, selector, columnMap);
default:
throw new FTSQueryException("Unsupported FTS option " + testNode.getText());
}
}
static private Constraint buildPhrase(CommonTree testNode, QueryModelFactory factory,
FunctionEvaluationContext functionEvaluationContext, Selector selector, Map<String, Column> columnMap)
{
String functionName = FTSPhrase.NAME;
Function function = factory.getFunction(functionName);
Map<String, Argument> functionArguments = new LinkedHashMap<String, Argument>();
LiteralArgument larg = factory.createLiteralArgument(FTSPhrase.ARG_PHRASE, DataTypeDefinition.TEXT, getText(testNode.getChild(0)));
functionArguments.put(larg.getName(), larg);
return factory.createFunctionalConstraint(function, functionArguments);
}
static private Constraint buildTerm(CommonTree testNode, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext,
Selector selector, Map<String, Column> columnMap)
{
String functionName = FTSTerm.NAME;
Function function = factory.getFunction(functionName);
Map<String, Argument> functionArguments = new LinkedHashMap<String, Argument>();
LiteralArgument larg = factory.createLiteralArgument(FTSTerm.ARG_TERM, DataTypeDefinition.TEXT, getText(testNode.getChild(0)));
functionArguments.put(larg.getName(), larg);
larg = factory.createLiteralArgument(FTSTerm.ARG_TOKENISATION_MODE, DataTypeDefinition.ANY, AnalysisMode.DEFAULT);
functionArguments.put(larg.getName(), larg);
return factory.createFunctionalConstraint(function, functionArguments);
}
static class DisjunctionToken implements Token
{
public int getChannel()
{
return 0;
}
public int getCharPositionInLine()
{
return 0;
}
public CharStream getInputStream()
{
return null;
}
public int getLine()
{
return 0;
}
public String getText()
{
return null;
}
public int getTokenIndex()
{
return 0;
}
public int getType()
{
return CMIS_FTSParser.DISJUNCTION;
}
public void setChannel(int arg0)
{
}
public void setCharPositionInLine(int arg0)
{
}
public void setInputStream(CharStream arg0)
{
}
public void setLine(int arg0)
{
}
public void setText(String arg0)
{
}
public void setTokenIndex(int arg0)
{
}
public void setType(int arg0)
{
}
}
static class DefaultToken implements Token
{
public int getChannel()
{
return 0;
}
public int getCharPositionInLine()
{
return 0;
}
public CharStream getInputStream()
{
return null;
}
public int getLine()
{
return 0;
}
public String getText()
{
return null;
}
public int getTokenIndex()
{
return 0;
}
public int getType()
{
return CMIS_FTSParser.DEFAULT;
}
public void setChannel(int arg0)
{
}
public void setCharPositionInLine(int arg0)
{
}
public void setInputStream(CharStream arg0)
{
}
public void setLine(int arg0)
{
}
public void setText(String arg0)
{
}
public void setTokenIndex(int arg0)
{
}
public void setType(int arg0)
{
}
}
static private String getText(Tree node)
{
String text = node.getText();
int index;
switch (node.getType())
{
case CMIS_FTSParser.FTSWORD:
index = text.indexOf('\\');
if (index == -1)
{
return text;
}
else
{
return unescape(text);
}
case CMIS_FTSParser.FTSPHRASE:
String phrase = text.substring(1, text.length() - 1);
index = phrase.indexOf('\\');
if (index == -1)
{
return phrase;
}
else
{
return unescape(phrase);
}
default:
return text;
}
}
static private String unescape(String string)
{
StringBuilder builder = new StringBuilder(string.length());
boolean lastWasEscape = false;
for (int i = 0; i < string.length(); i++)
{
char c = string.charAt(i);
if (lastWasEscape)
{
if (c == 'u')
{
throw new UnsupportedOperationException(string);
}
else
{
builder.append(c);
}
lastWasEscape = false;
}
else
{
if (c == '\\')
{
lastWasEscape = true;
}
else
{
builder.append(c);
}
}
}
if (lastWasEscape)
{
throw new FTSQueryException("Escape character at end of string " + string);
}
return builder.toString();
}
}

View File

@@ -1,90 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.opencmis.search;
import java.util.Locale;
import org.springframework.extensions.surf.util.I18NUtil;
import org.alfresco.repo.search.impl.querymodel.QueryOptions;
import org.alfresco.service.cmr.repository.StoreRef;
/**
* The options for a CMIS query
*
* @author andyh
*/
public class CMISQueryOptions extends QueryOptions
{
public enum CMISQueryMode
{
CMS_STRICT, CMS_WITH_ALFRESCO_EXTENSIONS;
}
private CMISQueryMode queryMode = CMISQueryMode.CMS_STRICT;
/**
* Create a CMISQueryOptions instance with the default options other than
* the query and store ref. The query will be run using the locale returned
* by I18NUtil.getLocale()
*
* @param query
* - the query to run
* @param storeRef
* - the store against which to run the query
*/
public CMISQueryOptions(String query, StoreRef storeRef)
{
this(query, storeRef, I18NUtil.getLocale());
}
/**
* Create a CMISQueryOptions instance with the default options other than
* the query, store ref and locale.
*
* @param query
* - the query to run
* @param storeRef
* - the store against which to run the query
*/
public CMISQueryOptions(String query, StoreRef storeRef, Locale locale)
{
super(query, storeRef, locale);
}
/**
* Get the query mode.
*
* @return the queryMode
*/
public CMISQueryMode getQueryMode()
{
return queryMode;
}
/**
* Set the query mode.
*
* @param queryMode
* the queryMode to set
*/
public void setQueryMode(CMISQueryMode queryMode)
{
this.queryMode = queryMode;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,429 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.opencmis.search;
import java.io.Serializable;
import java.util.Collection;
import java.util.Map;
import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.opencmis.dictionary.CMISDictionaryService;
import org.alfresco.opencmis.dictionary.PropertyDefintionWrapper;
import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper;
import org.alfresco.repo.search.impl.lucene.LuceneFunction;
import org.alfresco.repo.search.impl.lucene.LuceneQueryParser;
import org.alfresco.repo.search.impl.querymodel.FunctionArgument;
import org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext;
import org.alfresco.repo.search.impl.querymodel.PredicateMode;
import org.alfresco.repo.search.impl.querymodel.QueryModelException;
import org.alfresco.repo.search.impl.querymodel.Selector;
import org.alfresco.repo.search.impl.querymodel.impl.functions.Lower;
import org.alfresco.repo.search.impl.querymodel.impl.functions.Upper;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
import org.apache.chemistry.opencmis.commons.enums.Cardinality;
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.search.Query;
/**
* @author andyh
*/
public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
{
public static BaseTypeId[] STRICT_SCOPES = new BaseTypeId[] { BaseTypeId.CMIS_DOCUMENT, BaseTypeId.CMIS_FOLDER };
public static BaseTypeId[] ALFRESCO_SCOPES = new BaseTypeId[] { BaseTypeId.CMIS_DOCUMENT, BaseTypeId.CMIS_FOLDER,
BaseTypeId.CMIS_POLICY };
private Map<String, NodeRef> nodeRefs;
private Map<String, Float> scores;
private NodeService nodeService;
private CMISDictionaryService cmisDictionaryService;
private BaseTypeId[] validScopes;
private Float score;
/**
* @param nodeRefs
* the nodeRefs to set
*/
public void setNodeRefs(Map<String, NodeRef> nodeRefs)
{
this.nodeRefs = nodeRefs;
}
/**
* @param scores
* the scores to set
*/
public void setScores(Map<String, Float> scores)
{
this.scores = scores;
}
/**
* @param nodeService
* the nodeService to set
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* @param cmisDictionaryService
* the cmisDictionaryService to set
*/
public void setCmisDictionaryService(CMISDictionaryService cmisDictionaryService)
{
this.cmisDictionaryService = cmisDictionaryService;
}
/**
* @param validScopes
* the valid scopes to set
*/
public void setValidScopes(BaseTypeId[] validScopes)
{
this.validScopes = validScopes;
}
/*
* (non-Javadoc)
*
* @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#
* getNodeRefs()
*/
public Map<String, NodeRef> getNodeRefs()
{
return nodeRefs;
}
/*
* (non-Javadoc)
*
* @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#
* getNodeService()
*/
public NodeService getNodeService()
{
return nodeService;
}
/*
* (non-Javadoc)
*
* @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#
* getProperty(org.alfresco.service.cmr.repository.NodeRef,
* org.alfresco.service.namespace.QName)
*/
public Serializable getProperty(NodeRef nodeRef, String propertyName)
{
PropertyDefintionWrapper propertyDef = cmisDictionaryService.findProperty(propertyName);
return propertyDef.getPropertyAccessor().getValue(nodeRef);
}
/*
* (non-Javadoc)
*
* @see
* org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#getScores
* ()
*/
public Map<String, Float> getScores()
{
return scores;
}
/**
* @return the score
*/
public Float getScore()
{
return score;
}
/**
* @param score
* the score to set
*/
public void setScore(Float score)
{
this.score = score;
}
public Query buildLuceneEquality(LuceneQueryParser lqp, String propertyName, Serializable value,
PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
{
PropertyDefintionWrapper propertyDef = cmisDictionaryService.findProperty(propertyName);
return propertyDef.getPropertyLuceneBuilder().buildLuceneEquality(lqp, value, mode, luceneFunction);
}
/*
* (non-Javadoc)
*
* @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#
* buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser,
* org.alfresco.service.namespace.QName, java.lang.Boolean)
*/
public Query buildLuceneExists(LuceneQueryParser lqp, String propertyName, Boolean not) throws ParseException
{
PropertyDefintionWrapper propertyDef = cmisDictionaryService.findProperty(propertyName);
return propertyDef.getPropertyLuceneBuilder().buildLuceneExists(lqp, not);
}
/*
* (non-Javadoc)
*
* @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#
* buildLuceneGreaterThan
* (org.alfresco.repo.search.impl.lucene.LuceneQueryParser,
* org.alfresco.service.namespace.QName, java.io.Serializable,
* org.alfresco.repo.search.impl.querymodel.PredicateMode)
*/
public Query buildLuceneGreaterThan(LuceneQueryParser lqp, String propertyName, Serializable value,
PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
{
PropertyDefintionWrapper propertyDef = cmisDictionaryService.findProperty(propertyName);
return propertyDef.getPropertyLuceneBuilder().buildLuceneGreaterThan(lqp, value, mode, luceneFunction);
}
/*
* (non-Javadoc)
*
* @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#
* buildLuceneGreaterThanOrEquals
* (org.alfresco.repo.search.impl.lucene.LuceneQueryParser,
* org.alfresco.service.namespace.QName, java.io.Serializable,
* org.alfresco.repo.search.impl.querymodel.PredicateMode)
*/
public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value,
PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
{
PropertyDefintionWrapper propertyDef = cmisDictionaryService.findProperty(propertyName);
return propertyDef.getPropertyLuceneBuilder().buildLuceneGreaterThanOrEquals(lqp, value, mode, luceneFunction);
}
/*
* (non-Javadoc)
*
* @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#
* buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser,
* org.alfresco.service.namespace.QName, java.util.Collection,
* java.lang.Boolean,
* org.alfresco.repo.search.impl.querymodel.PredicateMode)
*/
public Query buildLuceneIn(LuceneQueryParser lqp, String propertyName, Collection<Serializable> values,
Boolean not, PredicateMode mode) throws ParseException
{
PropertyDefintionWrapper propertyDef = cmisDictionaryService.findProperty(propertyName);
return propertyDef.getPropertyLuceneBuilder().buildLuceneIn(lqp, values, not, mode);
}
/*
* (non-Javadoc)
*
* @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#
* buildLuceneInequality
* (org.alfresco.repo.search.impl.lucene.LuceneQueryParser,
* org.alfresco.service.namespace.QName, java.io.Serializable,
* org.alfresco.repo.search.impl.querymodel.PredicateMode)
*/
public Query buildLuceneInequality(LuceneQueryParser lqp, String propertyName, Serializable value,
PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
{
PropertyDefintionWrapper propertyDef = cmisDictionaryService.findProperty(propertyName);
return propertyDef.getPropertyLuceneBuilder().buildLuceneInequality(lqp, value, mode, luceneFunction);
}
/*
* (non-Javadoc)
*
* @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#
* buildLuceneLessThan
* (org.alfresco.repo.search.impl.lucene.LuceneQueryParser,
* org.alfresco.service.namespace.QName, java.io.Serializable,
* org.alfresco.repo.search.impl.querymodel.PredicateMode)
*/
public Query buildLuceneLessThan(LuceneQueryParser lqp, String propertyName, Serializable value,
PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
{
PropertyDefintionWrapper propertyDef = cmisDictionaryService.findProperty(propertyName);
return propertyDef.getPropertyLuceneBuilder().buildLuceneLessThan(lqp, value, mode, luceneFunction);
}
/*
* (non-Javadoc)
*
* @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#
* buildLuceneLessThanOrEquals
* (org.alfresco.repo.search.impl.lucene.LuceneQueryParser,
* org.alfresco.service.namespace.QName, java.io.Serializable,
* org.alfresco.repo.search.impl.querymodel.PredicateMode)
*/
public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, String propertyName, Serializable value,
PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
{
PropertyDefintionWrapper propertyDef = cmisDictionaryService.findProperty(propertyName);
return propertyDef.getPropertyLuceneBuilder().buildLuceneLessThanOrEquals(lqp, value, mode, luceneFunction);
}
/*
* (non-Javadoc)
*
* @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#
* buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser,
* org.alfresco.service.namespace.QName, java.io.Serializable,
* java.lang.Boolean)
*/
public Query buildLuceneLike(LuceneQueryParser lqp, String propertyName, Serializable value, Boolean not)
throws ParseException
{
PropertyDefintionWrapper propertyDef = cmisDictionaryService.findProperty(propertyName);
return propertyDef.getPropertyLuceneBuilder().buildLuceneLike(lqp, value, not);
}
/*
* (non-Javadoc)
*
* @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#
* getLuceneSortField(org.alfresco.service.namespace.QName)
*/
public String getLuceneSortField(LuceneQueryParser lqp, String propertyName)
{
PropertyDefintionWrapper propertyDef = cmisDictionaryService.findProperty(propertyName);
return propertyDef.getPropertyLuceneBuilder().getLuceneSortField(lqp);
}
public boolean isObjectId(String propertyName)
{
return CMISDictionaryModel.PROP_OBJECT_ID.equalsIgnoreCase(propertyName);
}
public boolean isOrderable(String fieldName)
{
PropertyDefintionWrapper propertyDef = cmisDictionaryService.findProperty(fieldName);
if (propertyDef == null)
{
return false;
} else
{
return propertyDef.getPropertyDefinition().isOrderable();
}
}
public boolean isQueryable(String fieldName)
{
PropertyDefintionWrapper propertyDef = cmisDictionaryService.findProperty(fieldName);
if (propertyDef == null)
{
return true;
} else
{
return propertyDef.getPropertyDefinition().isQueryable();
}
}
public String getLuceneFieldName(String propertyName)
{
PropertyDefintionWrapper propertyDef = cmisDictionaryService.findProperty(propertyName);
if (propertyDef != null)
{
return propertyDef.getPropertyLuceneBuilder().getLuceneFieldName();
} else
{
// TODO: restrict to supported "special" fields
return propertyName;
}
}
public LuceneFunction getLuceneFunction(FunctionArgument functionArgument)
{
if (functionArgument == null)
{
return LuceneFunction.FIELD;
} else
{
String functionName = functionArgument.getFunction().getName();
if (functionName.equals(Upper.NAME))
{
return LuceneFunction.UPPER;
} else if (functionName.equals(Lower.NAME))
{
return LuceneFunction.LOWER;
} else
{
throw new QueryModelException("Unsupported function: " + functionName);
}
}
}
/*
* (non-Javadoc)
*
* @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#
* checkFieldApplies(org.alfresco.service.namespace.QName, java.lang.String)
*/
public void checkFieldApplies(Selector selector, String propertyName)
{
PropertyDefintionWrapper propDef = cmisDictionaryService.findPropertyByQueryName(propertyName);
if (propDef == null)
{
throw new CmisInvalidArgumentException("Unknown column/property " + propertyName);
}
TypeDefinitionWrapper typeDef = cmisDictionaryService.findTypeForClass(selector.getType(), validScopes);
if (typeDef == null)
{
throw new CmisInvalidArgumentException("Type unsupported in CMIS queries: " + selector.getAlias());
}
// Check column/property applies to selector/type
if (typeDef.getPropertyById(propDef.getPropertyId()) == null)
{
throw new CmisInvalidArgumentException("Invalid column for "
+ typeDef.getTypeDefinition(false).getQueryName() + "." + propertyName);
}
}
/*
* (non-Javadoc)
*
* @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#
* isMultiValued(java.lang.String)
*/
public boolean isMultiValued(String propertyName)
{
PropertyDefintionWrapper propDef = cmisDictionaryService.findPropertyByQueryName(propertyName);
if (propDef == null)
{
throw new CmisInvalidArgumentException("Unknown column/property " + propertyName);
}
return propDef.getPropertyDefinition().getCardinality() == Cardinality.MULTI;
}
}

View File

@@ -27,5 +27,6 @@ package org.alfresco.repo.domain.permissions;
*/
public interface AclChangeSet
{
public Long getId();
Long getId();
Long getCommitTimeMs();
}

View File

@@ -18,6 +18,8 @@
*/
package org.alfresco.repo.domain.solr;
import org.alfresco.repo.solr.AclChangeSet;
/**
* Interface for SOLR changeset objects.
*
@@ -30,6 +32,17 @@ public class AclChangeSetEntity implements AclChangeSet
private Long commitTimeMs;
private int aclCount;
@Override
public String toString()
{
return "AclChangeSetEntity " +
"[id=" + id +
", commitTimeMs=" + commitTimeMs +
", aclCount=" + aclCount +
"]";
}
@Override
public Long getId()
{
return id;
@@ -38,6 +51,7 @@ public class AclChangeSetEntity implements AclChangeSet
{
this.id = id;
}
@Override
public Long getCommitTimeMs()
{
return commitTimeMs;
@@ -46,6 +60,7 @@ public class AclChangeSetEntity implements AclChangeSet
{
this.commitTimeMs = commitTimeMs;
}
@Override
public int getAclCount()
{
return aclCount;

View File

@@ -0,0 +1,77 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.domain.solr;
import java.util.List;
import org.alfresco.repo.solr.Acl;
import org.alfresco.repo.solr.AclEntry;
/**
* Interface for SOLR changeset objects.
*
* @author Derek Hulley
* @since 4.0
*/
public class AclEntity implements Acl
{
private Long id;
private Long aclChangeSetId;
private List<AclEntry> entries;
@Override
public String toString()
{
return "AclEntity " +
"[id=" + id +
", aclChangeSetId=" + aclChangeSetId +
", entries=" + entries +
"]";
}
@Override
public Long getId()
{
return id;
}
public void setId(Long id)
{
this.id = id;
}
@Override
public Long getAclChangeSetId()
{
return aclChangeSetId;
}
public void setAclChangeSetId(Long aclChangeSetId)
{
this.aclChangeSetId = aclChangeSetId;
}
@Override
public List<AclEntry> getEntries()
{
return entries;
}
public void setEntries(List<AclEntry> entries)
{
this.entries = entries;
}
}

View File

@@ -0,0 +1,87 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.domain.solr;
import org.alfresco.repo.solr.AclEntry;
/**
* Interface for SOLR changeset objects.
*
* @author Derek Hulley
* @since 4.0
*/
public class AclEntryEntity implements AclEntry
{
private Long id;
private Long aclId;
private Long aclPermissionId;
private String aclAuthority;
@Override
public String toString()
{
return "AclEntryEntity " +
"[id=" + id +
", aclId=" + aclId +
", aclPermissionId=" + aclPermissionId +
", aclAuthority=" + aclAuthority +
"]";
}
@Override
public Long getId()
{
return id;
}
public void setId(Long id)
{
this.id = id;
}
@Override
public Long getAclId()
{
return aclId;
}
public void setAclId(Long aclId)
{
this.aclId = aclId;
}
@Override
public Long getAclPermissionId()
{
return aclPermissionId;
}
public void setAclPermissionId(Long aclPermissionId)
{
this.aclPermissionId = aclPermissionId;
}
@Override
public String getAclAuthority()
{
return aclAuthority;
}
public void setAclAuthority(String aclAuthority)
{
this.aclAuthority = aclAuthority;
}
}

View File

@@ -21,7 +21,11 @@ package org.alfresco.repo.domain.solr;
import java.util.List;
import org.alfresco.repo.domain.node.Node;
import org.alfresco.repo.solr.Acl;
import org.alfresco.repo.solr.AclChangeSet;
import org.alfresco.repo.solr.AclEntry;
import org.alfresco.repo.solr.NodeParameters;
import org.alfresco.repo.solr.Transaction;
/**
* DAO support for SOLR web scripts.
@@ -31,15 +35,34 @@ import org.alfresco.repo.solr.NodeParameters;
public interface SOLRDAO
{
/**
* Get the ACL changesets for given range parameters
* Get the ACL changesets summary (rollup count) with paging options
*
* @param minAclChangeSetId minimum ACL changeset ID - (inclusive and optional)
* @param fromCommitTime minimum ACL commit time - (inclusive and optional)
* @param maxResults limit the results. 0 or Integer.MAX_VALUE does not limit the results
* @return list of ACL changesets
* @param maxResults limit the results (must be greater than zero and less than MAX)
* @return list of ACL changesets (no details)
*/
public List<AclChangeSet> getAclChangeSets(Long minAclChangeSetId, Long fromCommitTime, int maxResults);
/**
* Get the ACLs (no rollup count) with paging options for a specific change set
*
* @param aclChangeSetIds the ACL ChangeSet IDs
* @param minAclId the minimum ACL ID - (inclusive and optional).
* @param maxResults the maximum number of results (must be greater than zero and less than MAX)
* @return list of detailed ACL ChangeSets (details included, no roll-up)
*/
public List<Acl> getAcls(List<Long> aclChangeSetIds, Long minAclId, int maxResults);
/**
* Get the ACL entries for specific ACLs, optionally pulling back authority details.
*
* @param aclIds the ACL IDs
* @param includeAuthorities <tt>true</tt> to pull back authorities with read permission
* @return
*/
public List<AclEntry> getAclEntries(List<Long> aclIds, boolean includeAuthorities);
/**
* Get the transactions from either minTxnId or fromCommitTime, optionally limited to maxResults
*

View File

@@ -19,13 +19,20 @@
package org.alfresco.repo.domain.solr;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import junit.framework.TestCase;
import org.alfresco.repo.domain.node.Node;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.solr.Acl;
import org.alfresco.repo.solr.AclChangeSet;
import org.alfresco.repo.solr.NodeParameters;
import org.alfresco.repo.solr.Transaction;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.util.ApplicationContextHelper;
import org.springframework.context.ConfigurableApplicationContext;
@@ -51,7 +58,117 @@ public class SOLRDAOTest extends TestCase
authenticationComponent.setSystemUserAsCurrentUser();
}
public void testQueryTransactionsNoLimit()
public void testQueryChangeSets_NoLimit()
{
long startTime = System.currentTimeMillis() - (5 * 60000L);
try
{
solrDAO.getAclChangeSets(null, startTime, 0);
fail("Must have result limit");
}
catch (IllegalArgumentException e)
{
// Expected
}
}
public void testQueryChangeSets_Time()
{
long startTime = System.currentTimeMillis() + (5 * 60000L); // The future
List<AclChangeSet> results = solrDAO.getAclChangeSets(null, startTime, 50);
assertTrue("ChangeSet count not limited", results.size() == 0);
}
public void testQueryChangeSets_Limit()
{
List<AclChangeSet> results = solrDAO.getAclChangeSets(null, 0L, 50);
assertTrue("Transaction count not limited", results.size() <= 50);
}
/**
* Argument checks.
*/
public void testQueryAcls_Arguments()
{
try
{
// No IDs
solrDAO.getAcls(Collections.<Long>emptyList(), null, 50);
fail("Expected IllegalArgumentException");
}
catch (IllegalArgumentException e)
{
// Expected
}
try
{
// No limit on results
solrDAO.getAcls(Collections.<Long>singletonList(1L), null, 0);
fail("Expected IllegalArgumentException");
}
catch (IllegalArgumentException e)
{
// Expected
}
}
public void testQueryAcls_All()
{
// Do a query for some changesets
List<AclChangeSet> aclChangeSets = solrDAO.getAclChangeSets(null, 0L, 50);
// Choose some changesets with changes
int aclTotal = 0;
Iterator<AclChangeSet> aclChangeSetsIterator = aclChangeSets.iterator();
while (aclChangeSetsIterator.hasNext())
{
AclChangeSet aclChangeSet = aclChangeSetsIterator.next();
if (aclChangeSet.getAclCount() == 0)
{
aclChangeSetsIterator.remove();
}
else
{
aclTotal += aclChangeSet.getAclCount();
}
}
// Stop if we don't have ACLs
if (aclTotal == 0)
{
return;
}
List<Long> aclChangeSetIds = toIds(aclChangeSets);
// Now use those to query for details
List<Acl> acls = solrDAO.getAcls(aclChangeSetIds, null, 10);
assertTrue("Results not limited", acls.size() <= 10);
// Get again, but allow all results
acls = solrDAO.getAcls(aclChangeSetIds, null, aclTotal);
assertEquals("Expected exact results", aclTotal, acls.size());
// Check that the ACL ChangeSet IDs are correct
Set<Long> aclChangeSetIdsSet = new HashSet<Long>(aclChangeSetIds);
for (Acl acl : acls)
{
Long aclChangeSetId = acl.getAclChangeSetId();
assertTrue("ACL ChangeSet ID not in original list", aclChangeSetIdsSet.contains(aclChangeSetId));
}
}
private List<Long> toIds(List<AclChangeSet> aclChangeSets)
{
List<Long> ids = new ArrayList<Long>(aclChangeSets.size());
for (AclChangeSet aclChangeSet : aclChangeSets)
{
ids.add(aclChangeSet.getId());
}
return ids;
}
public void testQueryTransactions_NoLimit()
{
long startTime = System.currentTimeMillis() - (5 * 60000L);
@@ -66,17 +183,17 @@ public class SOLRDAOTest extends TestCase
}
}
public void testQueryTransactionsTime()
public void testQueryTransactions_Time()
{
long startTime = System.currentTimeMillis() + (5 * 60000L); // The future
List<Transaction> txns = solrDAO.getTransactions(null, startTime, 50);
assertTrue("Transaction count not limited", txns.size() == 0);
List<Transaction> results = solrDAO.getTransactions(null, startTime, 50);
assertTrue("Transaction count not limited", results.size() == 0);
}
public void testQueryTransactionsLimit()
public void testQueryTransactions_Limit()
{
List<Transaction> txns = solrDAO.getTransactions(null, 0L, 50);
assertTrue("Transaction count not limited", txns.size() <= 50);
List<Transaction> results = solrDAO.getTransactions(null, 0L, 50);
assertTrue("Transaction count not limited", results.size() <= 50);
}
public void testGetNodesSimple()

View File

@@ -33,10 +33,7 @@ public class SOLRTrackingParameters
private List<Long> ids;
private Long fromRelatedIdInclusive;
private Long toRelatedIdExclusive;
public SOLRTrackingParameters()
{
}
private boolean trueOrFalse;
public Long getFromIdInclusive()
{
@@ -58,12 +55,12 @@ public class SOLRTrackingParameters
this.fromCommitTimeInclusive = fromCommitTimeInclusive;
}
public List<Long> getIdsx()
public List<Long> getIds()
{
return ids;
}
public void setIdsx(List<Long> ids)
public void setIds(List<Long> ids)
{
this.ids = ids;
}
@@ -108,7 +105,23 @@ public class SOLRTrackingParameters
return false;
}
@Override
/**
* Simple mutalbe cross-DB boolean value
*/
public boolean isTrueOrFalse()
{
return trueOrFalse;
}
/**
* Simple mutalbe cross-DB boolean value
*/
public void setTrueOrFalse(boolean trueOrFalse)
{
this.trueOrFalse = trueOrFalse;
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder(512);

View File

@@ -18,6 +18,8 @@
*/
package org.alfresco.repo.domain.solr;
import org.alfresco.repo.solr.Transaction;
/**
* Bean to represent SOLR transaction data.
*

View File

@@ -22,12 +22,14 @@ import java.util.List;
import org.alfresco.repo.domain.node.Node;
import org.alfresco.repo.domain.qname.QNameDAO;
import org.alfresco.repo.domain.solr.AclChangeSet;
import org.alfresco.repo.domain.solr.NodeParametersEntity;
import org.alfresco.repo.domain.solr.SOLRDAO;
import org.alfresco.repo.domain.solr.SOLRTrackingParameters;
import org.alfresco.repo.domain.solr.Transaction;
import org.alfresco.repo.solr.Acl;
import org.alfresco.repo.solr.AclChangeSet;
import org.alfresco.repo.solr.AclEntry;
import org.alfresco.repo.solr.NodeParameters;
import org.alfresco.repo.solr.Transaction;
import org.alfresco.util.PropertyCheck;
import org.apache.ibatis.session.RowBounds;
import org.mybatis.spring.SqlSessionTemplate;
@@ -39,6 +41,9 @@ import org.mybatis.spring.SqlSessionTemplate;
*/
public class SOLRDAOImpl implements SOLRDAO
{
private static final String SELECT_CHANGESETS_SUMMARY = "alfresco.solr.select_ChangeSets_Summary";
private static final String SELECT_ACLS_BY_CHANGESET_IDS = "alfresco.solr.select_AclsByChangeSetIds";
private static final String SELECT_ACLENTRIESS_BY_ACL_IDS = "alfresco.solr.select_AclEntriessByAclIds";
private static final String SELECT_TRANSACTIONS = "alfresco.solr.select_Txns";
private static final String SELECT_NODES = "alfresco.solr.select_Txn_Nodes";
@@ -64,30 +69,76 @@ public class SOLRDAOImpl implements SOLRDAO
PropertyCheck.mandatory(this, "qnameDAO", qnameDAO);
}
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
public List<AclChangeSet> getAclChangeSets(Long minAclChangeSetId, Long fromCommitTime, int maxResults)
{
if (minAclChangeSetId == null && fromCommitTime == null && (maxResults == 0 || maxResults == Integer.MAX_VALUE))
if (maxResults <= 0 || maxResults == Integer.MAX_VALUE)
{
throw new IllegalArgumentException("Must specify at least one parameter");
throw new IllegalArgumentException("Maximum results must be a reasonable number.");
}
SOLRTrackingParameters params = new SOLRTrackingParameters();
params.setFromIdInclusive(minAclChangeSetId);
params.setFromCommitTimeInclusive(fromCommitTime);
List<AclChangeSet> results = null;
if(maxResults != 0 && maxResults != Integer.MAX_VALUE)
return (List<AclChangeSet>) template.selectList(SELECT_CHANGESETS_SUMMARY, params, new RowBounds(0, maxResults));
}
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
public List<Acl> getAcls(List<Long> aclChangeSetIds, Long minAclId, int maxResults)
{
if (maxResults <= 0 || maxResults == Integer.MAX_VALUE)
{
results = (List<AclChangeSet>)template.selectList(SELECT_TRANSACTIONS, params, new RowBounds(0, maxResults));
throw new IllegalArgumentException("Maximum results must be a reasonable number.");
}
else
if (aclChangeSetIds == null || aclChangeSetIds.size() == 0)
{
results = (List<AclChangeSet>)template.selectList(SELECT_TRANSACTIONS, params);
throw new IllegalArgumentException("'aclChangeSetIds' must contain IDs.");
}
if (aclChangeSetIds.size() > 512)
{
throw new IllegalArgumentException("'aclChangeSetIds' cannot have more than 512 entries.");
}
if (minAclId != null)
{
throw new IllegalArgumentException("When 'minAclId' is specified then there should be only one 'aclChangeSetIds'.");
}
return results;
SOLRTrackingParameters params = new SOLRTrackingParameters();
params.setIds(aclChangeSetIds);
params.setFromIdInclusive(minAclId);
return (List<Acl>) template.selectList(SELECT_ACLS_BY_CHANGESET_IDS, params, new RowBounds(0, maxResults));
}
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
public List<AclEntry> getAclEntries(List<Long> aclIds, boolean includeAuthorities)
{
if (aclIds == null || aclIds.size() == 0)
{
throw new IllegalArgumentException("'aclIds' must contain IDs.");
}
if (aclIds.size() > 512)
{
throw new IllegalArgumentException("'aclIds' cannot have more than 512 entries.");
}
SOLRTrackingParameters params = new SOLRTrackingParameters();
params.setIds(aclIds);
params.setTrueOrFalse(includeAuthorities);
return (List<AclEntry>) template.selectList(SELECT_ACLENTRIESS_BY_ACL_IDS, params);
}
/**
@@ -128,429 +179,4 @@ public class SOLRDAOImpl implements SOLRDAO
return (List<Node>) template.selectList(SELECT_NODES, params);
}
}
//
// /**
// * A dumb iterator that iterates over longs in sequence.
// *
// */
// private static class SequenceIterator implements Iterable<Long>, Iterator<Long>
// {
// private long fromId;
// private long toId;
// private long counter;
// private int maxResults;
// private boolean inUse = false;
//
// SequenceIterator(Long fromId, Long toId, int maxResults)
// {
// this.fromId = (fromId == null ? 1 : fromId.longValue());
// this.toId = (toId == null ? Long.MAX_VALUE : toId.longValue());
// this.maxResults = maxResults;
// this.counter = this.fromId;
// }
//
// public List<Long> getList()
// {
// List<Long> ret = new ArrayList<Long>(100);
// @SuppressWarnings("rawtypes")
// Iterator nodeIds = iterator();
// while(nodeIds.hasNext())
// {
// ret.add((Long)nodeIds.next());
// }
// return ret;
// }
//
// @Override
// public Iterator<Long> iterator()
// {
// if(inUse)
// {
// throw new IllegalStateException("Already in use");
// }
// this.counter = this.fromId;
// this.inUse = true;
// return this;
// }
//
// @Override
// public boolean hasNext()
// {
// return ((counter - this.fromId) < maxResults) && counter <= toId;
// }
//
// @Override
// public Long next()
// {
// return counter++;
// }
//
// @Override
// public void remove()
// {
// throw new UnsupportedOperationException();
// }
// }
// private boolean isCategorised(AspectDefinition aspDef)
// {
// if(aspDef == null)
// {
// return false;
// }
// AspectDefinition current = aspDef;
// while (current != null)
// {
// if (current.getName().equals(ContentModel.ASPECT_CLASSIFIABLE))
// {
// return true;
// }
// else
// {
// QName parentName = current.getParentName();
// if (parentName == null)
// {
// break;
// }
// current = dictionaryService.getAspect(parentName);
// }
// }
// return false;
// }
//
// // TODO: Push into Abstract class
// private Collection<Pair<Path, QName>> getCategoryPaths(NodeRef nodeRef, Set<QName> aspects, Map<QName, Serializable> properties)
// {
// ArrayList<Pair<Path, QName>> categoryPaths = new ArrayList<Pair<Path, QName>>();
//
// for (QName classRef : aspects)
// {
// AspectDefinition aspDef = dictionaryService.getAspect(classRef);
// if (isCategorised(aspDef))
// {
// LinkedList<Pair<Path, QName>> aspectPaths = new LinkedList<Pair<Path, QName>>();
// for (PropertyDefinition propDef : aspDef.getProperties().values())
// {
// if (propDef.getDataType().getName().equals(DataTypeDefinition.CATEGORY))
// {
// for (NodeRef catRef : DefaultTypeConverter.INSTANCE.getCollection(NodeRef.class, properties.get(propDef.getName())))
// {
// if (catRef != null)
// {
// // can be running in context of System user, hence use input nodeRef
// catRef = tenantService.getName(nodeRef, catRef);
//
// try
// {
// Pair<Long, NodeRef> pair = nodeDAO.getNodePair(catRef);
// for (Path path : nodeDAO.getPaths(pair, false))
// {
// if ((path.size() > 1) && (path.get(1) instanceof Path.ChildAssocElement))
// {
// Path.ChildAssocElement cae = (Path.ChildAssocElement) path.get(1);
// boolean isFakeRoot = true;
//
// final List<ChildAssociationRef> results = new ArrayList<ChildAssociationRef>(10);
// // We have a callback handler to filter results
// ChildAssocRefQueryCallback callback = new ChildAssocRefQueryCallback()
// {
// public boolean preLoadNodes()
// {
// return false;
// }
//
// public boolean handle(
// Pair<Long, ChildAssociationRef> childAssocPair,
// Pair<Long, NodeRef> parentNodePair,
// Pair<Long, NodeRef> childNodePair)
// {
// results.add(childAssocPair.getSecond());
// return true;
// }
//
// public void done()
// {
// }
// };
//
// Pair<Long, NodeRef> caePair = nodeDAO.getNodePair(cae.getRef().getChildRef());
// nodeDAO.getParentAssocs(caePair.getFirst(), null, null, false, callback);
// for (ChildAssociationRef car : results)
// {
// if (cae.getRef().equals(car))
// {
// isFakeRoot = false;
// break;
// }
// }
// if (isFakeRoot)
// {
// if (path.toString().indexOf(aspDef.getName().toString()) != -1)
// {
// aspectPaths.add(new Pair<Path, QName>(path, aspDef.getName()));
// }
// }
// }
// }
// }
// catch (InvalidNodeRefException e)
// {
// // If the category does not exists we move on the next
// }
//
// }
// }
// }
// }
// categoryPaths.addAll(aspectPaths);
// }
// }
// // Add member final element
// for (Pair<Path, QName> pair : categoryPaths)
// {
// if (pair.getFirst().last() instanceof Path.ChildAssocElement)
// {
// Path.ChildAssocElement cae = (Path.ChildAssocElement) pair.getFirst().last();
// ChildAssociationRef assocRef = cae.getRef();
// pair.getFirst().append(new Path.ChildAssocElement(new ChildAssociationRef(assocRef.getTypeQName(), assocRef.getChildRef(), QName.createQName("member"), nodeRef)));
// }
// }
//
// return categoryPaths;
// }
//
// private List<Long> preCacheNodes(NodeMetaDataParameters nodeMetaDataParameters)
// {
// int maxResults = nodeMetaDataParameters.getMaxResults();
// boolean isLimitSet = (maxResults != 0 && maxResults != Integer.MAX_VALUE);
//
// List<Long> nodeIds = null;
// Iterable<Long> iterable = null;
// List<Long> allNodeIds = nodeMetaDataParameters.getNodeIds();
// if(allNodeIds != null)
// {
// int toIndex = (maxResults > allNodeIds.size() ? allNodeIds.size() : maxResults);
// nodeIds = isLimitSet ? allNodeIds.subList(0, toIndex) : nodeMetaDataParameters.getNodeIds();
// iterable = nodeMetaDataParameters.getNodeIds();
// }
// else
// {
// Long fromNodeId = nodeMetaDataParameters.getFromNodeId();
// Long toNodeId = nodeMetaDataParameters.getToNodeId();
// nodeIds = new ArrayList<Long>(isLimitSet ? maxResults : 100); // TODO better default here?
// iterable = new SequenceIterator(fromNodeId, toNodeId, maxResults);
// int counter = 1;
// for(Long nodeId : iterable)
// {
// if(isLimitSet && counter++ > maxResults)
// {
// break;
// }
// nodeIds.add(nodeId);
// }
// }
// // pre-cache nodes
// nodeDAO.cacheNodesById(nodeIds);
//
// return nodeIds;
// }
//
// /**
// * {@inheritDoc}
// */
// public void getNodesMetadata(
// NodeMetaDataParameters nodeMetaDataParameters,
// MetaDataResultsFilter resultFilter,
// NodeMetaDataQueryCallback callback)
// {
// int maxResults = nodeMetaDataParameters.getMaxResults();
// NodeMetaDataQueryRowHandler rowHandler = new NodeMetaDataQueryRowHandler(callback);
// boolean isLimitSet = (maxResults != 0 && maxResults != Integer.MAX_VALUE);
// boolean includeType = (resultFilter == null ? true : resultFilter.getIncludeType());
// boolean includeProperties = (resultFilter == null ? true : resultFilter.getIncludeProperties());
// boolean includeAspects = (resultFilter == null ? true : resultFilter.getIncludeAspects());
// boolean includePaths = (resultFilter == null ? true : resultFilter.getIncludePaths());
// boolean includeNodeRef = (resultFilter == null ? true : resultFilter.getIncludeNodeRef());
// boolean includeAssociations = (resultFilter == null ? true : resultFilter.getIncludeAssociations());
// boolean includeChildAssociations = (resultFilter == null ? true : resultFilter.getIncludeChildAssociations());
// boolean includeOwner = (resultFilter == null ? true : resultFilter.getIncludeOwner());
//
// List<Long> nodeIds = preCacheNodes(nodeMetaDataParameters);
//
// for(Long nodeId : nodeIds)
// {
// Map<QName, Serializable> props = null;
// Set<QName> aspects = null;
//
// if (!nodeDAO.exists(nodeId))
// {
// // Deleted nodes have no metadata
// continue;
// }
//
// NodeMetaDataEntity nodeMetaData = new NodeMetaDataEntity();
// nodeMetaData.setNodeId(nodeId);
//
// Pair<Long, NodeRef> pair = nodeDAO.getNodePair(nodeId);
// nodeMetaData.setAclId(nodeDAO.getNodeAclId(nodeId));
//
// if(includeType)
// {
// QName nodeType = nodeDAO.getNodeType(nodeId);
// nodeMetaData.setNodeType(nodeType);
// }
//
// if(includePaths || includeProperties)
// {
// props = nodeDAO.getNodeProperties(nodeId);
// }
// nodeMetaData.setProperties(props);
//
// if(includePaths || includeAspects)
// {
// aspects = nodeDAO.getNodeAspects(nodeId);
// }
// nodeMetaData.setAspects(aspects);
//
// // TODO paths may change during get i.e. node moved around in the graph
// if(includePaths)
// {
// Collection<Pair<Path, QName>> categoryPaths = getCategoryPaths(pair.getSecond(), aspects, props);
// List<Path> directPaths = nodeDAO.getPaths(pair, false);
//
// Collection<Pair<Path, QName>> paths = new ArrayList<Pair<Path, QName>>(directPaths.size() + categoryPaths.size());
// for (Path path : directPaths)
// {
// paths.add(new Pair<Path, QName>(path, null));
// }
// paths.addAll(categoryPaths);
//
// nodeMetaData.setPaths(paths);
// }
//
// if(includeNodeRef)
// {
// nodeMetaData.setNodeRef(pair.getSecond());
// }
//
// if(includeChildAssociations)
// {
// final List<ChildAssociationRef> childAssocs = new ArrayList<ChildAssociationRef>(100);
// nodeDAO.getChildAssocs(nodeId, null, null, null, null, null, new ChildAssocRefQueryCallback()
// {
// @Override
// public boolean preLoadNodes()
// {
// return false;
// }
//
// @Override
// public boolean handle(Pair<Long, ChildAssociationRef> childAssocPair, Pair<Long, NodeRef> parentNodePair,
// Pair<Long, NodeRef> childNodePair)
// {
// childAssocs.add(childAssocPair.getSecond());
// return true;
// }
//
// @Override
// public void done()
// {
// }
// });
// nodeMetaData.setChildAssocs(childAssocs);
// }
//
// if(includeAssociations)
// {
// final List<ChildAssociationRef> parentAssocs = new ArrayList<ChildAssociationRef>(100);
// nodeDAO.getParentAssocs(nodeId, null, null, null, new ChildAssocRefQueryCallback()
// {
// @Override
// public boolean handle(Pair<Long, ChildAssociationRef> childAssocPair,
// Pair<Long, NodeRef> parentNodePair, Pair<Long, NodeRef> childNodePair)
// {
// parentAssocs.add(childAssocPair.getSecond());
// return true;
// }
//
// @Override
// public boolean preLoadNodes()
// {
// return false;
// }
//
// @Override
// public void done()
// {
// }
// });
//
// // TODO non-child associations
//// Collection<Pair<Long, AssociationRef>> sourceAssocs = nodeDAO.getSourceNodeAssocs(nodeId);
//// Collection<Pair<Long, AssociationRef>> targetAssocs = nodeDAO.getTargetNodeAssocs(nodeId);
////
//// nodeMetaData.setAssocs();
// }
//
// if(includeOwner)
// {
// // cached in OwnableService
// nodeMetaData.setOwner(ownableService.getOwner(pair.getSecond()));
// }
//
// rowHandler.processResult(nodeMetaData);
// }
// }
//
// /**
// * Class that passes results from a result entity into the client callback
// */
// protected class NodeQueryRowHandler
// {
// private final NodeQueryCallback callback;
// private boolean more;
//
// private NodeQueryRowHandler(NodeQueryCallback callback)
// {
// this.callback = callback;
// this.more = true;
// }
//
// public void processResult(Node row)
// {
// if (!more)
// {
// // No more results required
// return;
// }
//
// more = callback.handleNode(row);
// }
// }
//
// /**
// * Class that passes results from a result entity into the client callback
// */
// protected class NodeMetaDataQueryRowHandler
// {
// private final NodeMetaDataQueryCallback callback;
// private boolean more;
//
// private NodeMetaDataQueryRowHandler(NodeMetaDataQueryCallback callback)
// {
// this.callback = callback;
// this.more = true;
// }
//
// public void processResult(NodeMetaData row)
// {
// if (!more)
// {
// // No more results required
// return;
// }
//
// more = callback.handleNodeMetaData(row);
// }
// }
}

View File

@@ -122,7 +122,6 @@ public class ACPExportPackageHandler
this.mimetypeService = mimetypeService;
}
/**
* @param nodeService
*/

View File

@@ -127,7 +127,7 @@ public class FileFolderServiceImpl implements FileFolderService
private SearchService searchService;
private ContentService contentService;
private MimetypeService mimetypeService;
private NamedObjectRegistry<CannedQueryFactory> cannedQueryRegistry;
private NamedObjectRegistry<CannedQueryFactory<NodeRef>> cannedQueryRegistry;
private Set<String> systemNamespaces;
@@ -180,7 +180,7 @@ public class FileFolderServiceImpl implements FileFolderService
/**
* Set the registry of {@link CannedQueryFactory canned queries}
*/
public void setCannedQueryRegistry(NamedObjectRegistry<CannedQueryFactory> cannedQueryRegistry)
public void setCannedQueryRegistry(NamedObjectRegistry<CannedQueryFactory<NodeRef>> cannedQueryRegistry)
{
this.cannedQueryRegistry = cannedQueryRegistry;
}

View File

@@ -17,23 +17,22 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.node.locator;
package org.alfresco.repo.nodelocator;
import java.util.Collections;
import java.util.List;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.repository.NodeLocator;
import org.alfresco.service.cmr.repository.NodeLocatorService;
/**
* Base class for all {@link NodeLocator} implementations.
* <p>Extending this class with automatically register the node locator with the NodeLocatorService.</p>
*
* @author Nick Smith
* @since 4.0
*
*/
public abstract class AbstractNodeLocator implements NodeLocator
{
public void setNodeLocatorService(NodeLocatorService nodeLocatorService)
{
nodeLocatorService.register(getName(), this);

View File

@@ -17,7 +17,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.node.locator;
package org.alfresco.repo.nodelocator;
import java.io.Serializable;
import java.util.ArrayList;
@@ -34,13 +34,17 @@ import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
/**
* This {@link NodeLocator} identifies an ancestor of the source node.
* <p>The node returned can be of a specific <code>type</code> and/or have a specific <code>aspect</code> applied.
*
* <p>If no parameters are passed the immediate primary parent is returned.</p>
*
* @author Nick Smith
* @since 4.0
*
*/
public class AncestorNodeLocator extends AbstractNodeLocator
{
public static final String NAME = "AncestorNodeLocator";
public static final String NAME = "ancestor";
public static final String TYPE_KEY = "type";
public static final String ASPECT_KEY = "aspect";
@@ -56,19 +60,19 @@ public class AncestorNodeLocator extends AbstractNodeLocator
QName type = getQNameParam(TYPE_KEY, params);
QName aspect = getQNameParam(ASPECT_KEY, params);
NodeRef child = source;
while(true)
while (true)
{
ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(child);
if(parentAssoc == null)
if (parentAssoc == null)
{
break; // No matching ancestor found.
}
NodeRef parent = parentAssoc.getParentRef();
if(parent == null)
if (parent == null)
{
break; // No matching ancestor found.
}
if(typeMatches(type, parent) && aspectMatches(aspect, parent))
if (typeMatches(type, parent) && aspectMatches(aspect, parent))
{
return parent; // Matching ancestor was found.
}
@@ -91,18 +95,18 @@ public class AncestorNodeLocator extends AbstractNodeLocator
private boolean typeMatches(QName type, NodeRef parent)
{
return type==null || type.equals(nodeService.getType(parent));
return type == null || type.equals(nodeService.getType(parent));
}
private boolean aspectMatches(QName aspect, NodeRef parent)
{
return aspect==null || nodeService.getAspects(parent).contains(aspect);
return aspect == null || nodeService.getAspects(parent).contains(aspect);
}
private QName getQNameParam(String key, Map<String, Serializable> params)
{
String value = (String) params.get(key);
if(value!=null)
if (value != null)
{
return QName.createQName(value, namespaceService);
}
@@ -133,5 +137,4 @@ public class AncestorNodeLocator extends AbstractNodeLocator
{
this.namespaceService = namespaceService;
}
}

View File

@@ -17,7 +17,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.node.locator;
package org.alfresco.repo.nodelocator;
import java.io.Serializable;
@@ -31,11 +31,10 @@ import org.alfresco.service.cmr.repository.NodeRef;
*
* @author Nick Smith
* @since 4.0
*
*/
public class CompanyHomeNodeLocator extends AbstractNodeLocator
{
public static final String NAME = "CompanyHomeNodeLocator";
public static final String NAME = "companyhome";
private Repository repoHelper;
@@ -63,5 +62,4 @@ public class CompanyHomeNodeLocator extends AbstractNodeLocator
{
this.repoHelper = repoHelper;
}
}

View File

@@ -17,13 +17,14 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.repository;
package org.alfresco.repo.nodelocator;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* A strategy for locating a {@link NodeRef} in the repository, given a source node and an arbitrary set of parameters.

View File

@@ -17,11 +17,13 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.repository;
package org.alfresco.repo.nodelocator;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* This service is responsible for locating {@link NodeRef}s in the repository using {@link NodeLocator} strategies.
*

View File

@@ -17,24 +17,29 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.node.locator;
package org.alfresco.repo.nodelocator;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.service.cmr.repository.NodeLocator;
import org.alfresco.service.cmr.repository.NodeLocatorService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.util.ParameterCheck;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Implementation of the {@link NodeLocatorService} which is responsible for locating a
* {@link NodeRef} using a named lookup strategy.
*
* @author Nick Smith
* @since 4.0
*
*/
public class NodeLocatorServiceImpl implements NodeLocatorService
{
/** Logger */
private static Log logger = LogFactory.getLog(NodeLocatorServiceImpl.class);
private final Map<String, NodeLocator> locators = new HashMap<String, NodeLocator>();
/**
@@ -44,12 +49,21 @@ public class NodeLocatorServiceImpl implements NodeLocatorService
public NodeRef getNode(String locatorName, NodeRef source, Map<String, Serializable> params)
{
NodeLocator locator = locators.get(locatorName);
if(locator == null)
if (locator == null)
{
String msg = "No NodeLocator is registered with name " +locatorName;
String msg = "No NodeLocator is registered with name: " + locatorName;
throw new IllegalArgumentException(msg);
}
return locator.getNode(source, params);
NodeRef node = locator.getNode(source, params);
if (logger.isDebugEnabled())
{
logger.debug("Node locator named '" + locatorName + "' found node: " + node);
}
return node;
}
/**
@@ -60,11 +74,18 @@ public class NodeLocatorServiceImpl implements NodeLocatorService
{
ParameterCheck.mandatory("locatorName", locatorName);
ParameterCheck.mandatory("locator", locator);
if(locators.containsKey(locatorName))
if (locators.containsKey(locatorName))
{
String msg = "Locator with name: " +locatorName + " is already registered!";
String msg = "Locator with name '" + locatorName + "' is already registered!";
throw new IllegalArgumentException(msg);
}
if (logger.isDebugEnabled())
{
logger.debug("Registered node locator: " + locatorName);
}
locators.put(locatorName, locator);
}

View File

@@ -17,16 +17,16 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.node.locator;
package org.alfresco.repo.nodelocator;
import static junit.framework.Assert.*;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.fail;
import static org.mockito.Mockito.when;
import javax.annotation.Resource;
import org.alfresco.repo.model.Repository;
import org.alfresco.repo.site.SiteServiceInternal;
import org.alfresco.service.cmr.repository.NodeLocatorService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.junit.Before;
import org.junit.Test;

View File

@@ -17,7 +17,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.node.locator;
package org.alfresco.repo.nodelocator;
import java.io.Serializable;
import java.util.Map;
@@ -25,13 +25,14 @@ import java.util.Map;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* This {@link NodeLocator} returns the source node.
*
* @author Nick Smith
* @since 4.0
*
*/
public class SelfNodeLocator extends AbstractNodeLocator
{
public static final String NAME = "SelfNodeLocator";
public static final String NAME = "self";
/**
* {@inheritDoc}
*/
@@ -49,5 +50,4 @@ public class SelfNodeLocator extends AbstractNodeLocator
{
return NAME;
}
}

View File

@@ -17,7 +17,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.node.locator;
package org.alfresco.repo.nodelocator;
import java.io.Serializable;
@@ -27,13 +27,14 @@ import org.alfresco.repo.site.SiteServiceInternal;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Locates the Sites Home {@link NodeRef}.
*
* @author Nick Smith
* @since 4.0
*
*/
public class SitesHomeNodeLocator extends AbstractNodeLocator
{
public static final String NAME = "SitesHomeNodeLocator";
public static final String NAME = "siteshome";
SiteServiceInternal siteService;
@@ -62,5 +63,4 @@ public class SitesHomeNodeLocator extends AbstractNodeLocator
{
this.siteService = siteService;
}
}

View File

@@ -17,7 +17,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.node.locator;
package org.alfresco.repo.nodelocator;
import java.io.Serializable;
import java.util.Map;
@@ -26,13 +26,14 @@ import org.alfresco.repo.model.Repository;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* This {@link NodeLocator} identifies and returns the node representing the current users home folder.
*
* @author Nick Smith
* @since 4.0
*
*/
public class UserHomeNodeLocator extends AbstractNodeLocator
{
public static final String NAME = "UserHomeNodeLocator";
public static final String NAME = "userhome";
private Repository repositoryHelper;
/**
@@ -42,7 +43,7 @@ public class UserHomeNodeLocator extends AbstractNodeLocator
public NodeRef getNode(NodeRef source, Map<String, Serializable> params)
{
NodeRef person = repositoryHelper.getPerson();
if(person != null)
if (person != null)
{
return repositoryHelper.getUserHome(person);
}

View File

@@ -17,7 +17,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.node.locator;
package org.alfresco.repo.nodelocator;
import java.io.Serializable;
import java.util.ArrayList;
@@ -35,13 +35,14 @@ import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.util.ParameterCheck;
/**
* This {@link NodeLocator} identifies a node from an XPath provided via the <code>xpath</code> parameter.
*
* @author Nick Smith
* @since 4.0
*
*/
public class XPathNodeLocator extends AbstractNodeLocator
{
public static final String NAME = "XPathNodeLocator";
public static final String NAME = "xpath";
public static final String QUERY_KEY = "query";
public static final String STORE_TYPE_KEY = "store_type";
public static final String STORE_ID_KEY = "store_id";
@@ -58,7 +59,7 @@ public class XPathNodeLocator extends AbstractNodeLocator
String query = (String) params.get(QUERY_KEY);
ParameterCheck.mandatoryString("query", query);
StoreRef store = null;
if(source!=null)
if (source!=null)
{
store = source.getStoreRef();
}
@@ -66,7 +67,7 @@ public class XPathNodeLocator extends AbstractNodeLocator
{
String storeType = (String) params.get(STORE_TYPE_KEY);
String storeId = (String) params.get(STORE_ID_KEY);
if(storeType !=null && storeId != null)
if (storeType != null && storeId != null)
{
store = new StoreRef(storeType, storeId);
}
@@ -81,7 +82,7 @@ public class XPathNodeLocator extends AbstractNodeLocator
return nodes.get(0);
}
}
catch(Exception e)
catch (Exception e)
{
String msg = "Error while searching XPath. StoreRef: " + store + " Query: " + query;
throw new AlfrescoRuntimeException(msg, e);

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.publishing;
import org.alfresco.service.cmr.publishing.channels.ChannelService;
import org.alfresco.service.cmr.publishing.channels.ChannelType;
/**
* @author Nick Smith
* @since 4.0
*
*/
public abstract class AbstractChannelType implements ChannelType
{
public void setChannelService(ChannelService channelService)
{
channelService.register(this);
}
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.publishing;
import org.alfresco.service.cmr.publishing.channels.Channel;
import org.alfresco.service.cmr.publishing.channels.ChannelType;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* @author Brian
*
*/
public class ChannelImpl implements Channel
{
private final NodeRef nodeRef;
private final ChannelType channelType;
private final String name;
private final ChannelServiceImpl channelService;
/**
* @param channelType
* @param name
* @param channelService
*/
public ChannelImpl(ChannelType channelType, NodeRef nodeRef, String name, ChannelServiceImpl channelService)
{
this.nodeRef = nodeRef;
this.channelType = channelType;
this.name = name;
this.channelService = channelService;
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.publishing.channels.Channel#getChannelType()
*/
@Override
public ChannelType getChannelType()
{
return channelType;
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.publishing.channels.Channel#getName()
*/
@Override
public String getName()
{
return name;
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.publishing.channels.Channel#getNodeRef()
*/
@Override
public NodeRef getNodeRef()
{
return nodeRef;
}
}

View File

@@ -0,0 +1,214 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.publishing;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.publishing.channels.Channel;
import org.alfresco.service.cmr.publishing.channels.ChannelService;
import org.alfresco.service.cmr.publishing.channels.ChannelType;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ParameterCheck;
/**
* @author Nick Smith
* @since 4.0
*
*/
public class ChannelServiceImpl implements ChannelService
{
private static final String CHANNEL_CONTAINER_NAME = "channels";
private final Map<String, ChannelType> channelTypes = new TreeMap<String, ChannelType>();
private SiteService siteService;
private NodeService nodeService;
private DictionaryService dictionaryService;
private EnvironmentHelper environmentHelper;
/**
* @param siteService the siteService to set
*/
public void setSiteService(SiteService siteService)
{
this.siteService = siteService;
}
/**
* @param nodeService the nodeService to set
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* @param dictionaryService the dictionaryService to set
*/
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
}
/**
* @param environmentHelper the environmentHelper to set
*/
public void setEnvironmentHelper(EnvironmentHelper environmentHelper)
{
this.environmentHelper = environmentHelper;
}
/**
* {@inheritDoc}
*/
public void register(ChannelType channelType)
{
ParameterCheck.mandatory("channelType", channelType);
String id = channelType.getId();
if (channelTypes.containsKey(id))
{
throw new IllegalArgumentException("Channel type " + id + " is already registered!");
}
channelTypes.put(id, channelType);
}
/**
* {@inheritDoc}
*/
public List<ChannelType> getChannelTypes()
{
return new ArrayList<ChannelType>(channelTypes.values());
}
/**
* {@inheritDoc}
*/
public Channel createChannel(String siteId, String channelTypeId, String name, Map<QName, Serializable> properties)
{
NodeRef channelContainer = getChannelContainer(siteId);
ChannelType channelType = channelTypes.get(channelTypeId);
Channel channel = null;
if (channelType != null)
{
QName channelNodeType = channelType.getChannelNodeType();
HashMap<QName, Serializable> actualProps = new HashMap<QName, Serializable>(properties);
actualProps.put(PublishingModel.PROP_CHANNEL_TYPE, channelType.getId());
QName channelQName = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, name);
ChildAssociationRef assoc = nodeService.createNode(channelContainer, ContentModel.ASSOC_CONTAINS,
channelQName, channelNodeType, actualProps);
channel = buildChannelObject(assoc.getChildRef());
QName rootNodeType = channelType.getContentRootNodeType();
nodeService.createNode(assoc.getChildRef(), ContentModel.ASSOC_CONTAINS, QName.createQName(
NamespaceService.CONTENT_MODEL_1_0_URI, "root"), rootNodeType);
// Now create the corresponding channel nodes in each of the
// configured environments
//FIXME: BJR: 20110506: Should we provide a means for supplying separate properties for each environment?
Map<String, NodeRef> environments = environmentHelper.getEnvironments(siteId);
for (NodeRef environment : environments.values())
{
nodeService.createNode(environment, ContentModel.ASSOC_CONTAINS, channelQName, channelNodeType,
actualProps);
}
}
return channel;
}
/**
* {@inheritDoc}
*/
public void deleteChannel(String siteId, String channelName)
{
// TODO Auto-generated method stub
}
/**
* {@inheritDoc}
*/
public List<Channel> getChannels(String siteId)
{
ParameterCheck.mandatory("siteId", siteId);
NodeRef channelContainer = getChannelContainer(siteId);
Collection<QName> channelNodeTypes = dictionaryService.getSubTypes(PublishingModel.TYPE_DELIVERY_CHANNEL, true);
List<ChildAssociationRef> channelAssocs = nodeService.getChildAssocs(channelContainer, new HashSet<QName>(
channelNodeTypes));
List<Channel> channelList = new ArrayList<Channel>(channelAssocs.size());
for (ChildAssociationRef channelAssoc : channelAssocs)
{
channelList.add(buildChannelObject(channelAssoc.getChildRef()));
}
return Collections.unmodifiableList(channelList);
}
/**
* @param siteId
* @return
*/
private NodeRef getChannelContainer(final String siteId)
{
return AuthenticationUtil.runAs(new RunAsWork<NodeRef>()
{
public NodeRef doWork() throws Exception
{
NodeRef channelContainer = siteService.getContainer(siteId, CHANNEL_CONTAINER_NAME);
if (channelContainer == null)
{
// No channel container exists for this site yet. Create it.
channelContainer = siteService.createContainer(siteId, CHANNEL_CONTAINER_NAME,
PublishingModel.TYPE_CHANNEL_CONTAINER, null);
}
return channelContainer;
}
}, AuthenticationUtil.getSystemUserName());
}
/**
* @param childRef
* @return
*/
private Channel buildChannelObject(NodeRef nodeRef)
{
Map<QName, Serializable> props = nodeService.getProperties(nodeRef);
ChannelType channelType = channelTypes.get((String) props.get(PublishingModel.PROP_CHANNEL_TYPE));
String name = (String) props.get(ContentModel.PROP_NAME);
return new ChannelImpl(channelType, nodeRef, name, this);
}
}

View File

@@ -0,0 +1,126 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.publishing;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.namespace.QName;
/**
* A utility class to help out with environment-related operations that are used by both the channel service
* and the publishing service.
*
* @author Brian
*
*/
public class EnvironmentHelper
{
private static final String ENVIRONMENT_CONTAINER_NAME = "environments";
private Set<QName> environmentNodeTypes;
private SiteService siteService;
private NodeService nodeService;
public EnvironmentHelper()
{
environmentNodeTypes = new HashSet<QName>();
environmentNodeTypes.add(PublishingModel.TYPE_ENVIRONMENT);
}
/**
* @param environmentNodeTypes the environmentNodeTypes to set
*/
public void setEnvironmentNodeTypes(Set<QName> environmentNodeTypes)
{
this.environmentNodeTypes = environmentNodeTypes;
}
/**
* @param siteService the siteService to set
*/
public void setSiteService(SiteService siteService)
{
this.siteService = siteService;
}
/**
* @param nodeService the nodeService to set
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public Map<String,NodeRef> getEnvironments(String siteId)
{
Map<String,NodeRef> results = new TreeMap<String, NodeRef>();
NodeRef environmentContainer = getEnvironmentContainer(siteId);
List<ChildAssociationRef> envAssocs = nodeService.getChildAssocs(environmentContainer, getEnvironmentNodeTypes());
for (ChildAssociationRef envAssoc : envAssocs)
{
NodeRef environment = envAssoc.getChildRef();
String name = (String)nodeService.getProperty(environment, ContentModel.PROP_NAME);
results.put(name, environment);
}
return results;
}
/**
* @return
*/
protected Set<QName> getEnvironmentNodeTypes()
{
return environmentNodeTypes;
}
/**
* @param siteId
* @return
*/
private NodeRef getEnvironmentContainer(final String siteId)
{
return AuthenticationUtil.runAs(new RunAsWork<NodeRef>()
{
public NodeRef doWork() throws Exception
{
NodeRef channelContainer = siteService.getContainer(siteId, ENVIRONMENT_CONTAINER_NAME);
if (channelContainer == null)
{
// No channel container exists for this site yet. Create it.
channelContainer = siteService.createContainer(siteId, ENVIRONMENT_CONTAINER_NAME,
PublishingModel.TYPE_CHANNEL_CONTAINER, null);
}
return channelContainer;
}
}, AuthenticationUtil.getSystemUserName());
}
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.publishing;
import org.alfresco.service.namespace.QName;
/**
* @author Nick Smith
* @since 4.0
*
*/
public interface PublishingModel
{
public static final String NAMESPACE = "http://www.alfresco.org/model/publishing/1.0";
public static final String PREFIX = "pub";
public static final QName TYPE_DELIVERY_CHANNEL = QName.createQName(NAMESPACE, "DeliveryChannel");
public static final QName TYPE_DELIVERY_SERVER = QName.createQName(NAMESPACE, "DeliveryServer");
public static final QName TYPE_ENVIRONMENT= QName.createQName(NAMESPACE, "Environment");
public static final QName TYPE_PUBLISHING_QUEUE = QName.createQName(NAMESPACE, "PublishingQueue");
public static final QName TYPE_CHANNEL_CONTAINER = QName.createQName(NAMESPACE, "SiteChannelContainer");
public static final QName ASPECT_CONTENT_ROOT = QName.createQName(NAMESPACE, "ContentRoot");
public static final QName PROP_CHANNEL = QName.createQName(NAMESPACE, "channel");
public static final QName PROP_CHANNEL_TYPE = QName.createQName(NAMESPACE, "channelType");
}

View File

@@ -36,7 +36,8 @@ import org.alfresco.model.RenditionModel;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.node.locator.SelfNodeLocator;
import org.alfresco.repo.nodelocator.NodeLocator;
import org.alfresco.repo.nodelocator.SelfNodeLocator;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.rendition.RenderingEngineDefinitionImpl;
import org.alfresco.repo.rendition.RenditionDefinitionImpl;
@@ -56,7 +57,6 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeLocator;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceException;

View File

@@ -95,15 +95,20 @@ public class SolrAlfrescoFTSQueryLanguage implements LuceneQueryLanguageSPI
httpClient.getState().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials("admin", "admin"));
StringBuilder url = new StringBuilder("http://localhost:8080/solr/test/alfresco/afts");
//url.append("?q=");
//URLCodec encoder = new URLCodec();
//url.append(encoder.encode(searchParameters.getQuery(), "UTF-8"));
//duplicate the query in the URL
url.append("?q=");
URLCodec encoder = new URLCodec();
url.append(encoder.encode(searchParameters.getQuery(), "UTF-8"));
url.append("?wt=json");
url.append("&fl=*,score");
if(searchParameters.getMaxItems() > 0)
{
url.append("&rows=").append(searchParameters.getMaxItems());
}
else
{
url.append("&rows=").append(Integer.MAX_VALUE);
}
url.append("&df=").append(searchParameters.getDefaultFieldName());
url.append("&start=").append(searchParameters.getSkipCount());
@@ -119,15 +124,20 @@ public class SolrAlfrescoFTSQueryLanguage implements LuceneQueryLanguageSPI
authQuery.append("AUTHORITY:\"").append(authority).append("\"");
}
url.append("&fq=");
URLCodec encoder = new URLCodec();
url.append(encoder.encode(authQuery.toString(), "UTF-8"));
//url.append("&fq=");
//encoder = new URLCodec();
//url.append(encoder.encode(authQuery.toString(), "UTF-8"));
url.append("&fq=AUTHORITY_FILTER_FROM_JSON");
// facets would go on url?
JSONObject body = new JSONObject();
body.put("query", searchParameters.getQuery());
//body.put("defaultField", searchParameters.getDefaultFieldName());
body.put("filter", authQuery);
JSONArray locales = new JSONArray();
for(Locale locale : searchParameters.getLocales())
{

File diff suppressed because it is too large Load Diff

View File

@@ -1,86 +0,0 @@
QUERY=4
ALL_COLUMNS=5
COLUMN=6
COLUMNS=7
COLUMN_REF=8
QUALIFIER=9
FUNCTION=10
SOURCE=11
TABLE=12
TABLE_REF=13
PARAMETER=14
CONJUNCTION=15
DISJUNCTION=16
NEGATION=17
PRED_COMPARISON=18
PRED_IN=19
PRED_EXISTS=20
PRED_LIKE=21
PRED_FTS=22
LIST=23
PRED_CHILD=24
PRED_DESCENDANT=25
SORT_SPECIFICATION=26
NUMERIC_LITERAL=27
STRING_LITERAL=28
DATETIME_LITERAL=29
BOOLEAN_LITERAL=30
SINGLE_VALUED_PROPERTY=31
SELECT=32
STAR=33
COMMA=34
AS=35
DOTSTAR=36
DOT=37
LPAREN=38
RPAREN=39
FROM=40
JOIN=41
INNER=42
LEFT=43
OUTER=44
ON=45
EQUALS=46
WHERE=47
OR=48
AND=49
NOT=50
NOTEQUALS=51
LESSTHAN=52
GREATERTHAN=53
LESSTHANOREQUALS=54
GREATERTHANOREQUALS=55
IN=56
LIKE=57
IS=58
NULL=59
ANY=60
CONTAINS=61
IN_FOLDER=62
IN_TREE=63
ORDER=64
BY=65
ASC=66
DESC=67
COLON=68
QUOTED_STRING=69
ID=70
DOUBLE_QUOTE=71
FLOATING_POINT_LITERAL=72
DECIMAL_INTEGER_LITERAL=73
TRUE=74
FALSE=75
TIMESTAMP=76
SCORE=77
DOTDOT=78
TILDA=79
PLUS=80
MINUS=81
DECIMAL_NUMERAL=82
DIGIT=83
EXPONENT=84
WS=85
ZERO_DIGIT=86
NON_ZERO_DIGIT=87
E=88
SIGNED_INTEGER=89

View File

@@ -1,83 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.search.impl.parsers;
import java.io.IOException;
import java.io.InputStream;
import junit.framework.TestCase;
import org.alfresco.repo.node.BaseNodeServiceTest;
import org.antlr.gunit.GrammarInfo;
import org.antlr.gunit.gUnitLexer;
import org.antlr.gunit.gUnitParser;
import org.antlr.runtime.ANTLRInputStream;
import org.antlr.runtime.CharStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;
public class CMISTest extends TestCase
{
public CMISTest()
{
// TODO Auto-generated constructor stub
}
public CMISTest(String name)
{
super(name);
// TODO Auto-generated constructor stub
}
@Override
protected void setUp() throws Exception
{
super.setUp();
}
public void testLexer() throws IOException, RecognitionException
{
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
InputStream modelStream = cl.getResourceAsStream("org/alfresco/repo/search/impl/parsers/cmis_test.gunit");
CharStream input = new ANTLRInputStream(modelStream);
gUnitExecutor executer = new gUnitExecutor(parse(input), "CMIS");
System.out.print(executer.execTest()); // unit test result
assertEquals("Failures ", 0, executer.failures.size());
assertEquals("Invalids ", 0, executer.invalids.size());
}
private GrammarInfo parse(CharStream input) throws RecognitionException
{
gUnitLexer lexer = new gUnitLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
GrammarInfo grammarInfo = new GrammarInfo();
gUnitParser parser = new gUnitParser(tokens, grammarInfo);
parser.gUnitDef(); // parse gunit script and save elements to grammarInfo
return grammarInfo;
}
}

View File

@@ -1,433 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Parser for the Alfresco full text query language.
* It may be used stand-alone or embedded, for example, in CMIS SQL contains()
*
*/
grammar CMIS_FTS;
options
{
output = AST;
backtrack = false;
}
/*
* Additional tokens for tree building.
*/
tokens
{
DISJUNCTION;
CONJUNCTION;
TERM;
PHRASE;
DEFAULT;
EXCLUDE;
}
/*
* Make sure the lexer and parser are generated in the correct package
*/
@lexer::header
{
package org.alfresco.repo.search.impl.parsers;
import org.alfresco.cmis.CMISQueryException;
}
@header
{
package org.alfresco.repo.search.impl.parsers;
}
/*
* Embeded java to control the default connective when not specified.
*
* Do not support recover from errors
*
* Add extra detail to teh error message
*/
@members
{
private Stack<String> paraphrases = new Stack<String>();
protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) throws RecognitionException
{
throw new MismatchedTokenException(ttype, input);
}
public Object recoverFromMismatchedSet(IntStream input, RecognitionException e, BitSet follow) throws RecognitionException
{
throw e;
}
public String getErrorMessage(RecognitionException e, String[] tokenNames)
{
List stack = getRuleInvocationStack(e, this.getClass().getName());
String msg = e.getMessage();
if ( e instanceof UnwantedTokenException )
{
UnwantedTokenException ute = (UnwantedTokenException)e;
String tokenName="<unknown>";
if ( ute.expecting== Token.EOF )
{
tokenName = "EOF";
}
else
{
tokenName = tokenNames[ute.expecting];
}
msg = "extraneous input " + getTokenErrorDisplay(ute.getUnexpectedToken())
+ " expecting "+tokenName;
}
else if ( e instanceof MissingTokenException )
{
MissingTokenException mte = (MissingTokenException)e;
String tokenName="<unknown>";
if ( mte.expecting== Token.EOF )
{
tokenName = "EOF";
}
else
{
tokenName = tokenNames[mte.expecting];
}
msg = "missing " + tokenName+" at " + getTokenErrorDisplay(e.token)
+ " (" + getLongTokenErrorDisplay(e.token) +")";
}
else if ( e instanceof MismatchedTokenException )
{
MismatchedTokenException mte = (MismatchedTokenException)e;
String tokenName="<unknown>";
if ( mte.expecting== Token.EOF )
{
tokenName = "EOF";
}
else
{
tokenName = tokenNames[mte.expecting];
}
msg = "mismatched input " + getTokenErrorDisplay(e.token)
+ " expecting " + tokenName +" (" + getLongTokenErrorDisplay(e.token) + ")";
}
else if ( e instanceof MismatchedTreeNodeException )
{
MismatchedTreeNodeException mtne = (MismatchedTreeNodeException)e;
String tokenName="<unknown>";
if ( mtne.expecting==Token.EOF )
{
tokenName = "EOF";
}
else
{
tokenName = tokenNames[mtne.expecting];
}
msg = "mismatched tree node: " + mtne.node + " expecting " + tokenName;
}
else if ( e instanceof NoViableAltException )
{
NoViableAltException nvae = (NoViableAltException)e;
msg = "no viable alternative at input " + getTokenErrorDisplay(e.token)
+ "\n\t (decision=" + nvae.decisionNumber
+ " state " + nvae.stateNumber + ")"
+ " decision=<<" + nvae.grammarDecisionDescription + ">>";
}
else if ( e instanceof EarlyExitException )
{
//EarlyExitException eee = (EarlyExitException)e;
// for development, can add "(decision="+eee.decisionNumber+")"
msg = "required (...)+ loop did not match anything at input " + getTokenErrorDisplay(e.token);
}
else if ( e instanceof MismatchedSetException )
{
MismatchedSetException mse = (MismatchedSetException)e;
msg = "mismatched input " + getTokenErrorDisplay(e.token)
+ " expecting set " + mse.expecting;
}
else if ( e instanceof MismatchedNotSetException )
{
MismatchedNotSetException mse = (MismatchedNotSetException)e;
msg = "mismatched input " + getTokenErrorDisplay(e.token)
+ " expecting set " + mse.expecting;
}
else if ( e instanceof FailedPredicateException )
{
FailedPredicateException fpe = (FailedPredicateException)e;
msg = "rule " + fpe.ruleName + " failed predicate: {" + fpe.predicateText + "}?";
}
if(paraphrases.size() > 0)
{
String paraphrase = (String)paraphrases.peek();
msg = msg+" "+paraphrase;
}
return msg +"\n\t"+stack;
}
public String getLongTokenErrorDisplay(Token t)
{
return t.toString();
}
public String getErrorString(RecognitionException e)
{
String hdr = getErrorHeader(e);
String msg = getErrorMessage(e, this.getTokenNames());
return hdr+" "+msg;
}
}
/*
* Always throw exceptions
*/
@rulecatch
{
catch(RecognitionException e)
{
throw e;
}
}
/*
* Support for emitting duplicate tokens from the lexer
* - required to emit ranges after matching floating point literals ...
*/
@lexer::members
{
List tokens = new ArrayList();
public void emit(Token token) {
state.token = token;
tokens.add(token);
}
public Token nextToken() {
nextTokenImpl();
if ( tokens.size()==0 ) {
return Token.EOF_TOKEN;
}
return (Token)tokens.remove(0);
}
public Token nextTokenImpl() {
while (true)
{
state.token = null;
state.channel = Token.DEFAULT_CHANNEL;
state.tokenStartCharIndex = input.index();
state.tokenStartCharPositionInLine = input.getCharPositionInLine();
state.tokenStartLine = input.getLine();
state.text = null;
if ( input.LA(1)==CharStream.EOF )
{
return Token.EOF_TOKEN;
}
try
{
mTokens();
if ( state.token==null )
{
emit();
}
else if ( state.token==Token.SKIP_TOKEN )
{
continue;
}
return state.token;
}
catch (RecognitionException re)
{
throw new CMISQueryException(getErrorString(re), re);
}
}
}
public String getErrorString(RecognitionException e)
{
String hdr = getErrorHeader(e);
String msg = getErrorMessage(e, this.getTokenNames());
return hdr+" "+msg;
}
}
/*
* Top level query
*/
cmisFtsQuery
:
ftsCmisDisjunction EOF
-> ftsCmisDisjunction
;
/*
* "OR"
* As SQL, OR has lower precedence than implicit AND
*/
ftsCmisDisjunction
:
ftsCmisConjunction (or ftsCmisConjunction)*
->
^(DISJUNCTION ftsCmisConjunction+)
;
ftsCmisConjunction
:
ftsCmisPrefixed+
->
^(CONJUNCTION ftsCmisPrefixed+)
;
ftsCmisPrefixed
:
cmisTest
->
^(DEFAULT cmisTest)
| MINUS cmisTest
->
^(EXCLUDE cmisTest)
;
cmisTest
:
cmisTerm
->
^(TERM cmisTerm)
| cmisPhrase
->
^(PHRASE cmisPhrase)
;
cmisTerm
:
FTSWORD
-> FTSWORD
;
cmisPhrase
:
FTSPHRASE
-> FTSPHRASE
;
or
:
OR
;
// ===== //
// LEXER //
// ===== //
FTSPHRASE
:
'\''
(
F_ESC
|
~(
'\\'
| '\''
)
)*
'\''
;
fragment
F_ESC
:
'\\' ('\\' | '\'')
;
/*
* Simple tokens, note all are case insensitive
*/
OR
:
(
'O'
| 'o'
)
(
'R'
| 'r'
)
;
MINUS
:
'-'
;
/*
* Standard white space
* White space may be escaped by \ in some tokens
*/
WS
:
(
' '
| '\t'
| '\r'
| '\n'
)+
{ $channel = HIDDEN; }
;
FTSWORD
:
START_WORD IN_WORD*
;
fragment
START_WORD
:
~ (
' '
| '\t'
| '\r'
| '\n'
| '-'
)
;
fragment
IN_WORD
:
~ (
' '
| '\t'
| '\r'
| '\n'
)
;

View File

@@ -1,14 +0,0 @@
DISJUNCTION=4
CONJUNCTION=5
TERM=6
PHRASE=7
DEFAULT=8
EXCLUDE=9
MINUS=10
FTSWORD=11
FTSPHRASE=12
OR=13
F_ESC=14
WS=15
START_WORD=16
IN_WORD=17

View File

@@ -1,628 +0,0 @@
// $ANTLR 3.3 Nov 30, 2010 12:50:56 W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g 2011-04-26 17:09:23
package org.alfresco.repo.search.impl.parsers;
import org.alfresco.cmis.CMISQueryException;
import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;
public class CMIS_FTSLexer extends Lexer {
public static final int EOF=-1;
public static final int DISJUNCTION=4;
public static final int CONJUNCTION=5;
public static final int TERM=6;
public static final int PHRASE=7;
public static final int DEFAULT=8;
public static final int EXCLUDE=9;
public static final int MINUS=10;
public static final int FTSWORD=11;
public static final int FTSPHRASE=12;
public static final int OR=13;
public static final int F_ESC=14;
public static final int WS=15;
public static final int START_WORD=16;
public static final int IN_WORD=17;
List tokens = new ArrayList();
public void emit(Token token) {
state.token = token;
tokens.add(token);
}
public Token nextToken() {
nextTokenImpl();
if ( tokens.size()==0 ) {
return Token.EOF_TOKEN;
}
return (Token)tokens.remove(0);
}
public Token nextTokenImpl() {
while (true)
{
state.token = null;
state.channel = Token.DEFAULT_CHANNEL;
state.tokenStartCharIndex = input.index();
state.tokenStartCharPositionInLine = input.getCharPositionInLine();
state.tokenStartLine = input.getLine();
state.text = null;
if ( input.LA(1)==CharStream.EOF )
{
return Token.EOF_TOKEN;
}
try
{
mTokens();
if ( state.token==null )
{
emit();
}
else if ( state.token==Token.SKIP_TOKEN )
{
continue;
}
return state.token;
}
catch (RecognitionException re)
{
throw new CMISQueryException(getErrorString(re), re);
}
}
}
public String getErrorString(RecognitionException e)
{
String hdr = getErrorHeader(e);
String msg = getErrorMessage(e, this.getTokenNames());
return hdr+" "+msg;
}
// delegates
// delegators
public CMIS_FTSLexer() {;}
public CMIS_FTSLexer(CharStream input) {
this(input, new RecognizerSharedState());
}
public CMIS_FTSLexer(CharStream input, RecognizerSharedState state) {
super(input,state);
}
public String getGrammarFileName() { return "W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g"; }
// $ANTLR start "FTSPHRASE"
public final void mFTSPHRASE() throws RecognitionException {
try {
int _type = FTSPHRASE;
int _channel = DEFAULT_TOKEN_CHANNEL;
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:346:9: ( '\\'' ( F_ESC | ~ ( '\\\\' | '\\'' ) )* '\\'' )
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:347:9: '\\'' ( F_ESC | ~ ( '\\\\' | '\\'' ) )* '\\''
{
match('\'');
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:348:9: ( F_ESC | ~ ( '\\\\' | '\\'' ) )*
loop1:
do {
int alt1=3;
int LA1_0 = input.LA(1);
if ( (LA1_0=='\\') ) {
alt1=1;
}
else if ( ((LA1_0>='\u0000' && LA1_0<='&')||(LA1_0>='(' && LA1_0<='[')||(LA1_0>=']' && LA1_0<='\uFFFF')) ) {
alt1=2;
}
switch (alt1) {
case 1 :
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:349:17: F_ESC
{
mF_ESC();
}
break;
case 2 :
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:351:17: ~ ( '\\\\' | '\\'' )
{
if ( (input.LA(1)>='\u0000' && input.LA(1)<='&')||(input.LA(1)>='(' && input.LA(1)<='[')||(input.LA(1)>=']' && input.LA(1)<='\uFFFF') ) {
input.consume();
}
else {
MismatchedSetException mse = new MismatchedSetException(null,input);
recover(mse);
throw mse;}
}
break;
default :
break loop1;
}
} while (true);
match('\'');
}
state.type = _type;
state.channel = _channel;
}
finally {
}
}
// $ANTLR end "FTSPHRASE"
// $ANTLR start "F_ESC"
public final void mF_ESC() throws RecognitionException {
try {
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:362:9: ( '\\\\' ( '\\\\' | '\\'' ) )
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:363:9: '\\\\' ( '\\\\' | '\\'' )
{
match('\\');
if ( input.LA(1)=='\''||input.LA(1)=='\\' ) {
input.consume();
}
else {
MismatchedSetException mse = new MismatchedSetException(null,input);
recover(mse);
throw mse;}
}
}
finally {
}
}
// $ANTLR end "F_ESC"
// $ANTLR start "OR"
public final void mOR() throws RecognitionException {
try {
int _type = OR;
int _channel = DEFAULT_TOKEN_CHANNEL;
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:372:9: ( ( 'O' | 'o' ) ( 'R' | 'r' ) )
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:373:9: ( 'O' | 'o' ) ( 'R' | 'r' )
{
if ( input.LA(1)=='O'||input.LA(1)=='o' ) {
input.consume();
}
else {
MismatchedSetException mse = new MismatchedSetException(null,input);
recover(mse);
throw mse;}
if ( input.LA(1)=='R'||input.LA(1)=='r' ) {
input.consume();
}
else {
MismatchedSetException mse = new MismatchedSetException(null,input);
recover(mse);
throw mse;}
}
state.type = _type;
state.channel = _channel;
}
finally {
}
}
// $ANTLR end "OR"
// $ANTLR start "MINUS"
public final void mMINUS() throws RecognitionException {
try {
int _type = MINUS;
int _channel = DEFAULT_TOKEN_CHANNEL;
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:384:9: ( '-' )
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:385:9: '-'
{
match('-');
}
state.type = _type;
state.channel = _channel;
}
finally {
}
}
// $ANTLR end "MINUS"
// $ANTLR start "WS"
public final void mWS() throws RecognitionException {
try {
int _type = WS;
int _channel = DEFAULT_TOKEN_CHANNEL;
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:395:9: ( ( ' ' | '\\t' | '\\r' | '\\n' )+ )
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:396:9: ( ' ' | '\\t' | '\\r' | '\\n' )+
{
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:396:9: ( ' ' | '\\t' | '\\r' | '\\n' )+
int cnt2=0;
loop2:
do {
int alt2=2;
int LA2_0 = input.LA(1);
if ( ((LA2_0>='\t' && LA2_0<='\n')||LA2_0=='\r'||LA2_0==' ') ) {
alt2=1;
}
switch (alt2) {
case 1 :
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:
{
if ( (input.LA(1)>='\t' && input.LA(1)<='\n')||input.LA(1)=='\r'||input.LA(1)==' ' ) {
input.consume();
}
else {
MismatchedSetException mse = new MismatchedSetException(null,input);
recover(mse);
throw mse;}
}
break;
default :
if ( cnt2 >= 1 ) break loop2;
EarlyExitException eee =
new EarlyExitException(2, input);
throw eee;
}
cnt2++;
} while (true);
_channel = HIDDEN;
}
state.type = _type;
state.channel = _channel;
}
finally {
}
}
// $ANTLR end "WS"
// $ANTLR start "FTSWORD"
public final void mFTSWORD() throws RecognitionException {
try {
int _type = FTSWORD;
int _channel = DEFAULT_TOKEN_CHANNEL;
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:407:9: ( START_WORD ( IN_WORD )* )
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:408:9: START_WORD ( IN_WORD )*
{
mSTART_WORD();
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:408:20: ( IN_WORD )*
loop3:
do {
int alt3=2;
int LA3_0 = input.LA(1);
if ( ((LA3_0>='\u0000' && LA3_0<='\b')||(LA3_0>='\u000B' && LA3_0<='\f')||(LA3_0>='\u000E' && LA3_0<='\u001F')||(LA3_0>='!' && LA3_0<='\uFFFF')) ) {
alt3=1;
}
switch (alt3) {
case 1 :
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:408:20: IN_WORD
{
mIN_WORD();
}
break;
default :
break loop3;
}
} while (true);
}
state.type = _type;
state.channel = _channel;
}
finally {
}
}
// $ANTLR end "FTSWORD"
// $ANTLR start "START_WORD"
public final void mSTART_WORD() throws RecognitionException {
try {
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:413:9: (~ ( ' ' | '\\t' | '\\r' | '\\n' | '-' ) )
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:414:9: ~ ( ' ' | '\\t' | '\\r' | '\\n' | '-' )
{
if ( (input.LA(1)>='\u0000' && input.LA(1)<='\b')||(input.LA(1)>='\u000B' && input.LA(1)<='\f')||(input.LA(1)>='\u000E' && input.LA(1)<='\u001F')||(input.LA(1)>='!' && input.LA(1)<=',')||(input.LA(1)>='.' && input.LA(1)<='\uFFFF') ) {
input.consume();
}
else {
MismatchedSetException mse = new MismatchedSetException(null,input);
recover(mse);
throw mse;}
}
}
finally {
}
}
// $ANTLR end "START_WORD"
// $ANTLR start "IN_WORD"
public final void mIN_WORD() throws RecognitionException {
try {
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:425:9: (~ ( ' ' | '\\t' | '\\r' | '\\n' ) )
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:426:9: ~ ( ' ' | '\\t' | '\\r' | '\\n' )
{
if ( (input.LA(1)>='\u0000' && input.LA(1)<='\b')||(input.LA(1)>='\u000B' && input.LA(1)<='\f')||(input.LA(1)>='\u000E' && input.LA(1)<='\u001F')||(input.LA(1)>='!' && input.LA(1)<='\uFFFF') ) {
input.consume();
}
else {
MismatchedSetException mse = new MismatchedSetException(null,input);
recover(mse);
throw mse;}
}
}
finally {
}
}
// $ANTLR end "IN_WORD"
public void mTokens() throws RecognitionException {
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:1:8: ( FTSPHRASE | OR | MINUS | WS | FTSWORD )
int alt4=5;
alt4 = dfa4.predict(input);
switch (alt4) {
case 1 :
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:1:10: FTSPHRASE
{
mFTSPHRASE();
}
break;
case 2 :
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:1:20: OR
{
mOR();
}
break;
case 3 :
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:1:23: MINUS
{
mMINUS();
}
break;
case 4 :
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:1:29: WS
{
mWS();
}
break;
case 5 :
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:1:32: FTSWORD
{
mFTSWORD();
}
break;
}
}
protected DFA4 dfa4 = new DFA4(this);
static final String DFA4_eotS =
"\1\uffff\2\11\3\uffff\2\11\1\16\2\uffff\1\17\1\uffff\1\11\2\uffff";
static final String DFA4_eofS =
"\20\uffff";
static final String DFA4_minS =
"\3\0\3\uffff\3\0\2\uffff\1\0\1\uffff\1\0\2\uffff";
static final String DFA4_maxS =
"\3\uffff\3\uffff\3\uffff\2\uffff\1\uffff\1\uffff\1\uffff\2\uffff";
static final String DFA4_acceptS =
"\3\uffff\1\3\1\4\1\5\3\uffff\1\5\1\1\1\uffff\1\5\1\uffff\1\1\1"+
"\2";
static final String DFA4_specialS =
"\1\6\1\5\1\4\3\uffff\1\1\1\0\1\7\2\uffff\1\2\1\uffff\1\3\2\uffff}>";
static final String[] DFA4_transitionS = {
"\11\5\2\4\2\5\1\4\22\5\1\4\6\5\1\1\5\5\1\3\41\5\1\2\37\5\1"+
"\2\uff90\5",
"\11\7\2\12\2\7\1\12\22\7\1\12\6\7\1\10\64\7\1\6\uffa3\7",
"\11\14\2\uffff\2\14\1\uffff\22\14\1\uffff\61\14\1\13\37\14"+
"\1\13\uff8d\14",
"",
"",
"",
"\11\14\2\uffff\2\14\1\uffff\22\14\1\uffff\6\14\1\15\64\14"+
"\1\15\uffa3\14",
"\11\7\2\12\2\7\1\12\22\7\1\12\6\7\1\10\64\7\1\6\uffa3\7",
"\11\14\2\uffff\2\14\1\uffff\22\14\1\uffff\uffdf\14",
"",
"",
"\11\14\2\uffff\2\14\1\uffff\22\14\1\uffff\uffdf\14",
"",
"\11\7\2\12\2\7\1\12\22\7\1\12\6\7\1\10\64\7\1\6\uffa3\7",
"",
""
};
static final short[] DFA4_eot = DFA.unpackEncodedString(DFA4_eotS);
static final short[] DFA4_eof = DFA.unpackEncodedString(DFA4_eofS);
static final char[] DFA4_min = DFA.unpackEncodedStringToUnsignedChars(DFA4_minS);
static final char[] DFA4_max = DFA.unpackEncodedStringToUnsignedChars(DFA4_maxS);
static final short[] DFA4_accept = DFA.unpackEncodedString(DFA4_acceptS);
static final short[] DFA4_special = DFA.unpackEncodedString(DFA4_specialS);
static final short[][] DFA4_transition;
static {
int numStates = DFA4_transitionS.length;
DFA4_transition = new short[numStates][];
for (int i=0; i<numStates; i++) {
DFA4_transition[i] = DFA.unpackEncodedString(DFA4_transitionS[i]);
}
}
class DFA4 extends DFA {
public DFA4(BaseRecognizer recognizer) {
this.recognizer = recognizer;
this.decisionNumber = 4;
this.eot = DFA4_eot;
this.eof = DFA4_eof;
this.min = DFA4_min;
this.max = DFA4_max;
this.accept = DFA4_accept;
this.special = DFA4_special;
this.transition = DFA4_transition;
}
public String getDescription() {
return "1:1: Tokens : ( FTSPHRASE | OR | MINUS | WS | FTSWORD );";
}
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
IntStream input = _input;
int _s = s;
switch ( s ) {
case 0 :
int LA4_7 = input.LA(1);
s = -1;
if ( (LA4_7=='\'') ) {s = 8;}
else if ( (LA4_7=='\\') ) {s = 6;}
else if ( ((LA4_7>='\u0000' && LA4_7<='\b')||(LA4_7>='\u000B' && LA4_7<='\f')||(LA4_7>='\u000E' && LA4_7<='\u001F')||(LA4_7>='!' && LA4_7<='&')||(LA4_7>='(' && LA4_7<='[')||(LA4_7>=']' && LA4_7<='\uFFFF')) ) {s = 7;}
else if ( ((LA4_7>='\t' && LA4_7<='\n')||LA4_7=='\r'||LA4_7==' ') ) {s = 10;}
else s = 9;
if ( s>=0 ) return s;
break;
case 1 :
int LA4_6 = input.LA(1);
s = -1;
if ( (LA4_6=='\''||LA4_6=='\\') ) {s = 13;}
else if ( ((LA4_6>='\u0000' && LA4_6<='\b')||(LA4_6>='\u000B' && LA4_6<='\f')||(LA4_6>='\u000E' && LA4_6<='\u001F')||(LA4_6>='!' && LA4_6<='&')||(LA4_6>='(' && LA4_6<='[')||(LA4_6>=']' && LA4_6<='\uFFFF')) ) {s = 12;}
else s = 9;
if ( s>=0 ) return s;
break;
case 2 :
int LA4_11 = input.LA(1);
s = -1;
if ( ((LA4_11>='\u0000' && LA4_11<='\b')||(LA4_11>='\u000B' && LA4_11<='\f')||(LA4_11>='\u000E' && LA4_11<='\u001F')||(LA4_11>='!' && LA4_11<='\uFFFF')) ) {s = 12;}
else s = 15;
if ( s>=0 ) return s;
break;
case 3 :
int LA4_13 = input.LA(1);
s = -1;
if ( (LA4_13=='\'') ) {s = 8;}
else if ( (LA4_13=='\\') ) {s = 6;}
else if ( ((LA4_13>='\u0000' && LA4_13<='\b')||(LA4_13>='\u000B' && LA4_13<='\f')||(LA4_13>='\u000E' && LA4_13<='\u001F')||(LA4_13>='!' && LA4_13<='&')||(LA4_13>='(' && LA4_13<='[')||(LA4_13>=']' && LA4_13<='\uFFFF')) ) {s = 7;}
else if ( ((LA4_13>='\t' && LA4_13<='\n')||LA4_13=='\r'||LA4_13==' ') ) {s = 10;}
else s = 9;
if ( s>=0 ) return s;
break;
case 4 :
int LA4_2 = input.LA(1);
s = -1;
if ( (LA4_2=='R'||LA4_2=='r') ) {s = 11;}
else if ( ((LA4_2>='\u0000' && LA4_2<='\b')||(LA4_2>='\u000B' && LA4_2<='\f')||(LA4_2>='\u000E' && LA4_2<='\u001F')||(LA4_2>='!' && LA4_2<='Q')||(LA4_2>='S' && LA4_2<='q')||(LA4_2>='s' && LA4_2<='\uFFFF')) ) {s = 12;}
else s = 9;
if ( s>=0 ) return s;
break;
case 5 :
int LA4_1 = input.LA(1);
s = -1;
if ( (LA4_1=='\\') ) {s = 6;}
else if ( ((LA4_1>='\u0000' && LA4_1<='\b')||(LA4_1>='\u000B' && LA4_1<='\f')||(LA4_1>='\u000E' && LA4_1<='\u001F')||(LA4_1>='!' && LA4_1<='&')||(LA4_1>='(' && LA4_1<='[')||(LA4_1>=']' && LA4_1<='\uFFFF')) ) {s = 7;}
else if ( (LA4_1=='\'') ) {s = 8;}
else if ( ((LA4_1>='\t' && LA4_1<='\n')||LA4_1=='\r'||LA4_1==' ') ) {s = 10;}
else s = 9;
if ( s>=0 ) return s;
break;
case 6 :
int LA4_0 = input.LA(1);
s = -1;
if ( (LA4_0=='\'') ) {s = 1;}
else if ( (LA4_0=='O'||LA4_0=='o') ) {s = 2;}
else if ( (LA4_0=='-') ) {s = 3;}
else if ( ((LA4_0>='\t' && LA4_0<='\n')||LA4_0=='\r'||LA4_0==' ') ) {s = 4;}
else if ( ((LA4_0>='\u0000' && LA4_0<='\b')||(LA4_0>='\u000B' && LA4_0<='\f')||(LA4_0>='\u000E' && LA4_0<='\u001F')||(LA4_0>='!' && LA4_0<='&')||(LA4_0>='(' && LA4_0<=',')||(LA4_0>='.' && LA4_0<='N')||(LA4_0>='P' && LA4_0<='n')||(LA4_0>='p' && LA4_0<='\uFFFF')) ) {s = 5;}
if ( s>=0 ) return s;
break;
case 7 :
int LA4_8 = input.LA(1);
s = -1;
if ( ((LA4_8>='\u0000' && LA4_8<='\b')||(LA4_8>='\u000B' && LA4_8<='\f')||(LA4_8>='\u000E' && LA4_8<='\u001F')||(LA4_8>='!' && LA4_8<='\uFFFF')) ) {s = 12;}
else s = 14;
if ( s>=0 ) return s;
break;
}
NoViableAltException nvae =
new NoViableAltException(getDescription(), 4, _s, input);
error(nvae);
throw nvae;
}
}
}

View File

@@ -1,962 +0,0 @@
// $ANTLR 3.3 Nov 30, 2010 12:50:56 W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g 2011-04-26 17:09:23
package org.alfresco.repo.search.impl.parsers;
import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;
import org.antlr.runtime.tree.*;
public class CMIS_FTSParser extends Parser {
public static final String[] tokenNames = new String[] {
"<invalid>", "<EOR>", "<DOWN>", "<UP>", "DISJUNCTION", "CONJUNCTION", "TERM", "PHRASE", "DEFAULT", "EXCLUDE", "MINUS", "FTSWORD", "FTSPHRASE", "OR", "F_ESC", "WS", "START_WORD", "IN_WORD"
};
public static final int EOF=-1;
public static final int DISJUNCTION=4;
public static final int CONJUNCTION=5;
public static final int TERM=6;
public static final int PHRASE=7;
public static final int DEFAULT=8;
public static final int EXCLUDE=9;
public static final int MINUS=10;
public static final int FTSWORD=11;
public static final int FTSPHRASE=12;
public static final int OR=13;
public static final int F_ESC=14;
public static final int WS=15;
public static final int START_WORD=16;
public static final int IN_WORD=17;
// delegates
// delegators
public CMIS_FTSParser(TokenStream input) {
this(input, new RecognizerSharedState());
}
public CMIS_FTSParser(TokenStream input, RecognizerSharedState state) {
super(input, state);
}
protected TreeAdaptor adaptor = new CommonTreeAdaptor();
public void setTreeAdaptor(TreeAdaptor adaptor) {
this.adaptor = adaptor;
}
public TreeAdaptor getTreeAdaptor() {
return adaptor;
}
public String[] getTokenNames() { return CMIS_FTSParser.tokenNames; }
public String getGrammarFileName() { return "W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g"; }
private Stack<String> paraphrases = new Stack<String>();
protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) throws RecognitionException
{
throw new MismatchedTokenException(ttype, input);
}
public Object recoverFromMismatchedSet(IntStream input, RecognitionException e, BitSet follow) throws RecognitionException
{
throw e;
}
public String getErrorMessage(RecognitionException e, String[] tokenNames)
{
List stack = getRuleInvocationStack(e, this.getClass().getName());
String msg = e.getMessage();
if ( e instanceof UnwantedTokenException )
{
UnwantedTokenException ute = (UnwantedTokenException)e;
String tokenName="<unknown>";
if ( ute.expecting== Token.EOF )
{
tokenName = "EOF";
}
else
{
tokenName = tokenNames[ute.expecting];
}
msg = "extraneous input " + getTokenErrorDisplay(ute.getUnexpectedToken())
+ " expecting "+tokenName;
}
else if ( e instanceof MissingTokenException )
{
MissingTokenException mte = (MissingTokenException)e;
String tokenName="<unknown>";
if ( mte.expecting== Token.EOF )
{
tokenName = "EOF";
}
else
{
tokenName = tokenNames[mte.expecting];
}
msg = "missing " + tokenName+" at " + getTokenErrorDisplay(e.token)
+ " (" + getLongTokenErrorDisplay(e.token) +")";
}
else if ( e instanceof MismatchedTokenException )
{
MismatchedTokenException mte = (MismatchedTokenException)e;
String tokenName="<unknown>";
if ( mte.expecting== Token.EOF )
{
tokenName = "EOF";
}
else
{
tokenName = tokenNames[mte.expecting];
}
msg = "mismatched input " + getTokenErrorDisplay(e.token)
+ " expecting " + tokenName +" (" + getLongTokenErrorDisplay(e.token) + ")";
}
else if ( e instanceof MismatchedTreeNodeException )
{
MismatchedTreeNodeException mtne = (MismatchedTreeNodeException)e;
String tokenName="<unknown>";
if ( mtne.expecting==Token.EOF )
{
tokenName = "EOF";
}
else
{
tokenName = tokenNames[mtne.expecting];
}
msg = "mismatched tree node: " + mtne.node + " expecting " + tokenName;
}
else if ( e instanceof NoViableAltException )
{
NoViableAltException nvae = (NoViableAltException)e;
msg = "no viable alternative at input " + getTokenErrorDisplay(e.token)
+ "\n\t (decision=" + nvae.decisionNumber
+ " state " + nvae.stateNumber + ")"
+ " decision=<<" + nvae.grammarDecisionDescription + ">>";
}
else if ( e instanceof EarlyExitException )
{
//EarlyExitException eee = (EarlyExitException)e;
// for development, can add "(decision="+eee.decisionNumber+")"
msg = "required (...)+ loop did not match anything at input " + getTokenErrorDisplay(e.token);
}
else if ( e instanceof MismatchedSetException )
{
MismatchedSetException mse = (MismatchedSetException)e;
msg = "mismatched input " + getTokenErrorDisplay(e.token)
+ " expecting set " + mse.expecting;
}
else if ( e instanceof MismatchedNotSetException )
{
MismatchedNotSetException mse = (MismatchedNotSetException)e;
msg = "mismatched input " + getTokenErrorDisplay(e.token)
+ " expecting set " + mse.expecting;
}
else if ( e instanceof FailedPredicateException )
{
FailedPredicateException fpe = (FailedPredicateException)e;
msg = "rule " + fpe.ruleName + " failed predicate: {" + fpe.predicateText + "}?";
}
if(paraphrases.size() > 0)
{
String paraphrase = (String)paraphrases.peek();
msg = msg+" "+paraphrase;
}
return msg +"\n\t"+stack;
}
public String getLongTokenErrorDisplay(Token t)
{
return t.toString();
}
public String getErrorString(RecognitionException e)
{
String hdr = getErrorHeader(e);
String msg = getErrorMessage(e, this.getTokenNames());
return hdr+" "+msg;
}
public static class cmisFtsQuery_return extends ParserRuleReturnScope {
Object tree;
public Object getTree() { return tree; }
};
// $ANTLR start "cmisFtsQuery"
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:278:1: cmisFtsQuery : ftsCmisDisjunction EOF -> ftsCmisDisjunction ;
public final CMIS_FTSParser.cmisFtsQuery_return cmisFtsQuery() throws RecognitionException {
CMIS_FTSParser.cmisFtsQuery_return retval = new CMIS_FTSParser.cmisFtsQuery_return();
retval.start = input.LT(1);
Object root_0 = null;
Token EOF2=null;
CMIS_FTSParser.ftsCmisDisjunction_return ftsCmisDisjunction1 = null;
Object EOF2_tree=null;
RewriteRuleTokenStream stream_EOF=new RewriteRuleTokenStream(adaptor,"token EOF");
RewriteRuleSubtreeStream stream_ftsCmisDisjunction=new RewriteRuleSubtreeStream(adaptor,"rule ftsCmisDisjunction");
try {
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:279:9: ( ftsCmisDisjunction EOF -> ftsCmisDisjunction )
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:280:9: ftsCmisDisjunction EOF
{
pushFollow(FOLLOW_ftsCmisDisjunction_in_cmisFtsQuery194);
ftsCmisDisjunction1=ftsCmisDisjunction();
state._fsp--;
stream_ftsCmisDisjunction.add(ftsCmisDisjunction1.getTree());
EOF2=(Token)match(input,EOF,FOLLOW_EOF_in_cmisFtsQuery196);
stream_EOF.add(EOF2);
// AST REWRITE
// elements: ftsCmisDisjunction
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
root_0 = (Object)adaptor.nil();
// 281:17: -> ftsCmisDisjunction
{
adaptor.addChild(root_0, stream_ftsCmisDisjunction.nextTree());
}
retval.tree = root_0;
}
retval.stop = input.LT(-1);
retval.tree = (Object)adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
catch(RecognitionException e)
{
throw e;
}
finally {
}
return retval;
}
// $ANTLR end "cmisFtsQuery"
public static class ftsCmisDisjunction_return extends ParserRuleReturnScope {
Object tree;
public Object getTree() { return tree; }
};
// $ANTLR start "ftsCmisDisjunction"
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:289:1: ftsCmisDisjunction : ftsCmisConjunction ( or ftsCmisConjunction )* -> ^( DISJUNCTION ( ftsCmisConjunction )+ ) ;
public final CMIS_FTSParser.ftsCmisDisjunction_return ftsCmisDisjunction() throws RecognitionException {
CMIS_FTSParser.ftsCmisDisjunction_return retval = new CMIS_FTSParser.ftsCmisDisjunction_return();
retval.start = input.LT(1);
Object root_0 = null;
CMIS_FTSParser.ftsCmisConjunction_return ftsCmisConjunction3 = null;
CMIS_FTSParser.or_return or4 = null;
CMIS_FTSParser.ftsCmisConjunction_return ftsCmisConjunction5 = null;
RewriteRuleSubtreeStream stream_ftsCmisConjunction=new RewriteRuleSubtreeStream(adaptor,"rule ftsCmisConjunction");
RewriteRuleSubtreeStream stream_or=new RewriteRuleSubtreeStream(adaptor,"rule or");
try {
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:290:9: ( ftsCmisConjunction ( or ftsCmisConjunction )* -> ^( DISJUNCTION ( ftsCmisConjunction )+ ) )
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:291:9: ftsCmisConjunction ( or ftsCmisConjunction )*
{
pushFollow(FOLLOW_ftsCmisConjunction_in_ftsCmisDisjunction252);
ftsCmisConjunction3=ftsCmisConjunction();
state._fsp--;
stream_ftsCmisConjunction.add(ftsCmisConjunction3.getTree());
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:291:28: ( or ftsCmisConjunction )*
loop1:
do {
int alt1=2;
int LA1_0 = input.LA(1);
if ( (LA1_0==OR) ) {
alt1=1;
}
switch (alt1) {
case 1 :
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:291:29: or ftsCmisConjunction
{
pushFollow(FOLLOW_or_in_ftsCmisDisjunction255);
or4=or();
state._fsp--;
stream_or.add(or4.getTree());
pushFollow(FOLLOW_ftsCmisConjunction_in_ftsCmisDisjunction257);
ftsCmisConjunction5=ftsCmisConjunction();
state._fsp--;
stream_ftsCmisConjunction.add(ftsCmisConjunction5.getTree());
}
break;
default :
break loop1;
}
} while (true);
// AST REWRITE
// elements: ftsCmisConjunction
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
root_0 = (Object)adaptor.nil();
// 292:17: -> ^( DISJUNCTION ( ftsCmisConjunction )+ )
{
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:293:25: ^( DISJUNCTION ( ftsCmisConjunction )+ )
{
Object root_1 = (Object)adaptor.nil();
root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(DISJUNCTION, "DISJUNCTION"), root_1);
if ( !(stream_ftsCmisConjunction.hasNext()) ) {
throw new RewriteEarlyExitException();
}
while ( stream_ftsCmisConjunction.hasNext() ) {
adaptor.addChild(root_1, stream_ftsCmisConjunction.nextTree());
}
stream_ftsCmisConjunction.reset();
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
retval.stop = input.LT(-1);
retval.tree = (Object)adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
catch(RecognitionException e)
{
throw e;
}
finally {
}
return retval;
}
// $ANTLR end "ftsCmisDisjunction"
public static class ftsCmisConjunction_return extends ParserRuleReturnScope {
Object tree;
public Object getTree() { return tree; }
};
// $ANTLR start "ftsCmisConjunction"
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:296:1: ftsCmisConjunction : ( ftsCmisPrefixed )+ -> ^( CONJUNCTION ( ftsCmisPrefixed )+ ) ;
public final CMIS_FTSParser.ftsCmisConjunction_return ftsCmisConjunction() throws RecognitionException {
CMIS_FTSParser.ftsCmisConjunction_return retval = new CMIS_FTSParser.ftsCmisConjunction_return();
retval.start = input.LT(1);
Object root_0 = null;
CMIS_FTSParser.ftsCmisPrefixed_return ftsCmisPrefixed6 = null;
RewriteRuleSubtreeStream stream_ftsCmisPrefixed=new RewriteRuleSubtreeStream(adaptor,"rule ftsCmisPrefixed");
try {
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:297:9: ( ( ftsCmisPrefixed )+ -> ^( CONJUNCTION ( ftsCmisPrefixed )+ ) )
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:298:9: ( ftsCmisPrefixed )+
{
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:298:9: ( ftsCmisPrefixed )+
int cnt2=0;
loop2:
do {
int alt2=2;
int LA2_0 = input.LA(1);
if ( ((LA2_0>=MINUS && LA2_0<=FTSPHRASE)) ) {
alt2=1;
}
switch (alt2) {
case 1 :
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:298:9: ftsCmisPrefixed
{
pushFollow(FOLLOW_ftsCmisPrefixed_in_ftsCmisConjunction341);
ftsCmisPrefixed6=ftsCmisPrefixed();
state._fsp--;
stream_ftsCmisPrefixed.add(ftsCmisPrefixed6.getTree());
}
break;
default :
if ( cnt2 >= 1 ) break loop2;
EarlyExitException eee =
new EarlyExitException(2, input);
throw eee;
}
cnt2++;
} while (true);
// AST REWRITE
// elements: ftsCmisPrefixed
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
root_0 = (Object)adaptor.nil();
// 299:17: -> ^( CONJUNCTION ( ftsCmisPrefixed )+ )
{
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:300:25: ^( CONJUNCTION ( ftsCmisPrefixed )+ )
{
Object root_1 = (Object)adaptor.nil();
root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(CONJUNCTION, "CONJUNCTION"), root_1);
if ( !(stream_ftsCmisPrefixed.hasNext()) ) {
throw new RewriteEarlyExitException();
}
while ( stream_ftsCmisPrefixed.hasNext() ) {
adaptor.addChild(root_1, stream_ftsCmisPrefixed.nextTree());
}
stream_ftsCmisPrefixed.reset();
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
retval.stop = input.LT(-1);
retval.tree = (Object)adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
catch(RecognitionException e)
{
throw e;
}
finally {
}
return retval;
}
// $ANTLR end "ftsCmisConjunction"
public static class ftsCmisPrefixed_return extends ParserRuleReturnScope {
Object tree;
public Object getTree() { return tree; }
};
// $ANTLR start "ftsCmisPrefixed"
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:303:1: ftsCmisPrefixed : ( cmisTest -> ^( DEFAULT cmisTest ) | MINUS cmisTest -> ^( EXCLUDE cmisTest ) );
public final CMIS_FTSParser.ftsCmisPrefixed_return ftsCmisPrefixed() throws RecognitionException {
CMIS_FTSParser.ftsCmisPrefixed_return retval = new CMIS_FTSParser.ftsCmisPrefixed_return();
retval.start = input.LT(1);
Object root_0 = null;
Token MINUS8=null;
CMIS_FTSParser.cmisTest_return cmisTest7 = null;
CMIS_FTSParser.cmisTest_return cmisTest9 = null;
Object MINUS8_tree=null;
RewriteRuleTokenStream stream_MINUS=new RewriteRuleTokenStream(adaptor,"token MINUS");
RewriteRuleSubtreeStream stream_cmisTest=new RewriteRuleSubtreeStream(adaptor,"rule cmisTest");
try {
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:304:9: ( cmisTest -> ^( DEFAULT cmisTest ) | MINUS cmisTest -> ^( EXCLUDE cmisTest ) )
int alt3=2;
int LA3_0 = input.LA(1);
if ( ((LA3_0>=FTSWORD && LA3_0<=FTSPHRASE)) ) {
alt3=1;
}
else if ( (LA3_0==MINUS) ) {
alt3=2;
}
else {
NoViableAltException nvae =
new NoViableAltException("", 3, 0, input);
throw nvae;
}
switch (alt3) {
case 1 :
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:305:9: cmisTest
{
pushFollow(FOLLOW_cmisTest_in_ftsCmisPrefixed424);
cmisTest7=cmisTest();
state._fsp--;
stream_cmisTest.add(cmisTest7.getTree());
// AST REWRITE
// elements: cmisTest
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
root_0 = (Object)adaptor.nil();
// 306:17: -> ^( DEFAULT cmisTest )
{
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:307:25: ^( DEFAULT cmisTest )
{
Object root_1 = (Object)adaptor.nil();
root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(DEFAULT, "DEFAULT"), root_1);
adaptor.addChild(root_1, stream_cmisTest.nextTree());
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
break;
case 2 :
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:308:11: MINUS cmisTest
{
MINUS8=(Token)match(input,MINUS,FOLLOW_MINUS_in_ftsCmisPrefixed484);
stream_MINUS.add(MINUS8);
pushFollow(FOLLOW_cmisTest_in_ftsCmisPrefixed486);
cmisTest9=cmisTest();
state._fsp--;
stream_cmisTest.add(cmisTest9.getTree());
// AST REWRITE
// elements: cmisTest
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
root_0 = (Object)adaptor.nil();
// 309:17: -> ^( EXCLUDE cmisTest )
{
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:310:25: ^( EXCLUDE cmisTest )
{
Object root_1 = (Object)adaptor.nil();
root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(EXCLUDE, "EXCLUDE"), root_1);
adaptor.addChild(root_1, stream_cmisTest.nextTree());
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
break;
}
retval.stop = input.LT(-1);
retval.tree = (Object)adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
catch(RecognitionException e)
{
throw e;
}
finally {
}
return retval;
}
// $ANTLR end "ftsCmisPrefixed"
public static class cmisTest_return extends ParserRuleReturnScope {
Object tree;
public Object getTree() { return tree; }
};
// $ANTLR start "cmisTest"
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:313:1: cmisTest : ( cmisTerm -> ^( TERM cmisTerm ) | cmisPhrase -> ^( PHRASE cmisPhrase ) );
public final CMIS_FTSParser.cmisTest_return cmisTest() throws RecognitionException {
CMIS_FTSParser.cmisTest_return retval = new CMIS_FTSParser.cmisTest_return();
retval.start = input.LT(1);
Object root_0 = null;
CMIS_FTSParser.cmisTerm_return cmisTerm10 = null;
CMIS_FTSParser.cmisPhrase_return cmisPhrase11 = null;
RewriteRuleSubtreeStream stream_cmisPhrase=new RewriteRuleSubtreeStream(adaptor,"rule cmisPhrase");
RewriteRuleSubtreeStream stream_cmisTerm=new RewriteRuleSubtreeStream(adaptor,"rule cmisTerm");
try {
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:314:9: ( cmisTerm -> ^( TERM cmisTerm ) | cmisPhrase -> ^( PHRASE cmisPhrase ) )
int alt4=2;
int LA4_0 = input.LA(1);
if ( (LA4_0==FTSWORD) ) {
alt4=1;
}
else if ( (LA4_0==FTSPHRASE) ) {
alt4=2;
}
else {
NoViableAltException nvae =
new NoViableAltException("", 4, 0, input);
throw nvae;
}
switch (alt4) {
case 1 :
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:315:9: cmisTerm
{
pushFollow(FOLLOW_cmisTerm_in_cmisTest567);
cmisTerm10=cmisTerm();
state._fsp--;
stream_cmisTerm.add(cmisTerm10.getTree());
// AST REWRITE
// elements: cmisTerm
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
root_0 = (Object)adaptor.nil();
// 316:17: -> ^( TERM cmisTerm )
{
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:317:25: ^( TERM cmisTerm )
{
Object root_1 = (Object)adaptor.nil();
root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(TERM, "TERM"), root_1);
adaptor.addChild(root_1, stream_cmisTerm.nextTree());
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
break;
case 2 :
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:318:11: cmisPhrase
{
pushFollow(FOLLOW_cmisPhrase_in_cmisTest627);
cmisPhrase11=cmisPhrase();
state._fsp--;
stream_cmisPhrase.add(cmisPhrase11.getTree());
// AST REWRITE
// elements: cmisPhrase
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
root_0 = (Object)adaptor.nil();
// 319:17: -> ^( PHRASE cmisPhrase )
{
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:320:25: ^( PHRASE cmisPhrase )
{
Object root_1 = (Object)adaptor.nil();
root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(PHRASE, "PHRASE"), root_1);
adaptor.addChild(root_1, stream_cmisPhrase.nextTree());
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
break;
}
retval.stop = input.LT(-1);
retval.tree = (Object)adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
catch(RecognitionException e)
{
throw e;
}
finally {
}
return retval;
}
// $ANTLR end "cmisTest"
public static class cmisTerm_return extends ParserRuleReturnScope {
Object tree;
public Object getTree() { return tree; }
};
// $ANTLR start "cmisTerm"
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:324:1: cmisTerm : FTSWORD -> FTSWORD ;
public final CMIS_FTSParser.cmisTerm_return cmisTerm() throws RecognitionException {
CMIS_FTSParser.cmisTerm_return retval = new CMIS_FTSParser.cmisTerm_return();
retval.start = input.LT(1);
Object root_0 = null;
Token FTSWORD12=null;
Object FTSWORD12_tree=null;
RewriteRuleTokenStream stream_FTSWORD=new RewriteRuleTokenStream(adaptor,"token FTSWORD");
try {
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:325:9: ( FTSWORD -> FTSWORD )
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:326:9: FTSWORD
{
FTSWORD12=(Token)match(input,FTSWORD,FOLLOW_FTSWORD_in_cmisTerm717);
stream_FTSWORD.add(FTSWORD12);
// AST REWRITE
// elements: FTSWORD
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
root_0 = (Object)adaptor.nil();
// 327:17: -> FTSWORD
{
adaptor.addChild(root_0, stream_FTSWORD.nextNode());
}
retval.tree = root_0;
}
retval.stop = input.LT(-1);
retval.tree = (Object)adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
catch(RecognitionException e)
{
throw e;
}
finally {
}
return retval;
}
// $ANTLR end "cmisTerm"
public static class cmisPhrase_return extends ParserRuleReturnScope {
Object tree;
public Object getTree() { return tree; }
};
// $ANTLR start "cmisPhrase"
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:330:1: cmisPhrase : FTSPHRASE -> FTSPHRASE ;
public final CMIS_FTSParser.cmisPhrase_return cmisPhrase() throws RecognitionException {
CMIS_FTSParser.cmisPhrase_return retval = new CMIS_FTSParser.cmisPhrase_return();
retval.start = input.LT(1);
Object root_0 = null;
Token FTSPHRASE13=null;
Object FTSPHRASE13_tree=null;
RewriteRuleTokenStream stream_FTSPHRASE=new RewriteRuleTokenStream(adaptor,"token FTSPHRASE");
try {
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:331:9: ( FTSPHRASE -> FTSPHRASE )
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:332:9: FTSPHRASE
{
FTSPHRASE13=(Token)match(input,FTSPHRASE,FOLLOW_FTSPHRASE_in_cmisPhrase770);
stream_FTSPHRASE.add(FTSPHRASE13);
// AST REWRITE
// elements: FTSPHRASE
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
root_0 = (Object)adaptor.nil();
// 333:17: -> FTSPHRASE
{
adaptor.addChild(root_0, stream_FTSPHRASE.nextNode());
}
retval.tree = root_0;
}
retval.stop = input.LT(-1);
retval.tree = (Object)adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
catch(RecognitionException e)
{
throw e;
}
finally {
}
return retval;
}
// $ANTLR end "cmisPhrase"
public static class or_return extends ParserRuleReturnScope {
Object tree;
public Object getTree() { return tree; }
};
// $ANTLR start "or"
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:336:1: or : OR ;
public final CMIS_FTSParser.or_return or() throws RecognitionException {
CMIS_FTSParser.or_return retval = new CMIS_FTSParser.or_return();
retval.start = input.LT(1);
Object root_0 = null;
Token OR14=null;
Object OR14_tree=null;
try {
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:337:9: ( OR )
// W:\\alfresco\\BRANCHES\\DEV\\SWIFT\\root\\projects\\repository\\source\\java\\org\\alfresco\\repo\\search\\impl\\parsers\\CMIS_FTS.g:338:9: OR
{
root_0 = (Object)adaptor.nil();
OR14=(Token)match(input,OR,FOLLOW_OR_in_or823);
OR14_tree = (Object)adaptor.create(OR14);
adaptor.addChild(root_0, OR14_tree);
}
retval.stop = input.LT(-1);
retval.tree = (Object)adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
}
catch(RecognitionException e)
{
throw e;
}
finally {
}
return retval;
}
// $ANTLR end "or"
// Delegated rules
public static final BitSet FOLLOW_ftsCmisDisjunction_in_cmisFtsQuery194 = new BitSet(new long[]{0x0000000000000000L});
public static final BitSet FOLLOW_EOF_in_cmisFtsQuery196 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_ftsCmisConjunction_in_ftsCmisDisjunction252 = new BitSet(new long[]{0x0000000000002002L});
public static final BitSet FOLLOW_or_in_ftsCmisDisjunction255 = new BitSet(new long[]{0x0000000000001C00L});
public static final BitSet FOLLOW_ftsCmisConjunction_in_ftsCmisDisjunction257 = new BitSet(new long[]{0x0000000000002002L});
public static final BitSet FOLLOW_ftsCmisPrefixed_in_ftsCmisConjunction341 = new BitSet(new long[]{0x0000000000001C02L});
public static final BitSet FOLLOW_cmisTest_in_ftsCmisPrefixed424 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_MINUS_in_ftsCmisPrefixed484 = new BitSet(new long[]{0x0000000000001800L});
public static final BitSet FOLLOW_cmisTest_in_ftsCmisPrefixed486 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_cmisTerm_in_cmisTest567 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_cmisPhrase_in_cmisTest627 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_FTSWORD_in_cmisTerm717 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_FTSPHRASE_in_cmisPhrase770 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_OR_in_or823 = new BitSet(new long[]{0x0000000000000002L});
}

View File

@@ -1,98 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.search.impl.parsers;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import junit.framework.TestCase;
import org.alfresco.repo.node.BaseNodeServiceTest;
import org.antlr.gunit.GrammarInfo;
import org.antlr.gunit.gUnitLexer;
import org.antlr.gunit.gUnitParser;
import org.antlr.runtime.ANTLRInputStream;
import org.antlr.runtime.CharStream;
import org.antlr.runtime.CommonToken;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;
import org.apache.tools.ant.filters.StringInputStream;
public class CMIS_FTSTest extends TestCase
{
public CMIS_FTSTest()
{
// TODO Auto-generated constructor stub
}
public CMIS_FTSTest(String name)
{
super(name);
// TODO Auto-generated constructor stub
}
@Override
protected void setUp() throws Exception
{
super.setUp();
}
public void testLexer() throws IOException, RecognitionException
{
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
InputStream modelStream = cl.getResourceAsStream("org/alfresco/repo/search/impl/parsers/cmis_fts_test.gunit");
CharStream input = new ANTLRInputStream(modelStream);
gUnitExecutor executer = new gUnitExecutor(parse(input), "FTS");
System.out.print(executer.execTest()); // unit test result
assertEquals("Failures ", 0, executer.failures.size());
assertEquals("Invalids ", 0, executer.invalids.size());
}
public void testLexerOutput() throws IOException
{
CharStream input = new ANTLRInputStream(new StringInputStream("~woof^2"));
FTSLexer lexer = new FTSLexer(input);
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
for(CommonToken token : (List<CommonToken>)tokenStream.getTokens())
{
System.out.println(token.toString());
}
}
private GrammarInfo parse(CharStream input) throws RecognitionException
{
gUnitLexer lexer = new gUnitLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
GrammarInfo grammarInfo = new GrammarInfo();
gUnitParser parser = new gUnitParser(tokens, grammarInfo);
parser.gUnitDef(); // parse gunit script and save elements to grammarInfo
return grammarInfo;
}
}

View File

@@ -1,83 +0,0 @@
/** CMIS FTS */
gunit CMIS_FTS;
@header{package org.alfresco.repo.search.impl.parsers;}
/** Parser */
ftsCmisDisjunction:
"term1 term2 OR term3 term4" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM term1)) (DEFAULT (TERM term2))) (CONJUNCTION (DEFAULT (TERM term3)) (DEFAULT (TERM term4))))"
"'phrase one' 'phrase two' OR 'phrase three'" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (PHRASE 'phrase one')) (DEFAULT (PHRASE 'phrase two'))) (CONJUNCTION (DEFAULT (PHRASE 'phrase three'))))"
"-term OR -'phrase one' term2 OR -term3 'phrase two' OR 'phrase three'" -> "(DISJUNCTION (CONJUNCTION (EXCLUDE (TERM term))) (CONJUNCTION (EXCLUDE (PHRASE 'phrase one')) (DEFAULT (TERM term2))) (CONJUNCTION (EXCLUDE (TERM term3)) (DEFAULT (PHRASE 'phrase two'))) (CONJUNCTION (DEFAULT (PHRASE 'phrase three'))))"
"-term-one" -> "(DISJUNCTION (CONJUNCTION (EXCLUDE (TERM term-one))))"
"'it\\'s'" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (PHRASE 'it\\'s'))))"
// Invalid phrases end up as terms
"'it\'s'" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM 'it's'))))"
"test" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM test))))"
"!test" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM !test))))"
"te!st" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM te!st))))"
"test!" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM test!))))"
"?test" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM ?test))))"
"te?st" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM te?st))))"
"test?" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM test?))))"
"*test" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM *test))))"
"te*st" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM te*st))))"
"test*" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM test*))))"
ftsCmisConjunction:
"term1 term2" -> "(CONJUNCTION (DEFAULT (TERM term1)) (DEFAULT (TERM term2)))"
"'phrase one' 'phrase two'" -> "(CONJUNCTION (DEFAULT (PHRASE 'phrase one')) (DEFAULT (PHRASE 'phrase two')))"
"-term -'phrase one' term2 -term3 'phrase two'" -> "(CONJUNCTION (EXCLUDE (TERM term)) (EXCLUDE (PHRASE 'phrase one')) (DEFAULT (TERM term2)) (EXCLUDE (TERM term3)) (DEFAULT (PHRASE 'phrase two')))"
ftsCmisPrefixed:
"term" -> "(DEFAULT (TERM term))"
"'phrase one'" -> "(DEFAULT (PHRASE 'phrase one'))"
"-term" -> "(EXCLUDE (TERM term))"
"-'phrase one'" -> "(EXCLUDE (PHRASE 'phrase one'))"
cmisTest:
"term" -> "(TERM term)"
"'phrase one'" -> "(PHRASE 'phrase one')"
cmisTerm:
"term" -> "term"
cmisPhrase:
"'phrase one'" -> "'phrase one'"
or:
"OR" -> "OR"
/** Lexer */
FTSPHRASE:
"''" OK
"'meep'" OK
"'it\\'s'" OK
"'it\\'" FAIL
"'it\\\\'" OK
"'OR'" OK
OR:
"OR" OK
"or" OK
"Or" OK
"oR" OK
MINUS:
"-" OK
WS:
" " OK
"\t" OK
"\r" OK
"\n" OK
FTSWORD:
"word" OK
"wo-rd" OK

View File

@@ -1,556 +0,0 @@
/** CMIS */
gunit CMIS;
@header{package org.alfresco.repo.search.impl.parsers;}
/** Parser */
query:
"SELECT * FROM cmis:document" OK
"SELECT * FROM cmis:document, cmis:folder" FAIL
"SELECT SCORE() FROM cmis:document" OK
"SELECT from FROM cmis:document" FAIL
"SELECT DOCUMENT.Name FROM cmis:document" OK
"SELECT cmis:name, cmis:typeId FROM cmis:document" OK
"SELECT document.* FROM cmis:document" OK
"SELECT cmis:name,, cmis:typeId FROM cmis:document" FAIL
"SELECT * FROM *" FAIL
"SELECT * from FOLDER JOIN RELATIONSHIP ON FOLDER.ID = RELATIONSHIP.ID" OK
"SELECT * from FOLDER F JOIN RELATIONSHIP RL ON F.ID = RL.ID" OK
"SELECT * from DOCUMENT D JOIN DOCUMENT DD ON (D.ID = DD.ID)" FAIL
"SELECT * from FOLDER F JOIN RELATIONSHIP RL ON F.ID = RL.ID" OK
"SELECT * from (FOLDER F JOIN RELATIONSHIP RL ON F.ID = RL.ID)" OK
"SELECT * from ((FOLDER F JOIN RELATIONSHIP RL ON F.ID = RL.ID))" OK
"SELECT * from (FOLDER)" FAIL
"SELECT * from cmis:folder F INNER JOIN cmis:relationship RL ON F.ID = RL.ID" OK
"SELECT * from cmis:folder F LEFT JOIN cmis:relationship RL ON F.ID = RL.ID" OK
"SELECT * from FOLDER F LEFT OUTER JOIN RELATIONSHIP RL ON F.ID = RL.ID" OK
"SELECT * from FOLDER F LEFT INNER JOIN RELATIONSHIP RL ON F.ID = RL.ID" FAIL
"SELECT * FROM cmis:document WHERE cmis:name='Test'" OK
"SELECT * FROM FOLDER WHERE COUNTER=7" OK
"SELECT * FROM FOLDER WHERE 7=COUNTER" FAIL
"SELECT * FROM FOLDER WHERE COUNTER IS NULL" OK
"SELECT * FROM FOLDER WHERE COUNTER IS NOT NULL" OK
"SELECT * FROM FOLDER WHERE COUNTER IS 5" FAIL
"SELECT * FROM FOLDER WHERE NAME LIKE '%te_t'" OK
"SELECT * FROM FOLDER WHERE COUNTER LIKE 5" FAIL
"SELECT * FROM FOLDER WHERE ANY NAME IN ('test', 'mail', 2)" OK
"SELECT * FROM FOLDER WHERE CONTAINS ('test -mail')" OK
"SELECT * FROM FOLDER WHERE IN_FOLDER('folderId')" OK
"SELECT * FROM FOLDER WHERE IN_TREE('folderId')" OK
"SELECT cmis:objectId FROM test:document where cmis:name='Test' AND counter>=22" OK
"SELECT cmis:objectId FROM test:document where (cmis:name='Test' AND counter<>22) OR CONTAINS('test')" OK
"SELECT cmis:objectId FROM test:document where ((cmis:name='Test' AND counter<=22) OR (CONTAINS('test') AND cmis:createdBy NOT LIKE 'J%')) AND (bill IS NULL)" OK
"SELECT * FROM cmis:document WHERE cmis:name='Test' ORDER BY cmis:name" OK
"SELECT * FROM cmis:document WHERE cmis:name='Test' ORDER BY cmis:name ASC, cmis:type DESC" OK
"SELECT * FROM cmis:document WHERE cmis:name='Test' ORDER BY first lines" FAIL
"SELECT Y.*, X.PROPERTY_ADDRESS FROM POLICY AS X JOIN CLAIMS AS Y ON X.POLICY_NUM = Y.POLICY_NUM WHERE ( ( Y.DAMAGE_ESTIMATES = 10000 OR cmis:createdBy NOT LIKE 'J%') AND (X.MAIN IS NULL) ) ORDER BY cmis:name ASC, cmis:type DESC" OK
"SELECT Name, Make FROM POLICY WHERE (MAKE = 'buick' ) OR ( ANY FEATURES IN ('NAVIGATION SYSTEM', 'SATELLITE RADIO', 'MP3') ) OR IN_FOLDER('folderId')" OK
"SELECT DOC.NAME, DOC.TYPE, P.Info, SCORE() FROM cmis:document AS DOC LEFT OUTER JOIN POLICY P ON P.DOC_ID = DOC.ID WHERE (DOC.NAME LIKE 'Test%' AND P.INFO <> 'dual' AND DOC.NUM >=44) OR CONTAINS('test') OR DOC.NAME IS NOT NULL ORDER BY cmis:name ASC" OK
"SELECT Name, SCORE() FROM POLICY JOIN DOCUMENT WHERE (MAKE = 'buick' ) OR (FEATURES IS ('NAVIGATION SYSTEM', 'MP3') )" FAIL
selectList:
"*" OK
//"column1" OK
//"column1, column2" OK
"column1, *" FAIL
"column1,, column2" FAIL
"X.column1, Y.column2" OK
"X.*" OK
"X.1, X.Y.Z" FAIL
"*" -> "ALL_COLUMNS"
"X.*" -> "(COLUMNS (ALL_COLUMNS X))"
//"column1, column2" -> "(COLUMNS (COLUMN (COLUMN_REF column1)) (COLUMN (COLUMN_REF column2)))"
"X.column1, Y.column2" -> "(COLUMNS (COLUMN (COLUMN_REF column1 X)) (COLUMN (COLUMN_REF column2 Y)))"
"SCORE()" -> (COLUMNS (COLUMN (FUNCTION SCORE ( ))))
//selectSubList:
//"column1" OK
//valueExpression:
//"column1" OK
columnReference:
"column1" OK
fromClause:
"FROM table1" OK
"FROM table1 T" OK
"FROM table1 AS T" OK
"FROM table1 JOIN table2 ON column1 = column2" OK
"FROM table1 JOIN table2" FAIL
"FROM table1 T1 JOIN table2 T2 ON T1.column1 = T2.column2" OK
"FROM table1 T1 LEFT JOIN table2 T2 ON T1.column1 = T2.column2" OK
"FROM table1 T1 LEFT INNER JOIN table2 T2 ON T1.column1 = T2.column2" FAIL
"FROM table1 T1 LEFT OUTER JOIN table2 T2 ON T1.column1 = T2.column2" OK
"FROM table1 T1 INNER JOIN table2 T2 ON T1.column1 = T2.column2" OK
"FROM table1 T1 LEFT OUTER JOIN table2 T2 ON T1.column1 = T2.column2 INNER JOIN table3 ON T2.column2 = table3.column2" OK
"FROM table1 T1 JOIN table2 T2 ON T1.column1 = T2.column1 JOIN table3 ON T2.column2 = table3.column2" OK
"FROM ((table1 T1 JOIN table2 T2 ON T1.column1 = T2.column1) LEFT JOIN table3 T3 ON T2.column1 = T3.column1)" OK
"FROM table1" -> "(SOURCE (TABLE_REF table1))"
"FROM table1 AS T" -> "(SOURCE (TABLE_REF table1 T))"
"FROM table1 JOIN table2 ON column1 = column2" -> "(SOURCE (TABLE_REF table1) (JOIN (SOURCE (TABLE_REF table2)) (ON (COLUMN_REF column1) = (COLUMN_REF column2))))"
"FROM table1 LEFT OUTER JOIN table2 ON column1 = column2" -> "(SOURCE (TABLE_REF table1) (JOIN (SOURCE (TABLE_REF table2)) LEFT (ON (COLUMN_REF column1) = (COLUMN_REF column2))))"
whereClause:
"WHERE column1 = 'value1'" OK
"WHERE 3.32 = ANY column1" OK
"WHERE column1 = value1" FAIL
"WHERE T.column1 = 'value1'" OK
"WHERE T.T.column1 = 'value1'" FAIL
"WHERE column1 = true" OK
"WHERE column1 = 3.32" OK
"WHERE column1 > 3.32" OK
"WHERE column1 >= 3.32" OK
"WHERE column1 => 3.32" FAIL
"WHERE column1 < 3.32" OK
"WHERE column1 <= 3.32" OK
"WHERE column1 =< 3.32" FAIL
"WHERE column1 <> 3.32" OK
"WHERE column1 >< 3.32" FAIL
"WHERE 2.22 < column1 < 3.32" FAIL
"WHERE CONTAINS('test string')" OK
"WHERE CONTAINS(22)" FAIL
"WHERE IN_FOLDER('folderId')" OK
"WHERE IN_TREE('folderId')" OK
"WHERE column1 IS NULL" OK
"WHERE column1 IS NOT NULL" OK
"WHERE column1 NOT IS NULL" FAIL
"WHERE column1 LIKE 'T%'" OK
"WHERE column1 NOT LIKE 'T%'" OK
"WHERE column1 LIKE 2%" FAIL
"WHERE column1 IN (1, 2, 3)" OK
"WHERE ANY column1 IN (1, 2, 3)" OK
"WHERE column1 NOT IN (1, 2, 3)" OK
"WHERE column1 IN ('A', 'B')" OK
"WHERE column1 IN (A, B)" FAIL
"WHERE column1 IN (True)" OK
"WHERE col1=1 AND col2=2" OK
"WHERE col1=1 OR col2=2" OK
"WHERE (col1=1 AND col2=2)" OK
"WHERE NOT (col1=1 AND col2=2)" OK
"WHERE ((col1=1 OR col2=2))" OK
"WHERE ((col1=1 OR col2=2)" FAIL
"WHERE (col1=1 AND col2=2) OR col2=3" OK
"WHERE col1=1 AND ((col2=2) OR col2=3)" OK
"WHERE (col1=1 AND (col2=2 OR col2=3)" FAIL
"WHERE NOT(col2=2) OR NOT(col2=3)" OK
"WHERE NOT(col2=2 OR col2=3)" OK
"WHERE NOT(col2=2 AND NOT(col3=3)) OR NOT(col1=1)" OK
"WHERE col4=4 AND NOT(col2=2 AND NOT(col3=3)) OR NOT(col1=1)" OK
"WHERE col4=4 AND (col2=2 NOT(col3=3)) OR NOT(col1=1)" FAIL
"WHERE (NOT(col2 < 2.25) OR NOT CONTAINS('text')) AND col3 LIKE 'T__T'" OK
"WHERE 2 = ANY col1 OR col2 IN (2.25, 3.25) OR ((col2 IS NOT NULL OR col3 LIKE 'T%') AND IN_TREE('folder_id'))" OK
"WHERE ((NOT (col2 IS NOT NULL) OR col3 LIKE 'T%') AND CONTAINS ('TEXT')) OR (col1 >='A' AND col2 IN (2.25, 3.25))" OK
"WHERE column1 = 'value1'" -> "(DISJUNCTION (CONJUNCTION (PRED_COMPARISON SINGLE_VALUED_PROPERTY (COLUMN_REF column1) = (STRING_LITERAL 'value1'))))"
"WHERE 'value1'= ANY column1" -> "(DISJUNCTION (CONJUNCTION (PRED_COMPARISON ANY (STRING_LITERAL 'value1') = (COLUMN_REF column1))))"
"WHERE column1 > 3.32" -> "(DISJUNCTION (CONJUNCTION (PRED_COMPARISON SINGLE_VALUED_PROPERTY (COLUMN_REF column1) > (NUMERIC_LITERAL 3.32))))"
"WHERE CONTAINS('test string')" -> "(DISJUNCTION (CONJUNCTION (PRED_FTS 'test string')))"
"WHERE IN_FOLDER('folderId')" -> "(DISJUNCTION (CONJUNCTION (PRED_CHILD (STRING_LITERAL 'folderId'))))"
"WHERE IN_TREE('folderId')" -> "(DISJUNCTION (CONJUNCTION (PRED_DESCENDANT (STRING_LITERAL 'folderId'))))"
"WHERE column1 IS NULL" -> "(DISJUNCTION (CONJUNCTION (PRED_EXISTS (COLUMN_REF column1) NOT)))"
"WHERE column1 LIKE 'T%'" -> "(DISJUNCTION (CONJUNCTION (PRED_LIKE (COLUMN_REF column1) (STRING_LITERAL 'T%'))))"
"WHERE column1 IN (1, 2)" -> "(DISJUNCTION (CONJUNCTION (PRED_IN SINGLE_VALUED_PROPERTY (COLUMN_REF column1) (LIST (NUMERIC_LITERAL 1) (NUMERIC_LITERAL 2)))))"
"WHERE NOT(col1=1)" -> "(DISJUNCTION (CONJUNCTION (NEGATION (DISJUNCTION (CONJUNCTION (PRED_COMPARISON SINGLE_VALUED_PROPERTY (COLUMN_REF col1) = (NUMERIC_LITERAL 1)))))))"
"WHERE col1=1 AND col2=2" -> "(DISJUNCTION (CONJUNCTION (PRED_COMPARISON SINGLE_VALUED_PROPERTY (COLUMN_REF col1) = (NUMERIC_LITERAL 1)) (PRED_COMPARISON SINGLE_VALUED_PROPERTY (COLUMN_REF col2) = (NUMERIC_LITERAL 2))))"
"WHERE col1=1 OR col2=2" -> "(DISJUNCTION (CONJUNCTION (PRED_COMPARISON SINGLE_VALUED_PROPERTY (COLUMN_REF col1) = (NUMERIC_LITERAL 1))) (CONJUNCTION (PRED_COMPARISON SINGLE_VALUED_PROPERTY (COLUMN_REF col2) = (NUMERIC_LITERAL 2))))"
orderByClause:
"ORDER BY column1" OK
"ORDER BY ASC" FAIL
"ORDER BY column1 ASC" OK
"ORDER BY column1 DESC" OK
"ORDER BY column1 value" FAIL
"ORDER BY column1, column2" OK
"ORDER BY column1, column2 ASC" OK
"ORDER BY column1 ASC, column2 DESC" OK
"ORDER BY column1" -> "(ORDER (SORT_SPECIFICATION (COLUMN_REF column1) ASC))"
"ORDER BY column1 ASC, column2 DESC" -> "(ORDER (SORT_SPECIFICATION (COLUMN_REF column1) ASC) (SORT_SPECIFICATION (COLUMN_REF column2) DESC))"
datetimeLiteral:
"TIMESTAMP '2009-12-09T13:22:15.250'" OK
"TIMESTAMP '2009-12-09T13:22:15.250Z'" OK
"TIMESTAMP '2009-12-09T13:22:15.250+02:30'" OK
"TIMESTAMP '2009-12-09T13:22:15.250-02:30'" OK
/* Should fail as " are not valid quotes in CMIS or SQL */
"TIMESTAMP \"2009-12-09T13:22:15.250-02:30\"" FAIL
/* Not checked at parse time */
"TIMESTAMP '2009-12-9T13:22:15.250+2:30'" OK
/* The date format is checked during query processing and not parsing */
"TIMESTAMP 'Thu Dec 10 16:19:53 EET 2009'" OK
textSearchExpression:
"'word1'" OK
"'word1 -word2'" OK
"'word1 -word2 word3'" OK
"'word1 -word2 OR word3'" OK
/** OR is not treated as a special keyword */
"'word1-word2 OR OR word3'" OK
/** Spec spcifies minimum */
"'word1-word2 \"word1 OR word3\"'" OK
"'word1 \"phrase_word1 phrase_word2\"'" OK
/** "'word1 'phrase_word1 phrase_word2''" FAIL this failsas invalid */
/** Lexer */
QUOTED_STRING:
"'test string'" OK
"test string" FAIL
"'string\\''" OK
"''test string'" FAIL
"'cmis:name:\\'Folder 9\\\\\\'\\''" OK
SELECT:
"SELECT" OK
"sElECt" OK
"SeLECT" OK
"seLEct" OK
"SELect" OK
"SElECt" OK
"seLect" OK
"sElEcT" OK
"select" OK
AS:
"AS" OK
"aS" OK
"As" OK
"as" OK
FROM:
"FROM" OK
"fRom" OK
"FROM" OK
"FroM" OK
"fROM" OK
"FRoM" OK
"from" OK
JOIN:
"JOIN" OK
"JOiN" OK
"join" OK
"JoIN" OK
"jOiN" OK
"Join" OK
"join" OK
INNER:
"INNER" OK
"innEr" OK
"iNNer" OK
"INnER" OK
"iNnEr" OK
"InNer" OK
"InneR" OK
"inner" OK
LEFT:
"LEFT" OK
"leFt" OK
"lEfT" OK
"LEft" OK
"lefT" OK
"Left" OK
"left" OK
OUTER:
"OUTER" OK
"oUtEr" OK
"OUTEr" OK
"outER" OK
"OUtEr" OK
"OutEr" OK
"oUTer" OK
"outer" OK
ON:
"ON" OK
"oN" OK
"On" OK
"on" OK
WHERE:
"WHERE" OK
"wheRe" OK
"WHere" OK
"WhERE" OK
"WHERe" OK
"WHErE" OK
"whEre" OK
"where" OK
OR:
"OR" OK
"oR" OK
"Or" OK
"or" OK
AND:
"AND" OK
"ANd" OK
"AnD" OK
"aNd" OK
"And" OK
"and" OK
NOT:
"NOT" OK
"NoT" OK
"nOT" OK
"Not" OK
"noT" OK
"not" OK
IN:
"IN" OK
"iN" OK
"In" OK
"in" OK
LIKE:
"LIKE" OK
"LIkE" OK
"lIke" OK
"lIKe" OK
"liKE" OK
"lIkE" OK
"like" OK
IS:
"IS" OK
"iS" OK
"Is" OK
"is" OK
NULL:
"NULL" OK
"nulL" OK
"NUll" OK
"NuLl" OK
"nULL" OK
"NULL" OK
"null" OK
ANY:
"ANY" OK
"aNy" OK
"AnY" OK
"aNY" OK
"Any" OK
"any" OK
CONTAINS:
"CONTAINS" OK
"ContAINS" OK
"coNtainS" OK
"coNTainS" OK
"cONTAiNS" OK
"ContAIns" OK
"ConTains" OK
"CONTaiNS" OK
"CONtaiNs" OK
"COnTAiNS" OK
"contains" OK
IN_FOLDER:
"IN_FOLDER" OK
"In_FoldeR" OK
"In_FoldEr" OK
"IN_fOlDeR" OK
"in_FOLdeR" OK
"iN_fOLder" OK
"IN_FOlder" OK
"iN_FOLdER" OK
"in_fOLdEr" OK
"iN_FOLDer" OK
"in_FOLdER" OK
"in_folder" OK
IN_TREE:
"IN_TREE" OK
"IN_TRee" OK
"In_tREE" OK
"IN_tRee" OK
"in_trEe" OK
"In_TReE" OK
"IN_TRee" OK
"In_tRee" OK
"iN_treE" OK
"in_tree" OK
ORDER:
"ORDER" OK
"Order" OK
"ORDeR" OK
"OrdeR" OK
"orDER" OK
"oRdEr" OK
"ORder" OK
"order" OK
BY:
"BY" OK
"bY" OK
"By" OK
"by" OK
ASC:
"ASC" OK
"asC" OK
"Asc" OK
"ASc" OK
"aSC" OK
"asc" OK
DESC:
"DESC" OK
"deSC" OK
"DEsC" OK
"dESc" OK
"DeSC" OK
"dESC" OK
"desc" OK
TIMESTAMP:
"TIMESTAMP" OK
"tiMEsTaMP" OK
"TImESTaMp" OK
"tImesTAMP" OK
"TImEstaMp" OK
"timesTAMp" OK
"TIMEsTaMP" OK
"tiMESTAMP" OK
"timeSTamp" OK
"tIMESTamp" OK
"tImEsTAmp" OK
"timestamp" OK
TRUE:
"TRUE" OK
"tRUE" OK
"True" OK
"TRUE" OK
"truE" OK
"tRUe" OK
"true" OK
FALSE:
"FALSE" OK
"fALsE" OK
"FAlSE" OK
"fAlSe" OK
"FalSe" OK
"fALSE" OK
"fALsE" OK
"false" OK
SCORE:
"SCORE" OK
"SCore" OK
"score" OK
"ScOrE" OK
"scOrE" OK
"sCore" OK
"SCoRe" OK
"score" OK
LPAREN:
"(" OK
RPAREN:
")" OK
STAR:
"*" OK
COMMA:
"," OK
DOTSTAR:
".*" OK
DOT:
"." OK
DOTDOT:
".." OK
EQUALS:
"=" OK
TILDA:
"~" OK
NOTEQUALS:
"<>" OK
GREATERTHAN:
">" OK
LESSTHAN:
"<" OK
GREATERTHANOREQUALS:
">=" OK
LESSTHANOREQUALS:
"<=" OK
COLON:
":" OK
DOUBLE_QUOTE:
"\"" OK
ID:
"test_id" OK
"" FAIL
"a" OK
"_" OK
"$" FAIL
"_$" OK
"#" FAIL
"_#" OK
"1" FAIL
"A1" OK
"abcABC_abcABC0123_:$#" OK
DECIMAL_INTEGER_LITERAL:
"0" OK
"-1" OK
"1" OK
"01" FAIL
"10" OK
"-10" OK
"+150" OK
FLOATING_POINT_LITERAL:
"0" FAIL
"1.." FAIL
"1." OK
"-1.0" OK
"1..0" FAIL
"1...." FAIL
"1.0.." FAIL
"-1.02" OK
"1e10" OK
"1.2e-12" OK
"0.9E-9" OK
"+123.123456" OK

View File

@@ -20,12 +20,12 @@ package org.alfresco.repo.security.permissions.impl;
import org.alfresco.repo.security.permissions.PermissionReference;
/**
* This class provides common support for hash code and equality.
*
* @author andyh
*/
@SuppressWarnings("serial")
public abstract class AbstractPermissionReference implements PermissionReference
{
private int hashcode = 0;

View File

@@ -31,9 +31,6 @@ import org.alfresco.service.namespace.QName;
*/
public final class SimplePermissionReference extends AbstractPermissionReference
{
/**
*
*/
private static final long serialVersionUID = 637302438293417818L;
private static ReadWriteLock lock = new ReentrantReadWriteLock();
@@ -43,8 +40,6 @@ public final class SimplePermissionReference extends AbstractPermissionReference
/**
* Factory method to create simple permission refrences
*
* @param qName
* @param name
* @return a simple permission reference
*/
public static SimplePermissionReference getPermissionReference(QName qName, String name)

View File

@@ -17,13 +17,14 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.node.locator;
package org.alfresco.repo.site;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.repo.model.Repository;
import org.alfresco.service.cmr.repository.NodeLocator;
import org.alfresco.repo.nodelocator.AbstractNodeLocator;
import org.alfresco.repo.nodelocator.NodeLocator;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.service.cmr.site.SiteService;
@@ -31,13 +32,13 @@ import org.alfresco.service.cmr.site.SiteService;
/**
* This {@link NodeLocator} identifies the site in which the source node resides and returns the Document Library container for that site.
* If no site can be found or the site does not have a Document Library then the Company Home is returned.
*
* @author Nick Smith
* @since 4.0
*
*/
public class DocLibNodeLocator extends AbstractNodeLocator
{
public static final String NAME = "DocumentLibraryNodeLocator";
public static final String NAME = "doclib";
private SiteService siteService;
private Repository repositoryHelper;
@@ -54,17 +55,17 @@ public class DocLibNodeLocator extends AbstractNodeLocator
public NodeRef getNode(NodeRef source, Map<String, Serializable> params)
{
NodeRef docLib = null;
if(source != null)
if (source != null)
{
SiteInfo siteInfo = siteService.getSite(source);
if(siteInfo != null)
if (siteInfo != null)
{
String siteName = siteInfo.getShortName();
String containerId = SiteService.DOCUMENT_LIBRARY;
docLib = siteService.getContainer(siteName, containerId);
}
}
if(docLib == null)
if (docLib == null)
{
docLib = repositoryHelper.getCompanyHome();
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.solr;
import java.util.List;
/**
* Interface for SOLR changeset objects.
*
* @author Derek Hulley
* @since 4.0
*/
public interface Acl
{
Long getId();
Long getAclChangeSetId();
List<AclEntry> getEntries();
}

View File

@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.domain.solr;
package org.alfresco.repo.solr;
/**
* Interface for SOLR changeset objects.
@@ -26,7 +26,7 @@ package org.alfresco.repo.domain.solr;
*/
public interface AclChangeSet
{
public Long getId();
public Long getCommitTimeMs();
public int getAclCount();
Long getId();
Long getCommitTimeMs();
int getAclCount();
}

View File

@@ -0,0 +1,177 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.solr;
import java.util.List;
import java.util.Set;
import org.alfresco.service.namespace.QName;
/**
* Stores ACL change set query parameters
*
* @author Derek Hulley
* @since 4.0
*/
public class AclChangeSetParameters
{
private List<Long> transactionIds;
private Long fromTxnId;
private Long toTxnId;
private Long fromNodeId;
private Long toNodeId;
// default is 'all' results
private int maxResults = 0;
private String storeProtocol;
private String storeIdentifier;
private Set<QName> includeNodeTypes;
private Set<QName> excludeNodeTypes;
private Set<QName> includeAspects;
private Set<QName> excludeAspects;
public int getMaxResults()
{
return maxResults;
}
public void setMaxResults(int maxResults)
{
this.maxResults = maxResults;
}
public boolean getStoreFilter()
{
return (storeProtocol != null || storeIdentifier != null);
}
public void setStoreProtocol(String storeProtocol)
{
this.storeProtocol = storeProtocol;
}
public String getStoreProtocol()
{
return storeProtocol;
}
public void setStoreIdentifier(String storeIdentifier)
{
this.storeIdentifier = storeIdentifier;
}
public String getStoreIdentifier()
{
return storeIdentifier;
}
public void setTransactionIds(List<Long> txnIds)
{
this.transactionIds = txnIds;
}
public List<Long> getTransactionIds()
{
return transactionIds;
}
public Long getFromTxnId()
{
return fromTxnId;
}
public void setFromTxnId(Long fromTxnId)
{
this.fromTxnId = fromTxnId;
}
public Long getToTxnId()
{
return toTxnId;
}
public void setToTxnId(Long toTxnId)
{
this.toTxnId = toTxnId;
}
public Long getFromNodeId()
{
return fromNodeId;
}
public void setFromNodeId(Long fromNodeId)
{
this.fromNodeId = fromNodeId;
}
public Long getToNodeId()
{
return toNodeId;
}
public void setToNodeId(Long toNodeId)
{
this.toNodeId = toNodeId;
}
public Set<QName> getIncludeNodeTypes()
{
return includeNodeTypes;
}
public Set<QName> getExcludeNodeTypes()
{
return excludeNodeTypes;
}
public Set<QName> getIncludeAspects()
{
return includeAspects;
}
public Set<QName> getExcludeAspects()
{
return excludeAspects;
}
public void setIncludeNodeTypes(Set<QName> includeNodeTypes)
{
this.includeNodeTypes = includeNodeTypes;
}
public void setExcludeNodeTypes(Set<QName> excludeNodeTypes)
{
this.excludeNodeTypes = excludeNodeTypes;
}
public void setIncludeAspects(Set<QName> includeAspects)
{
this.includeAspects = includeAspects;
}
public void setExcludeAspects(Set<QName> excludeAspects)
{
this.excludeAspects = excludeAspects;
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.solr;
/**
* Interface for ACL ChangeSet entry details i.e. carries information about <b>alf_access_control_entry</b>.
*
* @author Derek Hulley
* @since 4.0
*/
public interface AclEntry
{
Long getId();
Long getAclId();
Long getAclPermissionId();
String getAclAuthority();
}

View File

@@ -21,8 +21,6 @@ package org.alfresco.repo.solr;
import java.util.List;
import org.alfresco.repo.domain.node.Node;
import org.alfresco.repo.domain.solr.AclChangeSet;
import org.alfresco.repo.domain.solr.Transaction;
/**
* Interface for component to provide tracking data for SOLR.

View File

@@ -32,9 +32,7 @@ import org.alfresco.repo.domain.node.Node;
import org.alfresco.repo.domain.node.NodeDAO;
import org.alfresco.repo.domain.node.NodeDAO.ChildAssocRefQueryCallback;
import org.alfresco.repo.domain.qname.QNameDAO;
import org.alfresco.repo.domain.solr.AclChangeSet;
import org.alfresco.repo.domain.solr.SOLRDAO;
import org.alfresco.repo.domain.solr.Transaction;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.dictionary.AspectDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;

View File

@@ -30,12 +30,7 @@ import junit.framework.TestCase;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.domain.node.Node;
import org.alfresco.repo.domain.node.NodeDAO;
import org.alfresco.repo.domain.solr.Transaction;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.solr.MetaDataResultsFilter;
import org.alfresco.repo.solr.NodeMetaData;
import org.alfresco.repo.solr.NodeMetaDataParameters;
import org.alfresco.repo.solr.NodeParameters;
import org.alfresco.repo.solr.SOLRTrackingComponent.NodeMetaDataQueryCallback;
import org.alfresco.repo.solr.SOLRTrackingComponent.NodeQueryCallback;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
@@ -99,6 +94,12 @@ public class SOLRTrackingComponentTest extends TestCase
rootNodeRef = nodeService.getRootNode(storeRef);
}
public void testGetAclChangeSets_Simple()
{
List<AclChangeSet> cs = solrTrackingComponent.getAclChangeSets(null, null, 50);
assertTrue("Expected results to be limited in number", cs.size() <= 50);
}
public void testGetNodeMetaData()
{
long startTime = System.currentTimeMillis();
@@ -555,64 +556,6 @@ public class SOLRTrackingComponentTest extends TestCase
return true;
}
/* private boolean compareProperties(Map<QName, Serializable> properties1, Map<QName, Serializable> properties2)
{
boolean match = true;
if(properties1.size() != properties2.size())
{
match = false;
}
else
{
for(QName qname : properties1.keySet())
{
Serializable value1 = properties1.get(qname);
Serializable value2 = properties2.get(qname);
if(value1 instanceof MLText)
{
if(!(value2 instanceof MLText))
{
match = false;
break;
}
MLText ml1 = (MLText)value1;
MLText ml2 = (MLText)value2;
if(ml1.getDefaultValue().equals(ml2.getDefaultValue()))
{
match = false;
break;
}
}
else if(value1 instanceof ContentDataWithId)
{
if(!(value2 instanceof ContentDataWithId))
{
match = false;
break;
}
ContentDataWithId cd1 = (ContentDataWithId)value1;
ContentDataWithId cd2 = (ContentDataWithId)value2;
if(cd1.getDefaultValue().equals(ml2.getDefaultValue()))
{
match = false;
break;
}
}
else
{
if(!value1.equals(value2))
{
match = false;
break;
}
}
}
}
return match;
}*/
@Override
public boolean handleNodeMetaData(NodeMetaData nodeMetaData) {
actualNodeMetaDataCount++;

View File

@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.domain.solr;
package org.alfresco.repo.solr;
/**
* Interface for SOLR transaction objects.

View File

@@ -0,0 +1,51 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* @author Brian
*
*/
public abstract class BaseNodePublishStatus implements NodePublishStatus
{
private NodeRef nodeRef;
/* (non-Javadoc)
* @see org.alfresco.service.cmr.publishing.NodePublishStatus#getNodeRef()
*/
@Override
public NodeRef getNodeRef()
{
return nodeRef;
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.publishing.NodePublishStatus#getEnvironment()
*/
@Override
public Environment getEnvironment()
{
// TODO Auto-generated method stub
return null;
}
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.alfresco.service.cmr.repository.NodeRef;
public interface Environment
{
String getId();
PublishingQueue getPublishingQueue();
Map<NodeRef,NodePublishStatus> checkPublishStatus(Collection<NodeRef> nodes);
List<PublishingEvent> getPublishingEvents(PublishingEventFilter filter);
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing;
import java.util.Calendar;
/**
* @author Brian
*
*/
public interface MutablePublishingEvent extends PublishingEvent
{
void setScheduledTime(Calendar time);
void setComment(String comment);
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing;
import java.util.Collection;
import org.alfresco.service.cmr.repository.NodeRef;
public interface MutablePublishingPackage extends PublishingPackage
{
void addNodesToUnpublish(NodeRef... nodesToRemove);
void addNodesToUnpublish(Collection<NodeRef> nodesToRemove);
void addNodesToPublish(NodeRef... nodesToPublish);
void addNodesToPublish(Collection<NodeRef> nodesToPublish);
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* @author Brian
*
*/
public interface NodePublishStatus
{
enum Status {NOT_PUBLISHED, ON_QUEUE, PUBLISHED, PUBLISHED_AND_ON_QUEUE};
<T> T visit(NodePublishStatusVisitor<T> visitor);
NodeRef getNodeRef();
Status getStatus();
/**
* Obtain the environment related to this status
* @return
*/
Environment getEnvironment();
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing;
/**
* @author Brian
*
*/
public class NodePublishStatusNotPublished extends BaseNodePublishStatus
{
/* (non-Javadoc)
* @see org.alfresco.service.cmr.publishing.NodePublishStatus#visit(org.alfresco.service.cmr.publishing.NodePublishStatusVisitor)
*/
@Override
public <T> T visit(NodePublishStatusVisitor<T> visitor)
{
return visitor.accept(this);
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.publishing.NodePublishStatus#getStatus()
*/
@Override
public Status getStatus()
{
return Status.NOT_PUBLISHED;
}
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing;
/**
* @author Brian
*
*/
public class NodePublishStatusOnQueue extends BaseNodePublishStatus
{
/* (non-Javadoc)
* @see org.alfresco.service.cmr.publishing.NodePublishStatus#visit(org.alfresco.service.cmr.publishing.NodePublishStatusVisitor)
*/
@Override
public <T> T visit(NodePublishStatusVisitor<T> visitor)
{
return visitor.accept(this);
}
public PublishingEvent getQueuedPublishingEvent()
{
return null;
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.publishing.NodePublishStatus#getStatus()
*/
@Override
public Status getStatus()
{
return Status.ON_QUEUE;
}
}

View File

@@ -0,0 +1,56 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing;
/**
* @author Brian
*
*/
public class NodePublishStatusPublished extends BaseNodePublishStatus
{
/* (non-Javadoc)
* @see org.alfresco.service.cmr.publishing.NodePublishStatus#visit(org.alfresco.service.cmr.publishing.NodePublishStatusVisitor)
*/
@Override
public <T> T visit(NodePublishStatusVisitor<T> visitor)
{
return visitor.accept(this);
}
/**
* Retrieve the most recent publishing event that affected (created or updated) the node relevant to this status.
* @return
*/
public PublishingEvent getLatestPublishingEvent()
{
return null;
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.publishing.NodePublishStatus#getStatus()
*/
@Override
public Status getStatus()
{
return Status.PUBLISHED;
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing;
/**
* @author Brian
*
*/
public class NodePublishStatusPublishedAndOnQueue extends BaseNodePublishStatus
{
/* (non-Javadoc)
* @see org.alfresco.service.cmr.publishing.NodePublishStatus#visit(org.alfresco.service.cmr.publishing.NodePublishStatusVisitor)
*/
@Override
public <T> T visit(NodePublishStatusVisitor<T> visitor)
{
return visitor.accept(this);
}
public PublishingEvent getQueuedPublishingEvent()
{
return null;
}
/**
* Retrieve the most recent publishing event that affected (created or updated) the node relevant to this status.
* @return
*/
public PublishingEvent getLatestPublishingEvent()
{
return null;
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.publishing.NodePublishStatus#getStatus()
*/
@Override
public Status getStatus()
{
return Status.PUBLISHED_AND_ON_QUEUE;
}
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing;
/**
* @author Brian
*
*/
public interface NodePublishStatusVisitor<T>
{
T accept(NodePublishStatusNotPublished status);
T accept(NodePublishStatusOnQueue status);
T accept(NodePublishStatusPublished status);
T accept(NodePublishStatusPublishedAndOnQueue status);
}

View File

@@ -0,0 +1,69 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing;
import java.util.Calendar;
import java.util.Date;
import java.util.Set;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* @author Brian
*
*/
public interface PublishingEvent
{
enum Status {SCHEDULED, IN_PROGRESS, COMPLETE, FAILED}
String getId();
Status getStatus();
Calendar getScheduledTime();
PublishingPackage getPackage();
Date getCreatedTime();
String getCreator();
Date getModifiedTime();
String getModifier();
String getComment();
/**
* Retrieve those publishing events that depend on this one
* @return
*/
Set<PublishingEvent> getDependingEvents();
/**
* Retrieve those publishing events on which this one depends
* @return
*/
Set<PublishingEvent> getEventsDependedOn();
Set<NodeRef> getNodesDependedOn();
MutablePublishingEvent edit();
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing;
/**
* @author Brian
*
*/
public interface PublishingEventFilter
{
}

View File

@@ -0,0 +1,26 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing;
import java.util.Set;
public interface PublishingPackage
{
Set<PublishingPackageEntry> getEntries();
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.version.Version;
/**
* @author Brian
*
*/
public interface PublishingPackageEntry
{
NodeRef getNodeRef();
Version getVersion();
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing;
import java.util.Calendar;
public interface PublishingQueue
{
MutablePublishingPackage createPublishingPackage();
/**
* Adds the supplied publishing package onto the queue.
* @param publishingPackage The publishing package that is to be enqueued
* @param schedule The time at which the new publishing event should be scheduled (optional - <code>null</code> indicates "as soon as possible")
* @param comment A comment to be stored with this new event (optional - may be <code>null</code>)
* @return A PublishingEvent object representing the newly scheduled event
*/
PublishingEvent scheduleNewEvent(PublishingPackage publishingPackage, Calendar schedule, String comment);
void cancelEvent(String eventId);
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing;
import java.util.Set;
import org.alfresco.service.cmr.repository.NodeRef;
public interface PublishingService
{
Set<Environment> getEnvironments(String siteId);
Environment getEnvironment(String siteId, String environmentName);
Environment getEditorialEnvironment(String siteId);
Set<NodeRef> getPublishingDependencies(NodeRef node);
PublishingEvent getPublishingEvent(String id);
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing.channels;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* @author Brian
*
*/
public interface Channel
{
ChannelType getChannelType();
/**
* Retrieve the node ref of the node that represents this channel in the editorial environment
* @return
*/
NodeRef getNodeRef();
/**
* Retrieve the name of this channel
* @return
*/
String getName();
}

View File

@@ -0,0 +1,39 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing.channels;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.alfresco.service.namespace.QName;
/**
* @author Brian
*
*/
public interface ChannelService
{
void register(ChannelType channelType);
List<ChannelType> getChannelTypes();
Channel createChannel(String siteId, String channelTypeId, String name, Map<QName, Serializable> properties);
void deleteChannel(String siteId, String channelName);
List<Channel> getChannels(String siteId);
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.publishing.channels;
import java.util.Map;
import org.alfresco.service.namespace.QName;
/**
* @author Brian
*
*/
public interface ChannelType
{
String getId();
Map<String,String> getCapabilities();
QName getChannelNodeType();
QName getContentRootNodeType();
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.publishing;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
import java.util.List;
import javax.annotation.Resource;
import org.alfresco.service.cmr.publishing.channels.ChannelService;
import org.alfresco.service.cmr.publishing.channels.ChannelType;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Nick Smith
* @since 4.0
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:test/alfresco/test-web-publishing-context.xml"})
public class ChannelServiceImplTest
{
@Resource
ChannelService channelService;
@Resource
MockChannelType mockChannelType;
@Test
public void testRegister()
{
List<ChannelType> types = channelService.getChannelTypes();
// Check the mock channel type is registered through Spring.
assertTrue(types.contains(mockChannelType));
try
{
channelService.register(null);
fail("Exception expected when calling register(null)");
}
catch(IllegalArgumentException e)
{
//NOOP
}
try
{
channelService.register(mockChannelType);
fail("Exception expected when trying to register the same ChannelType twice");
}
catch(IllegalArgumentException e)
{
//NOOP
}
}
}

View File

@@ -0,0 +1,75 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco 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 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.publishing;
import java.util.Map;
import org.alfresco.service.namespace.QName;
/**
* @author Nick Smith
* @since 4.0
*
*/
public class MockChannelType extends AbstractChannelType
{
public final static String NAME = "MockChannelType";
public MockChannelType()
{
super();
}
/**
* {@inheritDoc}
*/
@Override
public String getId()
{
return NAME;
}
/**
* {@inheritDoc}
*/
@Override
public Map<String, String> getCapabilities()
{
return null;
}
/**
* {@inheritDoc}
*/
@Override
public QName getChannelNodeType()
{
return null;
}
/**
* {@inheritDoc}
*/
@Override
public QName getContentRootNodeType()
{
return null;
}
}