Derek Hulley 5e86299377 Merged V3.2 to HEAD
17620: Merged DEV_TEMPORARY to V3.2
      17599: Fix for ETHREEOH-3308: xf:switch cannot be used in repeating field type
   17634: Put back AVM concurrency checks (reverse r17405)
   17644: Fixed up some comments and added return value to in-txn recording of deleted nodes
   17647: Fixed read-only detection of ContentStoreCleaner
   17648: Merged DEV fixes for ETHREEOH-3473 and ETHREEOH-3454 - DB script and iBatis-related changes
   17649: Fixed problem after merge-in: ETHREEOH-3641: build 270: cannot install on PostgreSQL
   17652: Fix ETHREEOH-3376 - Reindexer failure: requires rollback (Cluster)
   17658: Removed failing concurrency test for split person cleanup
   17659: Merged V3.1 to V3.2
      17308: Fixed ETHREEOH-2310: Upgrade from 2.1 E Sp7 to 3.1.1 E build 225 - Duplicate alf_node_status entries detected
             Fixes ETHREEOH-3606 (same as CHK-10454)
   17661: Fixed DB2 iBatis problems related to http://issues.apache.org/jira/browse/IBATIS-536
   17666: ETHREEOH-3376 / ETHREEOH-3637 - reindexer failure in a cluster (dictionary repo bootstrap)
   17678: Follow-on to r17666 (for RM custom model)
   17685: Merged DEV_TEMPORARY to V3.2
      17676: ETHREEOH-3187: Creating Web Content based on Web Form with most elements-read-only/default failed
   17695: Temporarily comment-out testSubmitChangedAssets1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /alfresco/BRANCHES/DEV/BELARUS/V3.2-2009_11_24:r17632,17636,17676
   Merged /alfresco/BRANCHES/DEV/BELARUS/V3.2-2009_11_09:r17599
   Merged /alfresco/BRANCHES/V3.1:r17308
   Merged /alfresco/BRANCHES/V3.2:r17620,17634,17644,17647-17649,17652,17658-17659,17661,17666,17678,17685,17695


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18165 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2010-01-20 11:30:46 +00:00

211 lines
6.1 KiB
Java
Executable File

/*
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.repo.dictionary;
import org.alfresco.repo.search.SearcherException;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.QName;
/**
* Repository location object, defines a location in the repository from which dictionary models/resources should be loaded
* for inclusion in the data dictionary.
*
*/
public class RepositoryLocation
{
/** Store protocol */
private String storeProtocol = StoreRef.PROTOCOL_WORKSPACE; // default
/** Store identifier */
private String storeId = "SpacesStore"; // default
/** Path */
private String path = ""; // default
/** Search Language */
private String queryLanguage = "xpath"; // default
public static final String LANGUAGE_PATH = "path"; // lookup directly using node (prefix qname) path
/**
*/
public RepositoryLocation()
{
}
/**
* Constructor
*
* @param storeRef the store reference (e.g. 'workspace://SpacesStore' )
* @param path the path (e.g. '/app:company_home/app:dictionary/app:models' )
* @param queryLanguage the query language (e.g. 'xpath' or 'lucence')
*/
public RepositoryLocation(StoreRef storeRef, String path, String queryLanguage)
{
this.storeProtocol = storeRef.getProtocol();
this.storeId = storeRef.getIdentifier();
this.path = path;
setQueryLanguage(queryLanguage);
}
/**
* Set the store protocol
*
* @param storeProtocol the store protocol
*/
public void setStoreProtocol(String storeProtocol)
{
this.storeProtocol = storeProtocol;
}
/**
* Set the store identifier
*
* @param storeId the store identifier
*/
public void setStoreId(String storeId)
{
this.storeId = storeId;
}
/**
* Set the path
*
* Example path: /app:company_home/app:dictionary/app:models
*
* @param path the path
*/
public void setPath(String path)
{
this.path = path;
}
/**
* Set the query language
*
* @param path the search language
*/
public void setQueryLanguage(String queryLanguage)
{
if (queryLanguage.equals(SearchService.LANGUAGE_LUCENE) || queryLanguage.equals(SearchService.LANGUAGE_XPATH) || queryLanguage.equals(LANGUAGE_PATH))
{
this.queryLanguage = queryLanguage;
}
else
{
throw new SearcherException("Unknown query language: " + queryLanguage);
}
}
/**
* Get the store reference
*
* @return the store reference
*/
public StoreRef getStoreRef()
{
return new StoreRef(this.storeProtocol, this.storeId);
}
/**
* Get the path
*
* @return the path
*/
public String getPath()
{
return this.path;
}
/**
* Get the query language
*
* @return the query language
*/
public String getQueryLanguage()
{
return this.queryLanguage;
}
/**
* Get the Lucene query statement for models, based on the path
*
* @return the Lucene query statement
*/
public String getLuceneQueryStatement(QName contentModelType)
{
String result = "+TYPE:\"" + contentModelType.toString() + "\"";
if ((this.path != null) && (! this.path.equals("")))
{
result += " +PATH:\"" + this.path + "\"";
}
return result;
}
/**
* Get the XPath query statement for models, based on the path
*
* @return the XPath query statement
*/
public String getXPathQueryStatement(QName prefixResolvedContentModelType)
{
String result = "/*[subtypeOf('" + prefixResolvedContentModelType.toPrefixString() + "')]"; // immediate children only
if ((this.path != null) && (! this.path.equals("")))
{
result = this.path + result;
}
return result;
}
public String[] getPathElements()
{
if ((this.path != null) && (! this.path.equals("")))
{
String pathToSplit = this.path;
while (pathToSplit.startsWith("/"))
{
pathToSplit = pathToSplit.substring(1);
}
while (pathToSplit.endsWith("/"))
{
pathToSplit = pathToSplit.substring(0, pathToSplit.length() - 1);
}
String[] pathElements = pathToSplit.split("/");
return pathElements;
}
else
{
return new String[0];
}
}
}