Author: piergiorgio
Date: Fri Jun 14 13:56:18 2013
New Revision: 1493075
URL: http://svn.apache.org/r1493075
Log:
- Alfresco connector now includes a better management of IOExceptions
(CONNECTORS-713)
- upgraded the Maven build with Java 7
- updated the Alfresco 4 WAR build with some new settings
Modified:
manifoldcf/trunk/CHANGES.txt
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/AlfrescoRepositoryConnector.java
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/ContentModelUtils.java
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/ContentReader.java
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/NodeUtils.java
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/PropertiesUtils.java
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/SearchUtils.java
manifoldcf/trunk/pom.xml
manifoldcf/trunk/test-materials/alfresco-4-war/src/main/properties/local/alfresco-global.properties
Modified: manifoldcf/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1493075&r1=1493074&r2=1493075&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Fri Jun 14 13:56:18 2013
@@ -3,6 +3,9 @@ $Id$
======================= 1.3-dev =====================
+CONNECTORS-713: Alfresco connector needs to deal with IOExceptions better
+(Piergiorgio Lucidi, Karl Wright)
+
CONNECTORS-623: Use UTF-8 for encoding headers in SolrJ post.
(Shinichiro Abe, Karl Wright)
Modified:
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/AlfrescoRepositoryConnector.java
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/AlfrescoRepositoryConnector.java?rev=1493075&r1=1493074&r2=1493075&view=diff
==============================================================================
---
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/AlfrescoRepositoryConnector.java
(original)
+++
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/AlfrescoRepositoryConnector.java
Fri Jun 14 13:56:18 2013
@@ -79,6 +79,9 @@ public class AlfrescoRepositoryConnector
/** Endpoint context path of the Alfresco webapp */
protected String path = null;
+ /** Endpoint with all the details */
+ protected String endpoint = null;
+
/** Alfresco Tenant domain */
protected String tenantDomain = null;
@@ -164,7 +167,12 @@ public class AlfrescoRepositoryConnector
@Override
public void disconnect() throws ManifoldCFException {
if (session != null) {
- AuthenticationUtils.endSession();
+ try {
+ AuthenticationUtils.endSession();
+ } catch (Exception e) {
+ Logging.connectors.error("Alfresco: error disconnect:"+e.getMessage(),
e);
+ throw new ManifoldCFException("Alfresco: error
disconnect:"+e.getMessage(), e);
+ }
session = null;
lastSessionFetch = -1L;
}
@@ -175,6 +183,7 @@ public class AlfrescoRepositoryConnector
server = null;
port = null;
path = null;
+ endpoint = null;
tenantDomain = null;
}
@@ -195,6 +204,14 @@ public class AlfrescoRepositoryConnector
path = params.getParameter(AlfrescoConfig.PATH_PARAM);
tenantDomain = params.getParameter(AlfrescoConfig.TENANT_DOMAIN_PARAM);
+ //endpoint
+ if(StringUtils.isNotEmpty(protocol)
+ && StringUtils.isNotEmpty(server)
+ && StringUtils.isNotEmpty(port)
+ && StringUtils.isNotEmpty(path)){
+ endpoint = protocol+"://"+server+":"+port+path;
+ }
+
//tenant domain (optional parameter). Pattern: username@tenantDomain
if(StringUtils.isNotEmpty(tenantDomain)){
username += AlfrescoConfig.TENANT_DOMAIN_SEP + tenantDomain;
@@ -250,29 +267,31 @@ public class AlfrescoRepositoryConnector
throw new ManifoldCFException("Parameter " + AlfrescoConfig.PATH_PARAM
+ " required but not set");
-
- String endpoint = protocol+"://"+server+":"+port+path;
- WebServiceFactory.setEndpointAddress(endpoint);
+ endpoint = protocol+"://"+server+":"+port+path;
try {
+
+ WebServiceFactory.setEndpointAddress(endpoint);
+ WebServiceFactory.setTimeoutMilliseconds(120000);
AuthenticationUtils.startSession(username, password);
session = AuthenticationUtils.getAuthenticationDetails();
- } catch (AuthenticationFault e) {
- Logging.connectors.warn(
- "Alfresco: Error during authentication. Username: "+username + ",
endpoint: "+endpoint+". "
- + e.getMessage(), e);
- throw new ManifoldCFException("Alfresco: Error during authentication.
Username: "+username + ", endpoint: "+endpoint+". "
- + e.getMessage(), e);
- } catch (WebServiceException e){
- Logging.connectors.warn(
- "Alfresco: Error during trying to authenticate the user. Username:
"+username + ", endpoint: "+endpoint
- +". Please check the connector parameters. "
- + e.getMessage(), e);
- throw new ManifoldCFException("Alfresco: Error during trying to
authenticate the user. Username: "+username + ", endpoint: "+endpoint
- +". Please check the connector parameters. "
- + e.getMessage(), e);
- }
+
+ }catch (AuthenticationFault e) {
+ Logging.connectors.warn(
+ "Alfresco: Error during authentication. Username: "+username + ",
endpoint: "+endpoint+". "
+ + e.getMessage(), e);
+ handleIOException(e);
+ } catch (WebServiceException e){
+ Logging.connectors.warn(
+ "Alfresco: Error during trying to authenticate the user. Username:
"+username + ", endpoint: "+endpoint
+ +". Please check the connector parameters. "
+ + e.getMessage(), e);
+ throw new ManifoldCFException("Alfresco: Error during trying to
authenticate the user. Username: "+username + ", endpoint: "+endpoint
+ +". Please check the connector parameters. "
+ + e.getMessage(), e);
+ }
lastSessionFetch = System.currentTimeMillis();
+
}
}
@@ -285,7 +304,13 @@ public class AlfrescoRepositoryConnector
long currentTime = System.currentTimeMillis();
if (currentTime >= lastSessionFetch + timeToRelease) {
- AuthenticationUtils.endSession();
+ try {
+ AuthenticationUtils.endSession();
+ } catch (Exception e) {
+ Logging.connectors.error(
+ "Alfresco: Error during releasing the connection.");
+ throw new ManifoldCFException( "Alfresco: Error during releasing the
connection.");
+ }
session = null;
lastSessionFetch = -1L;
}
@@ -294,16 +319,22 @@ public class AlfrescoRepositoryConnector
protected void checkConnection() throws ManifoldCFException,
ServiceInterruption {
while (true) {
- getSession();
- String ticket = AuthenticationUtils.getTicket();
- if(StringUtils.isEmpty(ticket)){
- Logging.connectors.error(
- "Alfresco: Error during checking the connection.");
- throw new ManifoldCFException( "Alfresco: Error during checking the
connection.");
- }
- AuthenticationUtils.endSession();
- session=null;
- return;
+ try {
+ getSession();
+ String ticket = AuthenticationUtils.getTicket();
+ if(StringUtils.isEmpty(ticket)){
+ Logging.connectors.error(
+ "Alfresco: Error during checking the connection.");
+ throw new ManifoldCFException( "Alfresco: Error during checking
the connection.");
+ }
+ AuthenticationUtils.endSession();
+ } catch (Exception e) {
+ Logging.connectors.error(
+ "Alfresco: Error during checking the connection.");
+ throw new ManifoldCFException( "Alfresco: Error during checking the
connection.");
+ }
+ session=null;
+ return;
}
}
@@ -372,25 +403,30 @@ public class AlfrescoRepositoryConnector
}
i++;
}
-
- QueryResult queryResult = null;
- if (StringUtils.isEmpty(luceneQuery)) {
- // get documents from the root of the Alfresco Repository
- queryResult = SearchUtils.getChildrenFromCompanyHome(username, password,
session);
- } else {
- // execute a Lucene query against the repository
- queryResult = SearchUtils.luceneSearch(username, password, session,
luceneQuery);
- }
-
- if(queryResult!=null){
- ResultSet resultSet = queryResult.getResultSet();
- ResultSetRow[] resultSetRows = resultSet.getRows();
- for (ResultSetRow resultSetRow : resultSetRows) {
- NamedValue[] properties = resultSetRow.getColumns();
- String nodeReference = PropertiesUtils.getNodeReference(properties);
- activities.addSeedDocument(nodeReference);
- }
+
+ try{
+ QueryResult queryResult = null;
+ if (StringUtils.isEmpty(luceneQuery)) {
+ // get documents from the root of the Alfresco Repository
+ queryResult = SearchUtils.getChildrenFromCompanyHome(endpoint,
username, password, session);
+ } else {
+ // execute a Lucene query against the repository
+ queryResult = SearchUtils.luceneSearch(endpoint, username, password,
session, luceneQuery);
}
+
+ if(queryResult!=null){
+ ResultSet resultSet = queryResult.getResultSet();
+ ResultSetRow[] resultSetRows = resultSet.getRows();
+ for (ResultSetRow resultSetRow : resultSetRows) {
+ NamedValue[] properties = resultSetRow.getColumns();
+ String nodeReference =
PropertiesUtils.getNodeReference(properties);
+ activities.addSeedDocument(nodeReference);
+ }
+ }
+ } catch(IOException e){
+ Logging.connectors.warn("Alfresco: IOException: " + e.getMessage(), e);
+ handleIOException(e);
+ }
}
/** Get the maximum number of documents to amalgamate together into one
batch, for this connector.
@@ -460,7 +496,7 @@ public class AlfrescoRepositoryConnector
String tenantDomain =
parameters.getParameter(AlfrescoConfig.TENANT_DOMAIN_PARAM);
if (tenantDomain == null)
- tenantDomain = "";
+ tenantDomain = StringUtils.EMPTY;
paramMap.put(AlfrescoConfig.TENANT_DOMAIN_PARAM, tenantDomain);
}
@@ -782,7 +818,15 @@ public class AlfrescoRepositoryConnector
predicate.setNodes(new Reference[] { reference });
// getting properties
- Node resultNode = NodeUtils.get(username, password, session, predicate);
+ Node resultNode = null;
+ try {
+ resultNode = NodeUtils.get(endpoint, username, password, session,
predicate);
+ } catch (IOException e) {
+ Logging.connectors.warn(
+ "Alfresco: IOException closing file input stream: "
+ + e.getMessage(), e);
+ handleIOException(e);
+ }
String errorCode = "OK";
String errorDesc = StringUtils.EMPTY;
@@ -790,20 +834,29 @@ public class AlfrescoRepositoryConnector
NamedValue[] properties = resultNode.getProperties();
boolean isDocument = ContentModelUtils.isDocument(properties);
- boolean isFolder = ContentModelUtils.isFolder(username, password,
session, reference);
-
- //a generic node in Alfresco could have child-associations
- if (isFolder) {
- // ingest all the children of the folder
- QueryResult queryResult = SearchUtils.getChildren(username, password,
session, reference);
- ResultSet resultSet = queryResult.getResultSet();
- ResultSetRow[] resultSetRows = resultSet.getRows();
- for (ResultSetRow resultSetRow : resultSetRows) {
- NamedValue[] childProperties = resultSetRow.getColumns();
- String childNodeReference =
PropertiesUtils.getNodeReference(childProperties);
- activities.addDocumentReference(childNodeReference, nodeReference,
RELATIONSHIP_CHILD);
- }
- }
+ try{
+
+ boolean isFolder = ContentModelUtils.isFolder(endpoint, username,
password, session, reference);
+
+ //a generic node in Alfresco could have child-associations
+ if (isFolder) {
+ // ingest all the children of the folder
+ QueryResult queryResult = SearchUtils.getChildren(endpoint,
username, password, session, reference);
+ ResultSet resultSet = queryResult.getResultSet();
+ ResultSetRow[] resultSetRows = resultSet.getRows();
+ for (ResultSetRow resultSetRow : resultSetRows) {
+ NamedValue[] childProperties = resultSetRow.getColumns();
+ String childNodeReference =
PropertiesUtils.getNodeReference(childProperties);
+ activities.addDocumentReference(childNodeReference,
nodeReference, RELATIONSHIP_CHILD);
+ }
+ }
+
+ }catch(IOException e){
+ Logging.connectors.warn(
+ "Alfresco: IOException closing file input stream: "
+ + e.getMessage(), e);
+ handleIOException(e);
+ }
//a generic node in Alfresco could also have binaries content
if (isDocument) {
@@ -819,9 +872,9 @@ public class AlfrescoRepositoryConnector
// binaries ingestion - in Alfresco we could have more than one
binary for each node (custom content models)
for (NamedValue contentProperty : contentProperties) {
//we are ingesting all the binaries defined as d:content property
in the Alfresco content model
- Content binary = ContentReader.read(username, password, session,
predicate, contentProperty.getName());
+ Content binary = ContentReader.read(endpoint, username, password,
session, predicate, contentProperty.getName());
fileLength = binary.getLength();
- is = ContentReader.getBinary(binary, username, password, session);
+ is = ContentReader.getBinary(endpoint, binary, username, password,
session);
rd.setBinary(is, fileLength);
//id is the node reference only if the node has an unique content
stream
@@ -843,12 +896,19 @@ public class AlfrescoRepositoryConnector
activities.ingestDocument(id, version, documentURI, rd);
}
+ AuthenticationUtils.endSession();
+
} catch (ParseException e) {
errorCode = "IO ERROR";
errorDesc = e.getMessage();
Logging.connectors.warn(
"Alfresco: Error during the reading process of dates: "
+ e.getMessage(), e);
+ } catch (IOException e) {
+ Logging.connectors.warn(
+ "Alfresco: IOException: "
+ + e.getMessage(), e);
+ handleIOException(e);
} finally {
try {
if(is!=null){
@@ -865,9 +925,9 @@ public class AlfrescoRepositoryConnector
Logging.connectors.warn(
"Alfresco: IOException closing file input stream: "
+ e.getMessage(), e);
+ handleIOException(e);
}
-
- AuthenticationUtils.endSession();
+
session = null;
activities.recordActivity(new Long(startTime), ACTIVITY_READ,
@@ -909,7 +969,16 @@ public class AlfrescoRepositoryConnector
predicate.setStore(SearchUtils.STORE);
predicate.setNodes(new Reference[]{reference});
- Node node = NodeUtils.get(username, password, session, predicate);
+ Node node = null;
+ try {
+ node = NodeUtils.get(endpoint, username, password, session, predicate);
+ } catch (IOException e) {
+ Logging.connectors.warn(
+ "Alfresco: IOException closing file input stream: "
+ + e.getMessage(), e);
+ handleIOException(e);
+ }
+
if(node.getProperties()!=null){
NamedValue[] properties = node.getProperties();
boolean isDocument = ContentModelUtils.isDocument(properties);
@@ -930,5 +999,16 @@ public class AlfrescoRepositoryConnector
}
return rval;
}
+
+ private static void handleIOException(IOException e)
+ throws ManifoldCFException, ServiceInterruption {
+ if (!(e instanceof java.net.SocketTimeoutException) && (e instanceof
InterruptedIOException)) {
+ throw new ManifoldCFException("Interrupted: " + e.getMessage(), e,
+ ManifoldCFException.INTERRUPTED);
+ }
+ long currentTime = System.currentTimeMillis();
+ throw new ServiceInterruption("IO exception: "+e.getMessage(), e,
currentTime + 300000L,
+ currentTime + 3 * 60 * 60000L,-1,false);
+ }
}
Modified:
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/ContentModelUtils.java
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/ContentModelUtils.java?rev=1493075&r1=1493074&r2=1493075&view=diff
==============================================================================
---
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/ContentModelUtils.java
(original)
+++
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/ContentModelUtils.java
Fri Jun 14 13:56:18 2013
@@ -18,6 +18,7 @@
*/
package org.apache.manifoldcf.crawler.connectors.alfresco;
+import java.io.IOException;
import java.rmi.RemoteException;
import org.alfresco.webservice.repository.QueryResult;
@@ -54,37 +55,40 @@ public class ContentModelUtils {
* @param node
* @return TRUE if the reference contains a node that is an Alfresco space,
otherwise FALSE
*/
- public static boolean isFolder(String username, String password,
AuthenticationDetails session, Reference node){
+ public static boolean isFolder(String endpoint, String username, String
password, AuthenticationDetails session, Reference node) throws IOException {
QueryResult queryResult = null;
try {
+ WebServiceFactory.setEndpointAddress(endpoint);
+ WebServiceFactory.setTimeoutMilliseconds(120000);
AuthenticationUtils.startSession(username, password);
session = AuthenticationUtils.getAuthenticationDetails();
queryResult =
WebServiceFactory.getRepositoryService().queryChildren(node);
+ if(queryResult!=null){
+ ResultSet rs = queryResult.getResultSet();
+ if(rs!=null){
+ ResultSetRow[] rows = rs.getRows();
+ if(rows!=null){
+ if(rows.length>0){
+ return true;
+ }
+ }
+ }
+ }
+ AuthenticationUtils.endSession();
+ return false;
} catch (RepositoryFault e) {
Logging.connectors.warn(
"Alfresco: Repository Error during the queryChildren: "
+ e.getMessage(), e);
+ throw new IOException("Alfresco: Repository Error during the
queryChildren: "
+ + e.getMessage(), e);
} catch (RemoteException e) {
Logging.connectors.warn(
"Alfresco: Remote Error during the queryChildren: "
+ e.getMessage(), e);
+ throw e;
} finally {
- AuthenticationUtils.endSession();
session = null;
}
-
- if(queryResult!=null){
- ResultSet rs = queryResult.getResultSet();
- if(rs!=null){
- ResultSetRow[] rows = rs.getRows();
- if(rows!=null){
- if(rows.length>0){
- return true;
- }
- }
- }
- }
- return false;
}
-
-}
+}
\ No newline at end of file
Modified:
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/ContentReader.java
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/ContentReader.java?rev=1493075&r1=1493074&r2=1493075&view=diff
==============================================================================
---
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/ContentReader.java
(original)
+++
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/ContentReader.java
Fri Jun 14 13:56:18 2013
@@ -18,13 +18,13 @@
*/
package org.apache.manifoldcf.crawler.connectors.alfresco;
+import java.io.IOException;
import java.io.InputStream;
import java.rmi.RemoteException;
import org.alfresco.webservice.authentication.AuthenticationFault;
import org.alfresco.webservice.content.Content;
import org.alfresco.webservice.content.ContentFault;
-import org.alfresco.webservice.content.ContentServiceSoapBindingStub;
import org.alfresco.webservice.types.Predicate;
import org.alfresco.webservice.util.AuthenticationDetails;
import org.alfresco.webservice.util.AuthenticationUtils;
@@ -39,35 +39,42 @@ public class ContentReader {
* @param predicate
* @return an unique binary for content
*/
- public static Content read(String username, String password,
AuthenticationDetails session, Predicate predicate, String contentProperty) {
+ public static Content read(String endpoint, String username, String
password, AuthenticationDetails session, Predicate predicate, String
contentProperty) throws IOException {
Content[] resultBinary = null;
try {
+ WebServiceFactory.setEndpointAddress(endpoint);
+ WebServiceFactory.setTimeoutMilliseconds(120000);
AuthenticationUtils.startSession(username, password);
session = AuthenticationUtils.getAuthenticationDetails();
- ContentServiceSoapBindingStub contentService =
WebServiceFactory.getContentService();
- resultBinary = contentService.read(predicate, contentProperty);
+ resultBinary = WebServiceFactory.getContentService().read(predicate,
contentProperty);
+ AuthenticationUtils.endSession();
} catch (ContentFault e) {
Logging.connectors
.error(
"Alfresco: Content fault exception error during getting the
content binary in processDocuments. " +
"Node: "+predicate.getNodes()[0].getPath() + ". "
+ e.getMessage(), e);
+ throw new IOException("Alfresco: Content fault exception error during
getting the content binary in processDocuments. " +
+ "Node: "+predicate.getNodes()[0].getPath() + ". "
+ + e.getMessage(), e);
} catch (RemoteException e) {
Logging.connectors
.error(
"Alfresco: Remote exception error during getting the content
binary in processDocuments. " +
"Node: "+predicate.getNodes()[0].getPath() + ". "
+ e.getMessage(), e);
+ throw e;
} finally{
- AuthenticationUtils.endSession();
session = null;
}
return resultBinary[0];
}
- public static InputStream getBinary(Content binary, String username, String
password, AuthenticationDetails session){
+ public static InputStream getBinary(String endpoint, Content binary, String
username, String password, AuthenticationDetails session) throws IOException {
InputStream is = null;
- try {
+ try {
+ WebServiceFactory.setEndpointAddress(endpoint);
+ WebServiceFactory.setTimeoutMilliseconds(120000);
AuthenticationUtils.startSession(username, password);
session = AuthenticationUtils.getAuthenticationDetails();
is = ContentUtils.getContentAsInputStream(binary);
@@ -76,8 +83,9 @@ public class ContentReader {
.error(
"Alfresco: Error during getting the binary for the node:
"+binary.getNode().getPath()+"."
+ e.getMessage(), e);
+ throw e;
}
return is;
}
-}
+}
\ No newline at end of file
Modified:
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/NodeUtils.java
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/NodeUtils.java?rev=1493075&r1=1493074&r2=1493075&view=diff
==============================================================================
---
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/NodeUtils.java
(original)
+++
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/NodeUtils.java
Fri Jun 14 13:56:18 2013
@@ -18,6 +18,7 @@
*/
package org.apache.manifoldcf.crawler.connectors.alfresco;
+import java.io.IOException;
import java.rmi.RemoteException;
import org.alfresco.webservice.repository.RepositoryFault;
@@ -50,23 +51,28 @@ public class NodeUtils {
* @param predicate
* @return the Node object instance of the current content
*/
- public static Node get(String username, String password,
AuthenticationDetails session, Predicate predicate){
+ public static Node get(String endpoint, String username, String password,
AuthenticationDetails session, Predicate predicate) throws IOException {
Node[] resultNodes = null;
try {
+ WebServiceFactory.setEndpointAddress(endpoint);
+ WebServiceFactory.setTimeoutMilliseconds(120000);
AuthenticationUtils.startSession(username, password);
session = AuthenticationUtils.getAuthenticationDetails();
resultNodes = WebServiceFactory.getRepositoryService().get(predicate);
+ AuthenticationUtils.endSession();
} catch (RepositoryFault e) {
Logging.connectors.error(
"Alfresco: RepositoryFault during getting a node in
processDocuments. Node: "
+ predicate.getNodes()[0].getPath() + ". " + e.getMessage(), e);
+ throw new IOException("Alfresco: RepositoryFault during getting a node
in processDocuments. Node: "
+ + predicate.getNodes()[0].getPath() + ". " + e.getMessage(), e);
} catch (RemoteException e) {
Logging.connectors
.error(
"Alfresco: Remote exception error during getting a node in
processDocuments. Node: "
+ predicate.getNodes()[0].getPath() + ". " + e.getMessage(),
e);
+ throw e;
} finally {
- AuthenticationUtils.endSession();
session = null;
}
if(resultNodes!=null && resultNodes.length>0){
Modified:
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/PropertiesUtils.java
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/PropertiesUtils.java?rev=1493075&r1=1493074&r2=1493075&view=diff
==============================================================================
---
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/PropertiesUtils.java
(original)
+++
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/PropertiesUtils.java
Fri Jun 14 13:56:18 2013
@@ -37,8 +37,7 @@ import org.apache.manifoldcf.core.interf
*/
public class PropertiesUtils {
- private static final String PROP_CONTENT_PREFIX_1 = "contentUrl";
- private static final String PROP_CONTENT_PREFIX_2 = "ContentData";
+ private static final String PROP_CONTENT_PREFIX = "contentUrl";
private static final String PROP_CONTENT_SEP = "|";
private static final String PROP_MIMETYPE_SEP = "=";
@@ -60,27 +59,49 @@ public class PropertiesUtils {
public static void ingestProperties(RepositoryDocument rd, NamedValue[]
properties, List<NamedValue> contentProperties) throws ManifoldCFException,
ParseException{
for(NamedValue property : properties){
- if(property.getIsMultiValue()){
- String[] values = property.getValues();
- if(values!=null){
- for (String value : values) {
- rd.addField(property.getName(), value);
+ if(property!=null && StringUtils.isNotEmpty(property.getName())){
+ if(property.getIsMultiValue()){
+ String[] values = property.getValues();
+ if(values!=null){
+ for (String value : values) {
+ if(StringUtils.isNotEmpty(value)){
+ rd.addField(property.getName(), value);
+ }
+ }
+ }
+ } else {
+ if(StringUtils.isNotEmpty(property.getValue())){
+ rd.addField(property.getName(), property.getValue());
}
}
- } else {
- rd.addField(property.getName(), property.getValue());
}
}
- String fileName = PropertiesUtils.getPropertyValues(properties,
Constants.PROP_NAME)[0];
+ String fileName = StringUtils.EMPTY;
+ String[] propertyValues = PropertiesUtils.getPropertyValues(properties,
Constants.PROP_NAME);
+ if(propertyValues!=null && propertyValues.length>0){
+ fileName = propertyValues[0];
+ }
+
String mimeType = PropertiesUtils.getMimeType(contentProperties);
Date createdDate = PropertiesUtils.getDatePropertyValue(properties,
Constants.PROP_CREATED);
Date modifiedDate = PropertiesUtils.getDatePropertyValue(properties,
PROP_MODIFIED);
-
- rd.setFileName(fileName);
- rd.setMimeType(mimeType);
- rd.setCreatedDate(createdDate);
- rd.setModifiedDate(modifiedDate);
+
+ if(StringUtils.isNotEmpty(fileName)){
+ rd.setFileName(fileName);
+ }
+
+ if(StringUtils.isNotEmpty(mimeType)){
+ rd.setMimeType(mimeType);
+ }
+
+ if(createdDate!=null){
+ rd.setCreatedDate(createdDate);
+ }
+
+ if(modifiedDate!=null){
+ rd.setModifiedDate(modifiedDate);
+ }
}
/**
@@ -93,14 +114,10 @@ public class PropertiesUtils {
if(properties!=null){
for (NamedValue property : properties) {
if(property!=null){
- if(property.getIsMultiValue()!=null){
- if(!property.getIsMultiValue()){
- if(StringUtils.isNotEmpty(property.getValue())){
- if(property.getValue().startsWith(PROP_CONTENT_PREFIX_1)
- || property.getValue().startsWith(PROP_CONTENT_PREFIX_2)){
- contentProperties.add(property);
- }
- }
+ if(property.getIsMultiValue()!=null && !property.getIsMultiValue()){
+ if(StringUtils.isNotEmpty(property.getValue())
+ && property.getValue().startsWith(PROP_CONTENT_PREFIX)){
+ contentProperties.add(property);
}
}
}
@@ -185,8 +202,17 @@ public class PropertiesUtils {
* @throws ParseException
*/
public static Date getDatePropertyValue(NamedValue[] properties, String
qname) throws ParseException{
- String dateString = PropertiesUtils.getPropertyValues(properties,
qname)[0];
- return DateParser.parseISO8601Date(dateString);
+ Date date = null;
+ if(properties!=null && properties.length>0){
+ String[] propertyValues = PropertiesUtils.getPropertyValues(properties,
qname);
+ if(propertyValues!=null && propertyValues.length>0){
+ String dateString = propertyValues[0];
+ if(StringUtils.isNotEmpty(dateString)){
+ date = DateParser.parseISO8601Date(dateString);
+ }
+ }
+ }
+ return date;
}
}
Modified:
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/SearchUtils.java
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/SearchUtils.java?rev=1493075&r1=1493074&r2=1493075&view=diff
==============================================================================
---
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/SearchUtils.java
(original)
+++
manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/SearchUtils.java
Fri Jun 14 13:56:18 2013
@@ -18,6 +18,7 @@
*/
package org.apache.manifoldcf.crawler.connectors.alfresco;
+import java.io.IOException;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;
@@ -54,44 +55,56 @@ public class SearchUtils {
"{http://www.alfresco.org/model/site/1.0}sites"};
- public static QueryResult luceneSearch(String username, String password,
AuthenticationDetails session, String luceneQuery){
+ public static QueryResult luceneSearch(String endpoint, String username,
String password, AuthenticationDetails session, String luceneQuery) throws
IOException {
QueryResult queryResult = null;
Query query = new Query(Constants.QUERY_LANG_LUCENE, luceneQuery);
try {
+ WebServiceFactory.setEndpointAddress(endpoint);
+ WebServiceFactory.setTimeoutMilliseconds(120000);
AuthenticationUtils.startSession(username, password);
session = AuthenticationUtils.getAuthenticationDetails();
queryResult = WebServiceFactory.getRepositoryService().query(STORE,
query, false);
+ AuthenticationUtils.endSession();
} catch (RepositoryFault e) {
Logging.connectors.error(
"Alfresco: Repository fault during addSeedDocuments: "
+ e.getMessage(), e);
+ throw new IOException("Alfresco: Repository fault during
addSeedDocuments: "
+ + e.getMessage(), e);
} catch (RemoteException e) {
Logging.connectors.error(
"Alfresco: Remote exception during addSeedDocuments: "
+ e.getMessage(), e);
- } finally{
- AuthenticationUtils.endSession();
+ throw e;
+ } finally {
+ session = null;
}
return queryResult;
}
- public static QueryResult getChildren(String username, String password,
AuthenticationDetails session, Reference reference){
+ public static QueryResult getChildren(String endpoint, String username,
String password, AuthenticationDetails session, Reference reference) throws
IOException {
QueryResult queryResult = null;
try {
+ WebServiceFactory.setEndpointAddress(endpoint);
+ WebServiceFactory.setTimeoutMilliseconds(120000);
AuthenticationUtils.startSession(username, password);
- session = AuthenticationUtils.getAuthenticationDetails();
+ session = AuthenticationUtils.getAuthenticationDetails();
queryResult =
WebServiceFactory.getRepositoryService().queryChildren(reference);
+ AuthenticationUtils.endSession();
} catch (RepositoryFault e) {
Logging.connectors.error(
"Alfresco: RepositoryFault during getting a node in
processDocuments. Node: "
+ reference.getPath() + ". " + e.getMessage(), e);
+ throw new IOException("Alfresco: RepositoryFault during getting a node
in processDocuments. Node: "
+ + reference.getPath() + ". " + e.getMessage(), e);
+
} catch (RemoteException e) {
Logging.connectors
.error(
"Alfresco: Remote exception error during getting a node in
processDocuments. Node: "
+ reference.getPath() + ". " + e.getMessage(), e);
+ throw e;
} finally {
- AuthenticationUtils.endSession();
session = null;
}
return queryResult;
@@ -104,9 +117,9 @@ public class SearchUtils {
* @param session
* @return filtered children of the Company Home without all the special
spaces
*/
- public static QueryResult getChildrenFromCompanyHome(String username, String
password, AuthenticationDetails session){
+ public static QueryResult getChildrenFromCompanyHome(String endpoint, String
username, String password, AuthenticationDetails session) throws IOException {
Reference companyHome = new Reference(STORE, null, XPATH_COMPANY_HOME);
- QueryResult queryResult =
SearchUtils.getChildren(username,password,session,companyHome);
+ QueryResult queryResult = SearchUtils.getChildren(endpoint,
username,password,session,companyHome);
ResultSet rs = queryResult.getResultSet();
ResultSetRow[] rows = rs.getRows();
List<ResultSetRow> filteredRows = new ArrayList<ResultSetRow>();
Modified: manifoldcf/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/pom.xml?rev=1493075&r1=1493074&r2=1493075&view=diff
==============================================================================
--- manifoldcf/trunk/pom.xml (original)
+++ manifoldcf/trunk/pom.xml Fri Jun 14 13:56:18 2013
@@ -90,8 +90,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>1.7</source>
+ <target>1.7</target>
<fork>true</fork>
<meminitial>128m</meminitial>
<maxmem>512m</maxmem>
Modified:
manifoldcf/trunk/test-materials/alfresco-4-war/src/main/properties/local/alfresco-global.properties
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/test-materials/alfresco-4-war/src/main/properties/local/alfresco-global.properties?rev=1493075&r1=1493074&r2=1493075&view=diff
==============================================================================
---
manifoldcf/trunk/test-materials/alfresco-4-war/src/main/properties/local/alfresco-global.properties
(original)
+++
manifoldcf/trunk/test-materials/alfresco-4-war/src/main/properties/local/alfresco-global.properties
Fri Jun 14 13:56:18 2013
@@ -23,6 +23,9 @@
## Common Alfresco Properties #
###############################
+cifs.enabled=false
+ftp.enabled=false
+nfs.enabled=false
dir.root=${alfresco.data.location}
# Allowed values are: NONE, AUTO, FULL
@@ -66,19 +69,6 @@ wcmqs.dynamicCollectionProcessor.schedul
wcmqs.feedbackProcessor.schedule=0 40 2 * * ? 2060
wcmqs.publishQueueProcessor.schedule=0 50 2 * * ? 2060
-# Fail or not when there are node integrity checker errors
-integrity.failOnError=true
-
-# database connection properties
-# MySQL connection (This is default and requires
mysql-connector-java-5.0.3-bin.jar, which ships with the Alfresco server)
-
-db.driver=${alfresco.db.driver}
-db.url=${alfresco.db.url}
-db.username=${alfresco.db.username}
-db.password=${alfresco.db.password}
-db.pool.initial=10
-db.pool.max=100
-
#
# Sample custom content and index data location