Merged V4.0-BUG-FIX to HEAD

36915: ALF-12874: Schema reference files are out of date
   - Difference: expected primary key .alf_tenant.PRIMARY.columnNames[0]="id", but was .alf_tenant.PRIMARY.columnNames[0]="tenant_domain"
   - fixed the rename of alf_tenant PK "id" -> "tenant_domain" (for all 5 DB types)
   36950: Merged V4.0 to V4.0-BUG-FIX (RECORD ONLY)
      36917: Merged V4.0-BUG-FIX to V4.0
         36915: ALF-12874: Schema reference files are out of date
         - Difference: expected primary key .alf_tenant.PRIMARY.columnNames[0]="id", but was .alf_tenant.PRIMARY.columnNames[0]="tenant_domain"
         - fixed the rename of alf_tenant PK "id" -> "tenant_domain" (for all 5 DB types)
   36951: Merged V4.0 (4.0.2) to V4.0-BUG-FIX (4.0.3)
      36949: ALF-13745: Merged V3.4-BUG-FIX (3.4.10) to V4.0 (4.0.2)
         36948: ALF-13667 Additional OpenOffice mimetypes to be added to the mime-type maps
            - On reflection the maxSourceSizeKBytes limits for power point files were too small. Did not take into account
              images in the files rather than just text.
      36923: Merged DEV to V4.0
         36600: ALF-14129 : Failed to do upgrade from 3.4.8 to 4.0.2
            Statements from ActivitiTaskIdIndexes.sql script were marked as optional.
      36922: Merged DEV to V4.0
         36729: ALF-14129 : Failed to do upgrade from 3.4.8 to 4.0.2
            Outdated Schema-Reference-ACT.xml were updated for all dialects and regression after ALF-12874 was fixed.
   36953: Merged BRANCHES/DEV/V3.4-BUG-FIX to BRANCHES/DEV/V4.0-BUG-FIX
      36905: ALF-14178 Share - Path issue with number of character limitation. Updated qname to max DB limit of 255 chars.
   36954: ALF-14209 SOLR - does not support query for all stores
   - it is now possible for SOLR to track any store and Alfresco to execute queries against that store (no federation or sharding yet ....)
   36965: Extra debugging after review of ALF-14238
   37032: ALF-12723: Missing mergeinfo for r34655
   37033: Merged V4.0 to V4.0-BUG-FIX
      36999: ALF-5285: Reverse merging r26226, as it causes regressions ALF-14202, ALF-14242 and ALF-14245
      37001: ALF-14169: Alfresco startup fails if XAM module was deployed
         Jan approved fix
      37005: ALF-14169: Fix unit test compilation
      37020: Resolved some "Patch description is not available" warnings in 4.0.2
      37022: ALF-12874: Schema reference files are out of date
      - Fixed up PostgreSQL diffs
      37027: ALF-12874: Schema reference files are out of date
      - DB2 fixes by Dmitry


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@37036 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2012-05-25 17:19:13 +00:00
parent 18ad785d32
commit ff2ae89c08
22 changed files with 366 additions and 130 deletions

View File

