Compare commits

..

28 Commits

Author SHA1 Message Date
dependabot[bot]
81e5bd509e Bump org.apache.commons:commons-dbcp2 from 2.12.0 to 2.13.0
Bumps org.apache.commons:commons-dbcp2 from 2.12.0 to 2.13.0.

---
updated-dependencies:
- dependency-name: org.apache.commons:commons-dbcp2
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-03 22:45:01 +00:00
alfresco-build
00c36251d4 [maven-release-plugin][skip ci] prepare for next development iteration 2024-12-02 15:05:20 +00:00
alfresco-build
ea9ce0c0c2 [maven-release-plugin][skip ci] prepare release 25.1.0.8 2024-12-02 15:05:18 +00:00
Eva Vasques
37231e50a2 MNT-24753 Restore from Archive when we have multiple content stores (#3066)
* Pre-commit changes
* Method requestRestoreContentFromArchive needs to use injected ContentStore
2024-12-02 14:22:51 +00:00
alfresco-build
26d8c7dcbe [maven-release-plugin][skip ci] prepare for next development iteration 2024-12-01 00:09:27 +00:00
alfresco-build
6ea97033d3 [maven-release-plugin][skip ci] prepare release 25.1.0.7 2024-12-01 00:09:23 +00:00
Alfresco CI User
cd0b2ffd24 [force] Force release for 2024-12-01. 2024-12-01 00:05:05 +00:00
alfresco-build
a14cbacb68 [maven-release-plugin][skip ci] prepare for next development iteration 2024-11-29 07:34:35 +00:00
alfresco-build
fc0b9863d4 [maven-release-plugin][skip ci] prepare release 25.1.0.6 2024-11-29 07:34:33 +00:00
Cezary Witkowski
29dc42d445 Merge pull request #3063 from Alfresco/revert-3051-dependabot/maven/dependency.log4j.version-2.24.2
Revert "Bump dependency.log4j.version from 2.23.1 to 2.24.2"
2024-11-28 15:26:55 +01:00
Cezary Witkowski
39da968d76 Revert "Bump dependency.log4j.version from 2.23.1 to 2.24.2 (#3051)"
This reverts commit 748be1f4a0.
2024-11-28 14:36:47 +01:00
alfresco-build
6a4fecd46e [maven-release-plugin][skip ci] prepare for next development iteration 2024-11-28 11:36:08 +00:00
alfresco-build
e083d4fcc2 [maven-release-plugin][skip ci] prepare release 25.1.0.5 2024-11-28 11:36:06 +00:00
varapathijanakiram
53e8a06a6e Merge pull request #3058 from Alfresco/fix/MNT-24571-Site-Membership-API
Fix/MNT-24571-Site Membership API
2024-11-28 16:23:20 +05:30
alfresco-build
c80e1fa94b [maven-release-plugin][skip ci] prepare for next development iteration 2024-11-28 09:56:23 +00:00
vjanakiram
d405043c5d Update the SiteMembership 2024-11-27 12:38:50 +05:30
rrajoria
da50f6271c Fix Precommit 2024-11-27 11:20:04 +05:30
rrajoria
a5e713c176 Fix Precommit 2024-11-27 11:11:41 +05:30
rrajoria
2dcd2788b2 Fix Precommit 2024-11-27 11:02:51 +05:30
vjanakiram
6b738342c1 Update the license SiteMembership 2024-11-27 10:59:13 +05:30
vjanakiram
ba5f5418ab Revert "Update the license i SiteMembership"
This reverts commit ee8f3bec18.
2024-11-27 10:58:40 +05:30
vjanakiram
ee8f3bec18 Update the license i SiteMembership 2024-11-27 10:47:56 +05:30
vjanakiram
39395af528 Update the SiteMembership Class 2024-11-26 17:49:12 +05:30
vjanakiram
e6f9d88779 Update the SiteMembership Class 2024-11-26 17:27:33 +05:30
vjanakiram
70f70c6ed3 Revert "Update the SiteMembership Class"
This reverts commit 15045f9612.
2024-11-26 17:26:44 +05:30
vjanakiram
15045f9612 Update the SiteMembership Class 2024-11-26 17:25:23 +05:30
vjanakiram
b5e023950d Update the SiteMembership Class 2024-11-26 16:48:11 +05:30
varapathijanakiram
d4591acf2c Update the SiteMembership Class 2024-11-26 16:31:47 +05:30
26 changed files with 518 additions and 532 deletions

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-amps</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<modules>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-community-parent</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<modules>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-automation-community-repo</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<build>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-community-parent</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<modules>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<properties>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<build>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<modules>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-amps</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<properties>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<dependencies>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<properties>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<dependencies>

View File

@@ -9,6 +9,6 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
</project>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<properties>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<modules>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<modules>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<organization>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<developers>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<developers>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<properties>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<developers>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<properties>

View File

@@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-community-repo</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Alfresco Community Repo Parent</name>
@@ -68,7 +68,7 @@
<dependency.mockito-core.version>5.14.1</dependency.mockito-core.version>
<dependency.assertj.version>3.26.3</dependency.assertj.version>
<dependency.org-json.version>20240303</dependency.org-json.version>
<dependency.commons-dbcp.version>2.12.0</dependency.commons-dbcp.version>
<dependency.commons-dbcp.version>2.13.0</dependency.commons-dbcp.version>
<dependency.commons-io.version>2.18.0</dependency.commons-io.version>
<dependency.gson.version>2.11.0</dependency.gson.version>
<dependency.guava.version>33.3.1-jre</dependency.guava.version>
@@ -79,7 +79,7 @@
<dependency.commons-httpclient.version>3.1-HTTPCLIENT-1265</dependency.commons-httpclient.version>
<dependency.xercesImpl.version>2.12.2</dependency.xercesImpl.version>
<dependency.slf4j.version>2.0.16</dependency.slf4j.version>
<dependency.log4j.version>2.24.2</dependency.log4j.version>
<dependency.log4j.version>2.23.1</dependency.log4j.version>
<dependency.groovy.version>3.0.23</dependency.groovy.version>
<dependency.tika.version>2.9.2</dependency.tika.version>
<dependency.truezip.version>7.7.10</dependency.truezip.version>
@@ -155,7 +155,7 @@
<connection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</connection>
<developerConnection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</developerConnection>
<url>https://github.com/Alfresco/alfresco-community-repo</url>
<tag>25.1.0.4</tag>
<tag>HEAD</tag>
</scm>
<distributionManagement>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<dependencies>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>25.1.0.4</version>
<version>25.1.0.9-SNAPSHOT</version>
</parent>
<dependencies>

View File

@@ -1,493 +1,484 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2021 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* 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/>.
* #L%
*/
package org.alfresco.repo.content;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.service.cmr.repository.ContentIOException;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.util.GUID;
import org.alfresco.util.Pair;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* A store providing support for content store implementations that provide
* routing of content read and write requests based on context.
*
* @see ContentContext
*
* @since 2.1
* @author Derek Hulley
*/
public abstract class AbstractRoutingContentStore implements ContentStore
{
private static Log logger = LogFactory.getLog(AbstractRoutingContentStore.class);
private String instanceKey = GUID.generate();
private SimpleCache<Pair<String, String>, ContentStore> storesByContentUrl;
private ReadLock storesCacheReadLock;
private WriteLock storesCacheWriteLock;
protected AbstractRoutingContentStore()
{
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
storesCacheReadLock = lock.readLock();
storesCacheWriteLock = lock.writeLock();
}
/**
* @param storesCache cache of stores used to access URLs
*/
public void setStoresCache(SimpleCache<Pair<String, String>, ContentStore> storesCache)
{
this.storesByContentUrl = storesCache;
}
/**
* @return Returns a list of all possible stores available for reading or writing
*/
protected abstract List<ContentStore> getAllStores();
/**
* Get a content store based on the context provided. The applicability of the
* context and even the types of context allowed are up to the implementation, but
* normally there should be a fallback case for when the parameters are not adequate
* to make a decision.
*
* @param ctx the context to use to make the choice
* @return Returns the store most appropriate for the given context and
* <b>never <tt>null</tt></b>
*/
protected abstract ContentStore selectWriteStore(ContentContext ctx);
/**
* Checks the cache for the store and ensures that the URL is in the store.
*
* @param contentUrl the content URL to search for
* @return Returns the store matching the content URL
*/
private ContentStore selectReadStore(String contentUrl)
{
Pair<String, String> cacheKey = new Pair<String, String>(instanceKey, contentUrl);
storesCacheReadLock.lock();
try
{
// Check if the store is in the cache
ContentStore store = storesByContentUrl.get(cacheKey);
if (store != null)
{
// We found a store that was previously used
try
{
// It is possible for content to be removed from a store and
// it might have moved into another store.
if (store.exists(contentUrl))
{
// We found a store and can use it
return store;
}
}
catch (UnsupportedContentUrlException e)
{
// This is odd. The store that previously supported the content URL
// no longer does so. I can't think of a reason why that would be.
throw new AlfrescoRuntimeException(
"Found a content store that previously supported a URL, but no longer does: \n" +
" Store: " + store + "\n" +
" Content URL: " + contentUrl);
}
}
}
finally
{
storesCacheReadLock.unlock();
}
// Get the write lock and double check
storesCacheWriteLock.lock();
try
{
// Double check
ContentStore store = storesByContentUrl.get(cacheKey);
if (store != null && store.exists(contentUrl))
{
// We found a store and can use it
if (logger.isDebugEnabled())
{
logger.debug(
"Found mapped store for content URL: \n" +
" Content URL: " + contentUrl + "\n" +
" Store: " + store);
}
return store;
}
else
{
store = null;
}
// It isn't, so search all the stores
List<ContentStore> stores = getAllStores();
// Keep track of the unsupported state of the content URL - it might be a rubbish URL
boolean contentUrlSupported = false;
for (ContentStore storeInList : stores)
{
boolean exists = false;
try
{
exists = storeInList.exists(contentUrl);
// At least the content URL was supported
contentUrlSupported = true;
}
catch (UnsupportedContentUrlException e)
{
// The store can't handle the content URL
}
if (!exists)
{
// It is not in the store
continue;
}
// We found one
store = storeInList;
// Put the value in the cache
storesByContentUrl.put(cacheKey, store);
break;
}
// Check if the content URL was supported
if (!contentUrlSupported)
{
throw new UnsupportedContentUrlException(this, contentUrl);
}
// Done
if (logger.isDebugEnabled())
{
logger.debug(
"Mapped content URL to store for reading: \n" +
" Content URL: " + contentUrl + "\n" +
" Store: " + store);
}
return store;
}
finally
{
storesCacheWriteLock.unlock();
}
}
/**
* @return Returns <tt>true</tt> if the URL is supported by any of the stores.
*/
public boolean isContentUrlSupported(String contentUrl)
{
List<ContentStore> stores = getAllStores();
boolean supported = false;
for (ContentStore store : stores)
{
if (store.isContentUrlSupported(contentUrl))
{
supported = true;
break;
}
}
// Done
if (logger.isDebugEnabled())
{
logger.debug("The url " + (supported ? "is" : "is not") + " supported by at least one store.");
}
return supported;
}
/**
* @return Returns <tt>true</tt> if write is supported by any of the stores.
*/
public boolean isWriteSupported()
{
List<ContentStore> stores = getAllStores();
boolean supported = false;
for (ContentStore store : stores)
{
if (store.isWriteSupported())
{
supported = true;
break;
}
}
// Done
if (logger.isDebugEnabled())
{
logger.debug("Writing " + (supported ? "is" : "is not") + " supported by at least one store.");
}
return supported;
}
/**
* @return Returns <b>.</b> always
*/
public String getRootLocation()
{
return ".";
}
/**
* @return Returns <tt>-1</tt> always
*/
@Override
public long getSpaceFree()
{
return -1L;
}
/**
* @return Returns <tt>-1</tt> always
*/
@Override
public long getSpaceTotal()
{
return -1L;
}
/**
* @see #selectReadStore(String)
*/
public boolean exists(String contentUrl) throws ContentIOException
{
ContentStore store = selectReadStore(contentUrl);
return (store != null);
}
/**
* @return Returns a valid reader from one of the stores otherwise
* a {@link EmptyContentReader} is returned.
*/
public ContentReader getReader(String contentUrl) throws ContentIOException
{
ContentStore store = selectReadStore(contentUrl);
if (store != null)
{
if (logger.isDebugEnabled())
{
logger.debug("Getting reader from store: \n" +
" Content URL: " + contentUrl + "\n" +
" Store: " + store);
}
return store.getReader(contentUrl);
}
else
{
if (logger.isDebugEnabled())
{
logger.debug("Getting empty reader for content URL: " + contentUrl);
}
return new EmptyContentReader(contentUrl);
}
}
/**
* Selects a store for the given context and caches store that was used.
*
* @see #selectWriteStore(ContentContext)
*/
public ContentWriter getWriter(ContentContext context) throws ContentIOException
{
String contentUrl = context.getContentUrl();
Pair<String, String> cacheKey = new Pair<String, String>(instanceKey, contentUrl);
if (contentUrl != null)
{
// Check to see if it is in the cache
storesCacheReadLock.lock();
try
{
// Check if the store is in the cache
ContentStore store = storesByContentUrl.get(cacheKey);
if (store != null)
{
throw new ContentExistsException(this, contentUrl);
}
/*
* We could go further and check each store for the existence of the URL,
* but that would be overkill. The main problem we need to prevent is
* the simultaneous access of the same store. The router represents
* a single store and therefore if the URL is present in any of the stores,
* it is effectively present in all of them.
*/
}
finally
{
storesCacheReadLock.unlock();
}
}
// Select the store for writing
ContentStore store = selectWriteStore(context);
// Check that we were given a valid store
if (store == null)
{
throw new NullPointerException(
"Unable to find a writer. 'selectWriteStore' may not return null: \n" +
" Router: " + this + "\n" +
" Chose: " + store);
}
else if (!store.isWriteSupported())
{
throw new AlfrescoRuntimeException(
"A write store was chosen that doesn't support writes: \n" +
" Router: " + this + "\n" +
" Chose: " + store);
}
ContentWriter writer = store.getWriter(context);
String newContentUrl = writer.getContentUrl();
Pair<String, String> newCacheKey = new Pair<String, String>(instanceKey, newContentUrl);
// Cache the store against the URL
storesCacheWriteLock.lock();
try
{
storesByContentUrl.put(newCacheKey, store);
}
finally
{
storesCacheWriteLock.unlock();
}
// Done
if (logger.isDebugEnabled())
{
logger.debug(
"Got writer and cache URL from store: \n" +
" Context: " + context + "\n" +
" Writer: " + writer + "\n" +
" Store: " + store);
}
return writer;
}
public ContentWriter getWriter(ContentReader existingContentReader, String newContentUrl) throws ContentIOException
{
return getWriter(new ContentContext(existingContentReader, newContentUrl));
}
/**
* This operation has to be performed on all the stores in order to maintain the
* {@link ContentStore#exists(String)} contract.
*/
public boolean delete(String contentUrl) throws ContentIOException
{
boolean deleted = true;
List<ContentStore> stores = getAllStores();
for (ContentStore store : stores)
{
if (store.isWriteSupported())
{
deleted &= store.delete(contentUrl);
}
}
// Done
if (logger.isDebugEnabled())
{
logger.debug("Deleted content URL from stores: \n" +
" Stores: " + stores.size() + "\n" +
" Deleted: " + deleted);
}
return deleted;
}
/**
* {@inheritDoc}
*/
@Override
public Map<String, String> getStorageProperties(String contentUrl)
{
ContentStore contentStore = selectReadStore(contentUrl);
if (contentStore == null)
{
logNoContentStore(contentUrl);
return Collections.emptyMap();
}
final String message = "Getting storage properties from store: ";
logExecution(contentUrl, contentStore, message);
return contentStore.getStorageProperties(contentUrl);
}
/**
* {@inheritDoc}
*/
@Override
public boolean requestSendContentToArchive(String contentUrl, Map<String, Serializable> archiveParams)
{
final ContentStore contentStore = selectReadStore(contentUrl);
if (contentStore == null)
{
logNoContentStore(contentUrl);
return ContentStore.super.requestSendContentToArchive(contentUrl, archiveParams);
}
final String message = "Sending content to archive: ";
logExecution(contentUrl, contentStore, message);
return contentStore.requestSendContentToArchive(contentUrl, archiveParams);
}
/**
* {@inheritDoc}
*/
@Override
public boolean requestRestoreContentFromArchive(String contentUrl, Map<String, Serializable> restoreParams)
{
final ContentStore contentStore = selectReadStore(contentUrl);
if (contentStore == null)
{
logNoContentStore(contentUrl);
return ContentStore.super.requestRestoreContentFromArchive(contentUrl, restoreParams);
}
final String message = "Restoring content from archive: ";
logExecution(contentUrl, contentStore, message);
return ContentStore.super.requestRestoreContentFromArchive(contentUrl, restoreParams);
}
private void logExecution(final String contentUrl, final ContentStore contentStore, final String message)
{
if (logger.isTraceEnabled())
{
logger.trace(message + "\n" +
" Content URL: " + contentUrl + "\n" +
" Store: " + contentStore);
}
}
private void logNoContentStore(String contentUrl)
{
if (logger.isTraceEnabled())
{
logger.trace("Content Store not found for content URL: " + contentUrl);
}
}
}
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2021 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* 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/>.
* #L%
*/
package org.alfresco.repo.content;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.service.cmr.repository.ContentIOException;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.util.GUID;
import org.alfresco.util.Pair;
/**
* A store providing support for content store implementations that provide routing of content read and write requests based on context.
*
* @see ContentContext
*
* @since 2.1
* @author Derek Hulley
*/
public abstract class AbstractRoutingContentStore implements ContentStore
{
private static Log logger = LogFactory.getLog(AbstractRoutingContentStore.class);
private String instanceKey = GUID.generate();
private SimpleCache<Pair<String, String>, ContentStore> storesByContentUrl;
private ReadLock storesCacheReadLock;
private WriteLock storesCacheWriteLock;
protected AbstractRoutingContentStore()
{
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
storesCacheReadLock = lock.readLock();
storesCacheWriteLock = lock.writeLock();
}
/**
* @param storesCache
* cache of stores used to access URLs
*/
public void setStoresCache(SimpleCache<Pair<String, String>, ContentStore> storesCache)
{
this.storesByContentUrl = storesCache;
}
/**
* @return Returns a list of all possible stores available for reading or writing
*/
protected abstract List<ContentStore> getAllStores();
/**
* Get a content store based on the context provided. The applicability of the context and even the types of context allowed are up to the implementation, but normally there should be a fallback case for when the parameters are not adequate to make a decision.
*
* @param ctx
* the context to use to make the choice
* @return Returns the store most appropriate for the given context and <b>never <tt>null</tt></b>
*/
protected abstract ContentStore selectWriteStore(ContentContext ctx);
/**
* Checks the cache for the store and ensures that the URL is in the store.
*
* @param contentUrl
* the content URL to search for
* @return Returns the store matching the content URL
*/
private ContentStore selectReadStore(String contentUrl)
{
Pair<String, String> cacheKey = new Pair<String, String>(instanceKey, contentUrl);
storesCacheReadLock.lock();
try
{
// Check if the store is in the cache
ContentStore store = storesByContentUrl.get(cacheKey);
if (store != null)
{
// We found a store that was previously used
try
{
// It is possible for content to be removed from a store and
// it might have moved into another store.
if (store.exists(contentUrl))
{
// We found a store and can use it
return store;
}
}
catch (UnsupportedContentUrlException e)
{
// This is odd. The store that previously supported the content URL
// no longer does so. I can't think of a reason why that would be.
throw new AlfrescoRuntimeException(
"Found a content store that previously supported a URL, but no longer does: \n" +
" Store: " + store + "\n" +
" Content URL: " + contentUrl);
}
}
}
finally
{
storesCacheReadLock.unlock();
}
// Get the write lock and double check
storesCacheWriteLock.lock();
try
{
// Double check
ContentStore store = storesByContentUrl.get(cacheKey);
if (store != null && store.exists(contentUrl))
{
// We found a store and can use it
if (logger.isDebugEnabled())
{
logger.debug(
"Found mapped store for content URL: \n" +
" Content URL: " + contentUrl + "\n" +
" Store: " + store);
}
return store;
}
else
{
store = null;
}
// It isn't, so search all the stores
List<ContentStore> stores = getAllStores();
// Keep track of the unsupported state of the content URL - it might be a rubbish URL
boolean contentUrlSupported = false;
for (ContentStore storeInList : stores)
{
boolean exists = false;
try
{
exists = storeInList.exists(contentUrl);
// At least the content URL was supported
contentUrlSupported = true;
}
catch (UnsupportedContentUrlException e)
{
// The store can't handle the content URL
}
if (!exists)
{
// It is not in the store
continue;
}
// We found one
store = storeInList;
// Put the value in the cache
storesByContentUrl.put(cacheKey, store);
break;
}
// Check if the content URL was supported
if (!contentUrlSupported)
{
throw new UnsupportedContentUrlException(this, contentUrl);
}
// Done
if (logger.isDebugEnabled())
{
logger.debug(
"Mapped content URL to store for reading: \n" +
" Content URL: " + contentUrl + "\n" +
" Store: " + store);
}
return store;
}
finally
{
storesCacheWriteLock.unlock();
}
}
/**
* @return Returns <tt>true</tt> if the URL is supported by any of the stores.
*/
public boolean isContentUrlSupported(String contentUrl)
{
List<ContentStore> stores = getAllStores();
boolean supported = false;
for (ContentStore store : stores)
{
if (store.isContentUrlSupported(contentUrl))
{
supported = true;
break;
}
}
// Done
if (logger.isDebugEnabled())
{
logger.debug("The url " + (supported ? "is" : "is not") + " supported by at least one store.");
}
return supported;
}
/**
* @return Returns <tt>true</tt> if write is supported by any of the stores.
*/
public boolean isWriteSupported()
{
List<ContentStore> stores = getAllStores();
boolean supported = false;
for (ContentStore store : stores)
{
if (store.isWriteSupported())
{
supported = true;
break;
}
}
// Done
if (logger.isDebugEnabled())
{
logger.debug("Writing " + (supported ? "is" : "is not") + " supported by at least one store.");
}
return supported;
}
/**
* @return Returns <b>.</b> always
*/
public String getRootLocation()
{
return ".";
}
/**
* @return Returns <tt>-1</tt> always
*/
@Override
public long getSpaceFree()
{
return -1L;
}
/**
* @return Returns <tt>-1</tt> always
*/
@Override
public long getSpaceTotal()
{
return -1L;
}
/**
* @see #selectReadStore(String)
*/
public boolean exists(String contentUrl) throws ContentIOException
{
ContentStore store = selectReadStore(contentUrl);
return (store != null);
}
/**
* @return Returns a valid reader from one of the stores otherwise a {@link EmptyContentReader} is returned.
*/
public ContentReader getReader(String contentUrl) throws ContentIOException
{
ContentStore store = selectReadStore(contentUrl);
if (store != null)
{
if (logger.isDebugEnabled())
{
logger.debug("Getting reader from store: \n" +
" Content URL: " + contentUrl + "\n" +
" Store: " + store);
}
return store.getReader(contentUrl);
}
else
{
if (logger.isDebugEnabled())
{
logger.debug("Getting empty reader for content URL: " + contentUrl);
}
return new EmptyContentReader(contentUrl);
}
}
/**
* Selects a store for the given context and caches store that was used.
*
* @see #selectWriteStore(ContentContext)
*/
public ContentWriter getWriter(ContentContext context) throws ContentIOException
{
String contentUrl = context.getContentUrl();
Pair<String, String> cacheKey = new Pair<String, String>(instanceKey, contentUrl);
if (contentUrl != null)
{
// Check to see if it is in the cache
storesCacheReadLock.lock();
try
{
// Check if the store is in the cache
ContentStore store = storesByContentUrl.get(cacheKey);
if (store != null)
{
throw new ContentExistsException(this, contentUrl);
}
/* We could go further and check each store for the existence of the URL, but that would be overkill. The main problem we need to prevent is the simultaneous access of the same store. The router represents a single store and therefore if the URL is present in any of the stores, it is effectively present in all of them. */
}
finally
{
storesCacheReadLock.unlock();
}
}
// Select the store for writing
ContentStore store = selectWriteStore(context);
// Check that we were given a valid store
if (store == null)
{
throw new NullPointerException(
"Unable to find a writer. 'selectWriteStore' may not return null: \n" +
" Router: " + this + "\n" +
" Chose: " + store);
}
else if (!store.isWriteSupported())
{
throw new AlfrescoRuntimeException(
"A write store was chosen that doesn't support writes: \n" +
" Router: " + this + "\n" +
" Chose: " + store);
}
ContentWriter writer = store.getWriter(context);
String newContentUrl = writer.getContentUrl();
Pair<String, String> newCacheKey = new Pair<String, String>(instanceKey, newContentUrl);
// Cache the store against the URL
storesCacheWriteLock.lock();
try
{
storesByContentUrl.put(newCacheKey, store);
}
finally
{
storesCacheWriteLock.unlock();
}
// Done
if (logger.isDebugEnabled())
{
logger.debug(
"Got writer and cache URL from store: \n" +
" Context: " + context + "\n" +
" Writer: " + writer + "\n" +
" Store: " + store);
}
return writer;
}
public ContentWriter getWriter(ContentReader existingContentReader, String newContentUrl) throws ContentIOException
{
return getWriter(new ContentContext(existingContentReader, newContentUrl));
}
/**
* This operation has to be performed on all the stores in order to maintain the {@link ContentStore#exists(String)} contract.
*/
public boolean delete(String contentUrl) throws ContentIOException
{
boolean deleted = true;
List<ContentStore> stores = getAllStores();
for (ContentStore store : stores)
{
if (store.isWriteSupported())
{
deleted &= store.delete(contentUrl);
}
}
// Done
if (logger.isDebugEnabled())
{
logger.debug("Deleted content URL from stores: \n" +
" Stores: " + stores.size() + "\n" +
" Deleted: " + deleted);
}
return deleted;
}
/**
* {@inheritDoc}
*/
@Override
public Map<String, String> getStorageProperties(String contentUrl)
{
ContentStore contentStore = selectReadStore(contentUrl);
if (contentStore == null)
{
logNoContentStore(contentUrl);
return Collections.emptyMap();
}
final String message = "Getting storage properties from store: ";
logExecution(contentUrl, contentStore, message);
return contentStore.getStorageProperties(contentUrl);
}
/**
* {@inheritDoc}
*/
@Override
public boolean requestSendContentToArchive(String contentUrl, Map<String, Serializable> archiveParams)
{
final ContentStore contentStore = selectReadStore(contentUrl);
if (contentStore == null)
{
logNoContentStore(contentUrl);
return ContentStore.super.requestSendContentToArchive(contentUrl, archiveParams);
}
final String message = "Sending content to archive: ";
logExecution(contentUrl, contentStore, message);
return contentStore.requestSendContentToArchive(contentUrl, archiveParams);
}
/**
* {@inheritDoc}
*/
@Override
public boolean requestRestoreContentFromArchive(String contentUrl, Map<String, Serializable> restoreParams)
{
final ContentStore contentStore = selectReadStore(contentUrl);
if (contentStore == null)
{
logNoContentStore(contentUrl);
return ContentStore.super.requestRestoreContentFromArchive(contentUrl, restoreParams);
}
final String message = "Restoring content from archive: ";
logExecution(contentUrl, contentStore, message);
return contentStore.requestRestoreContentFromArchive(contentUrl, restoreParams);
}
private void logExecution(final String contentUrl, final ContentStore contentStore, final String message)
{
if (logger.isTraceEnabled())
{
logger.trace(message + "\n" +
" Content URL: " + contentUrl + "\n" +
" Store: " + contentStore);
}
}
private void logNoContentStore(String contentUrl)
{
if (logger.isTraceEnabled())
{
logger.trace("Content Store not found for content URL: " + contentUrl);
}
}
}

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2024 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -25,14 +25,15 @@
*/
package org.alfresco.repo.site;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import org.alfresco.api.AlfrescoPublicApi;
import org.alfresco.query.CannedQuerySortDetails;
import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.util.Pair;
import java.util.Comparator;
import java.util.List;
/**
* Conveys information for a member of a site.
*
@@ -52,7 +53,7 @@ public class SiteMembership extends AbstractSiteMembership
public SiteMembership(SiteInfo siteInfo, String id, String firstName, String lastName,
String role)
{
super(siteInfo,id, role);
super(siteInfo, id, role);
if (firstName == null)
{
throw new java.lang.IllegalArgumentException(
@@ -76,13 +77,8 @@ public class SiteMembership extends AbstractSiteMembership
throw new java.lang.IllegalArgumentException(
"FirstName required building site membership of " + siteInfo.getShortName());
}
if (lastName == null)
{
throw new java.lang.IllegalArgumentException(
"LastName required building site membership of " + siteInfo.getShortName());
}
this.firstName = firstName;
this.lastName = lastName;
this.lastName = Optional.ofNullable(lastName).orElse("");
this.isMemberOfGroup = isMemberOfGroup;
}
@@ -164,7 +160,6 @@ public class SiteMembership extends AbstractSiteMembership
", isMemberOfGroup = " + isMemberOfGroup + "]";
}
static int compareTo(List<Pair<? extends Object, CannedQuerySortDetails.SortOrder>> sortPairs, SiteMembership o1, SiteMembership o2)
{
String personId1 = o1.getPersonId();