Commit a4e46541 authored by Ate Douma's avatar Ate Douma

REPO-1976 Upgrade to jackrabbit-2.16.1-h1 and Tika 1.17

This introduces the new hippo-repository-tika module which now takes care of managing all the tika-parsers related dependencies (and exclusions),
and provides a new TikaFactory for loading the hippo-repository specific tika-config.xml, and creating new Tika instances using the corresponding TikaConfig.

The tika-core/tika-parsers dependency management previously configured in the hippo-cms7-project parent no longer can/should be used, and thus will be removed.

(cherry picked from commit 56ff16ba)
parent a1a9e805
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2007-2015 Hippo B.V. (http://www.onehippo.com)
Copyright 2007-2018 Hippo B.V. (http://www.onehippo.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......@@ -27,47 +27,6 @@
<artifactId>hippo-repository-config</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms7-commons</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-services</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-api</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-builtin</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-testutils</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-engine</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>package</defaultGoal>
</build>
......
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Authors: Chris Taylor, Ceki Gulcu. -->
<!-- Version: 1.2 -->
<!-- A configuration element consists of optional renderer
elements,appender elements, categories and an optional root
element. -->
<!ELEMENT log4j:configuration (renderer*, appender*,plugin*, (category|logger)*,root?,
(categoryFactory|loggerFactory)?)>
<!-- The "threshold" attribute takes a level value below which -->
<!-- all logging statements are disabled. -->
<!-- Setting the "debug" enable the printing of internal log4j logging -->
<!-- statements. -->
<!-- By default, debug attribute is "null", meaning that we not do touch -->
<!-- internal log4j logging settings. The "null" value for the threshold -->
<!-- attribute can be misleading. The threshold field of a repository -->
<!-- cannot be set to null. The "null" value for the threshold attribute -->
<!-- simply means don't touch the threshold field, the threshold field -->
<!-- keeps its old value. -->
<!ATTLIST log4j:configuration
xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/"
threshold (all|trace|debug|info|warn|error|fatal|off|null) "null"
debug (true|false|null) "null"
reset (true|false) "false"
>
<!-- renderer elements allow the user to customize the conversion of -->
<!-- message objects to String. -->
<!ELEMENT renderer EMPTY>
<!ATTLIST renderer
renderedClass CDATA #REQUIRED
renderingClass CDATA #REQUIRED
>
<!-- Appenders must have a name and a class. -->
<!-- Appenders may contain an error handler, a layout, optional parameters -->
<!-- and filters. They may also reference (or include) other appenders. -->
<!ELEMENT appender (errorHandler?, param*,
rollingPolicy?, triggeringPolicy?, connectionSource?,
layout?, filter*, appender-ref*)>
<!ATTLIST appender
name CDATA #REQUIRED
class CDATA #REQUIRED
>
<!ELEMENT layout (param*)>
<!ATTLIST layout
class CDATA #REQUIRED
>
<!ELEMENT filter (param*)>
<!ATTLIST filter
class CDATA #REQUIRED
>
<!-- ErrorHandlers can be of any class. They can admit any number of -->
<!-- parameters. -->
<!ELEMENT errorHandler (param*, root-ref?, logger-ref*, appender-ref?)>
<!ATTLIST errorHandler
class CDATA #REQUIRED
>
<!ELEMENT root-ref EMPTY>
<!ELEMENT logger-ref EMPTY>
<!ATTLIST logger-ref
ref CDATA #REQUIRED
>
<!ELEMENT param EMPTY>
<!ATTLIST param
name CDATA #REQUIRED
value CDATA #REQUIRED
>
<!-- The priority class is org.apache.log4j.Level by default -->
<!ELEMENT priority (param*)>
<!ATTLIST priority
class CDATA #IMPLIED
value CDATA #REQUIRED
>
<!-- The level class is org.apache.log4j.Level by default -->
<!ELEMENT level (param*)>
<!ATTLIST level
class CDATA #IMPLIED
value CDATA #REQUIRED
>
<!-- If no level element is specified, then the configurator MUST not -->
<!-- touch the level of the named category. -->
<!ELEMENT category (param*,(priority|level)?,appender-ref*)>
<!ATTLIST category
class CDATA #IMPLIED
name CDATA #REQUIRED
additivity (true|false) "true"
>
<!-- If no level element is specified, then the configurator MUST not -->
<!-- touch the level of the named logger. -->
<!ELEMENT logger (level?,appender-ref*)>
<!ATTLIST logger
name CDATA #REQUIRED
additivity (true|false) "true"
>
<!ELEMENT categoryFactory (param*)>
<!ATTLIST categoryFactory
class CDATA #REQUIRED>
<!ELEMENT loggerFactory (param*)>
<!ATTLIST loggerFactory
class CDATA #REQUIRED>
<!ELEMENT appender-ref EMPTY>
<!ATTLIST appender-ref
ref CDATA #REQUIRED
>
<!-- plugins must have a name and class and can have optional parameters -->
<!ELEMENT plugin (param*, connectionSource?)>
<!ATTLIST plugin
name CDATA #REQUIRED
class CDATA #REQUIRED
>
<!ELEMENT connectionSource (dataSource?, param*)>
<!ATTLIST connectionSource
class CDATA #REQUIRED
>
<!ELEMENT dataSource (param*)>
<!ATTLIST dataSource
class CDATA #REQUIRED
>
<!ELEMENT triggeringPolicy ((param|filter)*)>
<!ATTLIST triggeringPolicy
name CDATA #IMPLIED
class CDATA #REQUIRED
>
<!ELEMENT rollingPolicy (param*)>
<!ATTLIST rollingPolicy
name CDATA #IMPLIED
class CDATA #REQUIRED
>
<!-- If no priority element is specified, then the configurator MUST not -->
<!-- touch the priority of root. -->
<!-- The root category always exists and cannot be subclassed. -->
<!ELEMENT root (param*, (priority|level)?, appender-ref*)>
<!-- ==================================================================== -->
<!-- A logging event -->
<!-- ==================================================================== -->
<!ELEMENT log4j:eventSet (log4j:event*)>
<!ATTLIST log4j:eventSet
xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/"
version (1.1|1.2) "1.2"
includesLocationInfo (true|false) "true"
>
<!ELEMENT log4j:event (log4j:message, log4j:NDC?, log4j:throwable?,
log4j:locationInfo?, log4j:properties?) >
<!-- The timestamp format is application dependent. -->
<!ATTLIST log4j:event
logger CDATA #REQUIRED
level CDATA #REQUIRED
thread CDATA #REQUIRED
timestamp CDATA #REQUIRED
time CDATA #IMPLIED
>
<!ELEMENT log4j:message (#PCDATA)>
<!ELEMENT log4j:NDC (#PCDATA)>
<!ELEMENT log4j:throwable (#PCDATA)>
<!ELEMENT log4j:locationInfo EMPTY>
<!ATTLIST log4j:locationInfo
class CDATA #REQUIRED
method CDATA #REQUIRED
file CDATA #REQUIRED
line CDATA #REQUIRED
>
<!ELEMENT log4j:properties (log4j:data*)>
<!ELEMENT log4j:data EMPTY>
<!ATTLIST log4j:data
name CDATA #REQUIRED
value CDATA #REQUIRED
>
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright 2007-2013 Hippo B.V. (http://www.onehippo.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- ====================================================================== -->
<!-- A P P E N D E R S -->
<!-- ====================================================================== -->
<!-- console -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="threshold" value="ERROR"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} %-5p [%C.%M():%L] %m%n"/>
</layout>
</appender>
<!-- log4j.log -->
<appender name="root" class="org.apache.log4j.FileAppender">
<param name="File" value="log4j.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} %-5p [%C.%M():%L] %m%n"/>
</layout>
</appender>
<!-- ====================================================================== -->
<!-- L O G G E R S -->
<!-- ====================================================================== -->
<category additivity="false" name="org.apache.jackrabbit.core">
<level value="warn"/>
<appender-ref ref="root"/>
</category>
<category additivity="false" name="org.apache.jackrabbit.core.state.MLRUItemStateCache">
<level value="error"/>
<appender-ref ref="root"/>
</category>
<category additivity="false" name="org.apache.jackrabbit.core.state.ItemStateMap">
<level value="error"/>
<appender-ref ref="root"/>
</category>
<category additivity="false" name="org.apache.jackrabbit.core.state.ItemStateReferenceCache">
<level value="error"/>
<appender-ref ref="root"/>
</category>
<category additivity="false" name="org.hippoecm.repository">
<level value="warn"/>
<appender-ref ref="console"/>
</category>
<category additivity="false" name="org.hippoecm.repository.export">
<level value="warn"/>
<appender-ref ref="console"/>
</category>
<category additivity="false" name="org.hippoecm.repository.jackrabbit.HippoVirtualProvider">
<level value="error"/>
<appender-ref ref="console"/>
</category>
<category additivity="false" name="org.hippoecm.repository.security.HippoAccessManager">
<level value="warn"/>
<appender-ref ref="root"/>
</category>
<category additivity="false" name="org.hippoecm.repository.security.HippoLoginModule">
<level value="warn"/>
<appender-ref ref="root"/>
</category>
<category additivity="false" name="org.hippoecm.repository.updater">
<level value="warn"/>
<appender-ref ref="console"/>
</category>
<category additivity="false" name="org.hippoecm.checker">
<level value="warn"/>
<appender-ref ref="console"/>
</category>
<root>
<level value="warn"/>
<appender-ref ref="console"/>
<appender-ref ref="root"/>
</root>
</log4j:configuration>
......@@ -58,14 +58,6 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr2spi</artifactId>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-spi2jcr</artifactId>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-spi-commons</artifactId>
......
Note that this directory contains parts of source code of a sandbox
Apache JackRabbit project.
Only slight modifications have been done in order to allow this source
to be run with JackRabbit 1.4, in combination with the patch which is
also here and is part of the sandbox project.
Both a update ot JackRabbit trunk and a release of the spi-rmi project
are required to move this source out of Hippo ECM source basis.
Copied have been made from
http://svn.apache.org/repos/asf/jackrabbit/sandbox/spi/spi-rmi/src/main/java/org/apache
with SVN revision 682125.
/*
* Copyright 2008-2013 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.jackrabbit.jcr2spi;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import javax.jcr.Credentials;
import javax.jcr.LoginException;
import javax.jcr.NamespaceException;
import javax.jcr.NoSuchWorkspaceException;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Value;
import javax.jcr.ValueFactory;
import javax.naming.NamingException;
import javax.naming.RefAddr;
import javax.naming.Reference;
import javax.naming.Referenceable;
import javax.naming.StringRefAddr;
import org.apache.jackrabbit.commons.AbstractRepository;
import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
import org.apache.jackrabbit.spi.QValue;
import org.apache.jackrabbit.spi.SessionInfo;
import org.apache.jackrabbit.spi.XASessionInfo;
import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
import org.apache.jackrabbit.spi.commons.value.ValueFormat;
import org.apache.jackrabbit.value.ValueFactoryImpl;
/**
* <code>HippoRepositoryImpl</code>...
*/
public class HippoRepositoryImpl extends AbstractRepository implements Referenceable {
// configuration of the repository
private final RepositoryConfig config;
private final Map<String,Value[]> descriptors;
private Reference reference = null;
private HippoRepositoryImpl(RepositoryConfig config) throws RepositoryException {
this.config = config;
ValueFactory vf = ValueFactoryImpl.getInstance();
NamePathResolver resolver = new DefaultNamePathResolver(new NamespaceResolver() {
public String getURI(String prefix) throws NamespaceException {
return prefix;
}
public String getPrefix(String uri) throws NamespaceException {
return uri;
}
});
Map<String, QValue[]> descr = config.getRepositoryService().getRepositoryDescriptors();
descriptors = new HashMap<String, Value[]>(descr.size());
for (Map.Entry<String,QValue[]> entry : descr.entrySet()) {
QValue[] qvs = entry.getValue();
Value[] vs = new Value[qvs.length];
for (int i = 0; i < qvs.length; i++) {
vs[i] = ValueFormat.getJCRValue(qvs[i], resolver, vf);
}
descriptors.put(entry.getKey(), vs);
}
}
public static Repository create(RepositoryConfig config) throws RepositoryException {
return new HippoRepositoryImpl(config);
}
//---------------------------------------------------------< Repository >---
/**
* @see Repository#getDescriptorKeys()
*/
public String[] getDescriptorKeys() {
String[] keys = (String[]) descriptors.keySet().toArray(new String[descriptors.keySet().size()]);
return keys;
}
/**
* @see Repository#getDescriptor(String)
*/
public String getDescriptor(String descriptorKey) {
Value[] values = descriptors.get(descriptorKey);
if(values.length >= 0) {
try {
return values[0].getString();
} catch(RepositoryException ex) {
}
}
return null;
}
/**
* @see Repository#login(javax.jcr.Credentials, String)
*/
public Session login(Credentials credentials, String workspaceName) throws LoginException, NoSuchWorkspaceException, RepositoryException {
SessionInfo info = config.getRepositoryService().obtain(credentials, workspaceName);
try {
if (info instanceof XASessionInfo) {
return new HippoXASessionImpl((XASessionInfo) info, this, config);
} else {
return new HippoSessionImpl(info, this, config);
}
} catch (RepositoryException ex) {
config.getRepositoryService().dispose(info);
throw ex;
}
}
//---------------------------------------------------------< Rereferencable >---
/**
* @see Referenceable#getReference()
*/
public Reference getReference() throws NamingException {
if (config instanceof Referenceable) {
Referenceable confref = (Referenceable)config;
if (reference == null) {
reference = new Reference(RepositoryImpl.class.getName(), RepositoryImpl.Factory.class.getName(), null);
// carry over all addresses from referenceable config
for (Enumeration en = confref.getReference().getAll(); en.hasMoreElements(); ) {
reference.add((RefAddr)(en.nextElement()));
}
// also add the information required by factory class
reference.add(new StringRefAddr(RepositoryImpl.Factory.RCF, confref.getReference().getFactoryClassName()));
reference.add(new StringRefAddr(RepositoryImpl.Factory.RCC, config.getClass().getName()));
}
return reference;
}
else {
throw new javax.naming.OperationNotSupportedException("Contained RepositoryConfig needs to implement javax.naming.Referenceable");
}
}
public boolean isSingleValueDescriptor(String key) {
Value[] values = descriptors.get(key);
if(values != null && values.length == 1)
return true;
return false;
}
public Value getDescriptorValue(String key) {
Value[] values = descriptors.get(key);
if (values == null || values.length!=1)
return null;
return values[0];
}
public Value[] getDescriptorValues(String key) {
Value[] values = descriptors.get(key);
if (values == null || values.length!=1)
return null;
return values;
}
}
/*
* Copyright 2008-2013 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.jackrabbit.jcr2spi;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import javax.jcr.AccessDeniedException;
import javax.jcr.NamespaceException;
import javax.jcr.NoSuchWorkspaceException;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.nodetype.NoSuchNodeTypeException;
import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyManager;
import org.apache.jackrabbit.jcr2spi.state.HippoSessionItemStateManager;
import org.apache.jackrabbit.jcr2spi.state.ItemState;
import org.apache.jackrabbit.jcr2spi.state.ItemStateFactory;
import org.apache.jackrabbit.jcr2spi.state.NodeState;
import org.apache.jackrabbit.jcr2spi.state.SessionItemStateManager;
import org.apache.jackrabbit.jcr2spi.state.UpdatableItemStateManager;
import org.apache.jackrabbit.spi.SessionInfo;
import org.apache.jackrabbit.spi.XASessionInfo;
import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* <code>HippoSessionImpl</code>...
*/
public class HippoSessionImpl extends SessionImpl implements NamespaceResolver, ManagerProvider {
private static Logger log = LoggerFactory.getLogger(SessionImpl.class);
private Repository repository;
private SessionInfo sessionInfo;
private RepositoryConfig config;
private HippoSessionItemStateManager sessionItemStateManager;
private ItemManager itemManager;
HippoSessionImpl(SessionInfo sessionInfo, Repository repository, RepositoryConfig config)
throws RepositoryException {
super(sessionInfo, repository, config);
this.repository = repository;
this.config = config;
this.sessionInfo = sessionInfo;
}
@Override
protected SessionItemStateManager createSessionItemStateManager(UpdatableItemStateManager wsStateManager,
ItemStateFactory isf) throws RepositoryException {
sessionItemStateManager = new HippoSessionItemStateManager(wsStateManager, getValidator(), getQValueFactory(), isf, this);
return sessionItemStateManager;
}
@Override
protected ItemManager createItemManager(HierarchyManager hierarchyManager) {
itemManager = super.createItemManager(hierarchyManager);
return itemManager;
}
@Override
HippoSessionImpl switchWorkspace(String workspaceName) throws AccessDeniedException, NoSuchWorkspaceException,
RepositoryException {
checkAccessibleWorkspace(workspaceName);
SessionInfo info = config.getRepositoryService().obtain(sessionInfo, workspaceName);
if (info instanceof XASessionInfo) {
return new HippoXASessionImpl((XASessionInfo) info, repository, config);
} else {
return new HippoSessionImpl(info, repository, config);
}
}
public NodeIterator pendingChanges(Node node, String nodeType, boolean prune) throws NamespaceException,
NoSuchNodeTypeException, RepositoryException {
NodeState target;
if(node != null) {
target = (NodeState) ((NodeImpl)node).getItemState();
} else {
target = getHierarchyManager().getRootEntry().getNodeState();
}
Set affected = sessionItemStateManager.pendingChanges(target);
Set<Node> nodes = new LinkedHashSet<Node>();
for(Iterator iter = affected.iterator(); iter.hasNext(); ) {
ItemState state = (ItemState) iter.next();
if (!state.isValid()) {
continue;
}
boolean propChange = false;
if(!state.isNode()) {
state = state.getParent();
propChange = true;
}
Node candidate = (Node) itemManager.getItem(state.getHierarchyEntry());
if(nodeType != null && !candidate.isNodeType(nodeType))
continue;
if(!propChange && node != null && node.isSame(candidate))
continue;
nodes.add(candidate);
}
if (prune) {
for (Iterator<Node> iter = nodes.iterator(); iter.hasNext();) {
Node ancestor = iter.next();
while (ancestor.getDepth() > 0) {
ancestor = ancestor.getParent();
if (node != null && node.equals(ancestor)) {
break;
}
if (nodes.contains(ancestor)) {
iter.remove