@@ -23,6 +23,8 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -35,6 +37,7 @@ import org.alfresco.repo.search.impl.lucene.LuceneQueryParserException;
import org.alfresco.repo.search.impl.lucene.SolrJSONResultSet;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.search.LimitBy;
import org.alfresco.service.cmr.search.ResultSet;
@@ -62,12 +65,15 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* @author Andy
*/
public class SolrQueryHTTPClient
public class SolrQueryHTTPClient implements BeanFactoryAware
{
static Log s_logger = LogFactory.getLog(SolrQueryHTTPClient.class);
@@ -79,15 +85,15 @@ public class SolrQueryHTTPClient
private Map<String, String> languageMappings;
private Map<String, String> storeMappings;
private List<SolrStoreMapping> storeMappings;
private String baseUrl;
private HttpClient httpClient;
private HashMap<StoreRef, HttpClient> httpClients = new HashMap<StoreRef, HttpClient>();
private HttpClientFactory httpClientFactory;
private HashMap<StoreRef, SolrStoreMapping> mappingLookup = new HashMap<StoreRef, SolrStoreMapping>();
private RepositoryState repositoryState;
private BeanFactory beanFactory;
public SolrQueryHTTPClient()
{
@@ -96,21 +102,23 @@ public class SolrQueryHTTPClient
public void init()
{
PropertyCheck.mandatory(this, "NodeService", nodeService);
PropertyCheck.mandatory(this, "PermissionService", nodeService);
PropertyCheck.mandatory(this, "TenantService", nodeService);
PropertyCheck.mandatory(this, "LanguageMappings", nodeService);
PropertyCheck.mandatory(this, "StoreMappings", nodeService);
PropertyCheck.mandatory(this, "HttpClientFactory", nodeService);
PropertyCheck.mandatory(this, "RepositoryState", nodeService);
StringBuilder sb = new StringBuilder();
sb.append("/solr");
this.baseUrl = sb.toString();
PropertyCheck.mandatory(this, "PermissionService", permissionService);
PropertyCheck.mandatory(this, "TenantService", tenantService);
PropertyCheck.mandatory(this, "LanguageMappings", languageMappings);
PropertyCheck.mandatory(this, "StoreMappings", storeMappings);
PropertyCheck.mandatory(this, "RepositoryState", repositoryState);
httpClient = httpClientFactory.getHttpClient();
HttpClientParams params = httpClient.getParams();
params.setBooleanParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, true);
httpClient.getState().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials("admin", "admin"));
for(SolrStoreMapping mapping : storeMappings)
{
mappingLookup.put(mapping.getStoreRef(), mapping);
HttpClientFactory httpClientFactory = (HttpClientFactory)beanFactory.getBean(mapping.getHttpClientFactory());
HttpClient httpClient = httpClientFactory.getHttpClient();
HttpClientParams params = httpClient.getParams();
params.setBooleanParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, true);
httpClient.getState().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials("admin", "admin"));
httpClients.put(mapping.getStoreRef(), httpClient);
}
}
/**
@@ -121,11 +129,6 @@ public class SolrQueryHTTPClient
this.repositoryState = repositoryState;
}
public void setHttpClientFactory(HttpClientFactory httpClientFactory)
{
this.httpClientFactory = httpClientFactory;
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
@@ -146,7 +149,7 @@ public class SolrQueryHTTPClient
this.languageMappings = languageMappings;
}
public void setStoreMappings(Map<String, String> storeMappings)
public void setStoreMappings(List storeMappings)
{
this.storeMappings = storeMappings;
}
@@ -160,19 +163,24 @@ public class SolrQueryHTTPClient
try
{
URLCodec encoder = new URLCodec();
StringBuilder url = new StringBuilder();
url.append(baseUrl);
if (searchParameters.getStores().size() == 0)
{
throw new AlfrescoRuntimeException("No store for query");
}
String storeUrlFragment = storeMappings.get(searchParameters.getStores().get(0).toString());
if (storeUrlFragment == null)
StoreRef store = searchParameters.getStores().get(0);
SolrStoreMapping mapping = mappingLookup.get(store);
if (mapping == null)
{
throw new AlfrescoRuntimeException("No solr query support for store " + searchParameters.getStores().get(0).toString());
}
url.append("/").append(storeUrlFragment);
URLCodec encoder = new URLCodec();
StringBuilder url = new StringBuilder();
url.append(mapping.getBaseUrl());
String languageUrlFragment = languageMappings.get(language);
if (languageUrlFragment == null)
{
@@ -341,6 +349,13 @@ public class SolrQueryHTTPClient
try
{
HttpClient httpClient = httpClients.get(store);
if(httpClient == null)
{
throw new AlfrescoRuntimeException("No http client for store " + searchParameters.getStores().get(0).toString());
}
httpClient.executeMethod(post);
if(post.getStatusCode() == HttpStatus.SC_MOVED_PERMANENTLY || post.getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY)
@@ -395,4 +410,13 @@ public class SolrQueryHTTPClient
}
}
/* (non-Javadoc)
* @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
*/
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException
{
this.beanFactory = beanFactory;
}
}

View File

@@ -0,0 +1,150 @@
/*
* 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.solr;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.util.PropertyCheck;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
/**
* @author Andy
*
*/
public class SolrStoreMapping implements BeanNameAware
{
StoreRef storeRef;
String httpClientFactory;
String baseUrl;
String protocol;
String identifier;
private String beanName;
public SolrStoreMapping()
{
}
public SolrStoreMapping(String protocol, String identifier, String httpClientFactory, String baseUrl)
{
this.protocol = protocol;
this.identifier = identifier;
this.httpClientFactory = httpClientFactory;
this.baseUrl = baseUrl;
}
/**
* @return the storeRef
*/
public StoreRef getStoreRef()
{
return storeRef;
}
/**
* @return the protocol
*/
public String getProtocol()
{
return protocol;
}
/**
* @param protocol the protocol to set
*/
public void setProtocol(String protocol)
{
this.protocol = protocol;
setStoreRef();
}
/**
* @return the identifier
*/
public String getIdentifier()
{
return identifier;
}
/**
* @param identifier the identifier to set
*/
public void setIdentifier(String identifier)
{
this.identifier = identifier;
setStoreRef();
}
/**
* @return the httpClientFactory
*/
public String getHttpClientFactory()
{
return httpClientFactory;
}
/**
* @param httpClientFactory the httpClientFactory to set
*/
public void setHttpClientFactory(String httpClientFactory)
{
this.httpClientFactory = httpClientFactory;
}
/**
* @return the baseUrl
*/
public String getBaseUrl()
{
return baseUrl;
}
/**
* @param baseUrl the baseUrl to set
*/
public void setBaseUrl(String baseUrl)
{
this.baseUrl = baseUrl;
}
/* (non-Javadoc)
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
*/
@Override
public void setBeanName(String beanName)
{
this.beanName = beanName;
}
private void setStoreRef()
{
if((protocol != null) && (identifier != null))
{
this.storeRef = new StoreRef(protocol, identifier);
}
}
}