mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
ACS-2147 renaming method which gets storage props (#778)
* ACS-2147: Adding missing ContentStore implementation, switching some logging to trace. * ACS-2147: Renaming getObjectStorageProperties to getStorageProperties * [maven-release-plugin][skip ci] prepare release 14.20 * [maven-release-plugin][skip ci] prepare for next development iteration * Fix/mnt 21506 sanitation create people (#756) * MNT-21506: sanitize username on nodeBrowser Repo * [maven-release-plugin][skip ci] prepare release 14.21 * [maven-release-plugin][skip ci] prepare for next development iteration * ACS-2148: Adding get StorageObjectProps to ContentService (#773) * ACS-2148: Adding get StorageObjectProps to ContentService and implementation. * ACS-2148: Adding propertyQName param to get storage property method. * ACS-2148: Security config for added method. * ACS-2148: Renaming getObjectStorageProperties to getStorageProperties * ACS-2148: Javadoc fix * ACS-2148: Fixing security context after method renaming. * ACS-2148: ContentService with new method names. * ACS-2147: Adding missing ContentStore implementation, switching some logging to trace. * ACS-2147: Renaming getObjectStorageProperties to getStorageProperties * ACS-2148: ContentService with new method names. * ACS-2148: Small fixes after code review.
This commit is contained in:
@@ -340,7 +340,7 @@ public interface ContentStore
|
||||
* @return Returns a key-value (String-String) collection of storage headers/properties with their respective values.
|
||||
*/
|
||||
@Experimental
|
||||
default Map<String, String> getObjectStorageProperties(String contentUrl)
|
||||
default Map<String, String> getStorageProperties(String contentUrl)
|
||||
{
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
@@ -422,21 +422,21 @@ public abstract class AbstractRoutingContentStore implements ContentStore
|
||||
|
||||
@Override
|
||||
@Experimental
|
||||
public Map<String, String> getObjectStorageProperties(String contentUrl) {
|
||||
public Map<String, String> getStorageProperties(String contentUrl) {
|
||||
ContentStore contentStore = selectReadStore(contentUrl);
|
||||
|
||||
if (contentStore == null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Storage properties not found for content URL: " + contentUrl);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Storage properties not found for content URL: " + contentUrl);
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Getting storage properties from store: \n" +
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Getting storage properties from store: \n" +
|
||||
" Content URL: " + contentUrl + "\n" +
|
||||
" Store: " + contentStore);
|
||||
}
|
||||
return contentStore.getObjectStorageProperties(contentUrl);
|
||||
|
||||
return contentStore.getStorageProperties(contentUrl);
|
||||
}
|
||||
}
|
||||
|
@@ -664,7 +664,7 @@ public class ContentServiceImpl implements ContentService, ApplicationContextAwa
|
||||
throw new IllegalArgumentException("The supplied nodeRef " + nodeRef + " and property name: " + propertyQName + " has no content.");
|
||||
}
|
||||
|
||||
return store.getObjectStorageProperties(contentData.getContentUrl());
|
||||
return store.getStorageProperties(contentData.getContentUrl());
|
||||
}
|
||||
|
||||
protected String getFileName(NodeRef nodeRef)
|
||||
|
@@ -384,9 +384,9 @@ public class CachingContentStore implements ContentStore, ApplicationEventPublis
|
||||
|
||||
@Override
|
||||
@Experimental
|
||||
public Map<String, String> getObjectStorageProperties(final String contentUrl)
|
||||
public Map<String, String> getStorageProperties(final String contentUrl)
|
||||
{
|
||||
return backingStore.getObjectStorageProperties(contentUrl);
|
||||
return backingStore.getStorageProperties(contentUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -407,7 +407,7 @@ public class AggregatingContentStore extends AbstractContentStore
|
||||
|
||||
@Override
|
||||
@Experimental
|
||||
public Map<String, String> getObjectStorageProperties(String contentUrl)
|
||||
public Map<String, String> getStorageProperties(String contentUrl)
|
||||
{
|
||||
if (primaryStore == null) {
|
||||
throw new AlfrescoRuntimeException(REPLICATING_CONTENT_STORE_NOT_INITIALISED);
|
||||
@@ -419,7 +419,7 @@ public class AggregatingContentStore extends AbstractContentStore
|
||||
Optional<Map<String, String>> objectStoragePropertiesMap = Optional.empty();
|
||||
// Check the primary store
|
||||
try {
|
||||
objectStoragePropertiesMap = Optional.of(primaryStore.getObjectStorageProperties(contentUrl));
|
||||
objectStoragePropertiesMap = Optional.of(primaryStore.getStorageProperties(contentUrl));
|
||||
} catch (UnsupportedContentUrlException e) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Primary store could not handle content URL: " + contentUrl);
|
||||
@@ -429,7 +429,7 @@ public class AggregatingContentStore extends AbstractContentStore
|
||||
if (objectStoragePropertiesMap.isEmpty()) {// the content is not in the primary store so we have to go looking for it
|
||||
for (ContentStore store : secondaryStores) {
|
||||
try {
|
||||
objectStoragePropertiesMap = Optional.of(store.getObjectStorageProperties(contentUrl));
|
||||
objectStoragePropertiesMap = Optional.of(store.getStorageProperties(contentUrl));
|
||||
} catch (UnsupportedContentUrlException e) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Secondary store " + store + " could not handle content URL: " + contentUrl);
|
||||
|
@@ -1,51 +1,52 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 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%
|
||||
*/
|
||||
/*
|
||||
* #%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.tenant;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
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.repo.content.AbstractRoutingContentStore;
|
||||
import org.alfresco.repo.content.ContentContext;
|
||||
import org.alfresco.repo.content.ContentStore;
|
||||
import org.alfresco.repo.domain.tenant.TenantAdminDAO;
|
||||
import org.alfresco.repo.domain.tenant.TenantEntity;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
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.repo.content.AbstractRoutingContentStore;
|
||||
import org.alfresco.repo.content.ContentContext;
|
||||
import org.alfresco.repo.content.ContentStore;
|
||||
import org.alfresco.repo.domain.tenant.TenantAdminDAO;
|
||||
import org.alfresco.repo.domain.tenant.TenantEntity;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.Experimental;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
|
||||
/**
|
||||
* Content Store that supports tenant routing, if multi-tenancy is enabled.
|
||||
@@ -270,6 +271,13 @@ public abstract class AbstractTenantRoutingContentStore extends AbstractRoutingC
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Experimental
|
||||
@Override
|
||||
public Map<String, String> getStorageProperties(String contentUrl)
|
||||
{
|
||||
return getTenantContentStore().getStorageProperties(contentUrl);
|
||||
}
|
||||
|
||||
protected abstract ContentStore initContentStore(ApplicationContext ctx, String contentRoot);
|
||||
}
|
||||
|
@@ -168,7 +168,7 @@ public class ContentServiceImplUnitTest
|
||||
public void shouldReturnStoragePropertiesWhenTheyExist()
|
||||
{
|
||||
final Map<String, String> storageObjectPropsMap = Map.of(X_AMZ_HEADER_1, VALUE_1, X_AMZ_HEADER_2, VALUE_2);
|
||||
when(mockContentStore.getObjectStorageProperties(SOME_CONTENT_URL)).thenReturn(storageObjectPropsMap);
|
||||
when(mockContentStore.getStorageProperties(SOME_CONTENT_URL)).thenReturn(storageObjectPropsMap);
|
||||
|
||||
final Map<String, String> objectStorageProperties = contentService.getStorageProperties(NODE_REF, ContentModel.PROP_CONTENT);
|
||||
assertFalse(objectStorageProperties.isEmpty());
|
||||
@@ -178,7 +178,7 @@ public class ContentServiceImplUnitTest
|
||||
@Test
|
||||
public void shouldReturnEmptyStoragePropertiesWhenTheyDontExist()
|
||||
{
|
||||
when(mockContentStore.getObjectStorageProperties(SOME_CONTENT_URL)).thenReturn(Collections.emptyMap());
|
||||
when(mockContentStore.getStorageProperties(SOME_CONTENT_URL)).thenReturn(Collections.emptyMap());
|
||||
|
||||
final Map<String, String> objectStorageProperties = contentService.getStorageProperties(NODE_REF, ContentModel.PROP_CONTENT);
|
||||
assertTrue(objectStorageProperties.isEmpty());
|
||||
|
@@ -528,8 +528,8 @@ public class CachingContentStoreTest
|
||||
{
|
||||
final Map<String, String> propertiesMap = Map.of("x-amz-header1", "value1", "x-amz-header2", "value2");
|
||||
final String contentUrl = "url";
|
||||
when(backingStore.getObjectStorageProperties(contentUrl)).thenReturn(propertiesMap);
|
||||
final Map<String, String> storageProperties = cachingStore.getObjectStorageProperties(contentUrl);
|
||||
when(backingStore.getStorageProperties(contentUrl)).thenReturn(propertiesMap);
|
||||
final Map<String, String> storageProperties = cachingStore.getStorageProperties(contentUrl);
|
||||
assertFalse(storageProperties.isEmpty());
|
||||
assertEquals(propertiesMap, storageProperties);
|
||||
}
|
||||
@@ -537,7 +537,7 @@ public class CachingContentStoreTest
|
||||
@Test
|
||||
public void shouldReturnEmptyStorageProperties()
|
||||
{
|
||||
Map<String, String> storageProperties = cachingStore.getObjectStorageProperties("url");
|
||||
Map<String, String> storageProperties = cachingStore.getStorageProperties("url");
|
||||
assertTrue(storageProperties.isEmpty());
|
||||
}
|
||||
}
|
||||
|
@@ -321,13 +321,13 @@ public class AggregatingContentStoreTest extends AbstractWritableContentStoreTes
|
||||
{
|
||||
final String contentUrl = "url";
|
||||
final Map<String, String> primaryStorePropertiesMap = Map.of(X_AMZ_HEADER_1, VALUE_1, X_AMZ_HEADER_2, VALUE_2);;
|
||||
when(primaryStoreMock.getObjectStorageProperties(contentUrl)).thenReturn(primaryStorePropertiesMap);
|
||||
when(primaryStoreMock.getStorageProperties(contentUrl)).thenReturn(primaryStorePropertiesMap);
|
||||
|
||||
final Map<String, String> storageProperties = aggregatingStore.getObjectStorageProperties(contentUrl);
|
||||
final Map<String, String> storageProperties = aggregatingStore.getStorageProperties(contentUrl);
|
||||
|
||||
assertFalse(storageProperties.isEmpty());
|
||||
assertEquals(primaryStorePropertiesMap, storageProperties);
|
||||
verify(secondaryStoreMock, times(0)).getObjectStorageProperties(contentUrl);
|
||||
verify(secondaryStoreMock, times(0)).getStorageProperties(contentUrl);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -335,29 +335,29 @@ public class AggregatingContentStoreTest extends AbstractWritableContentStoreTes
|
||||
{
|
||||
final String contentUrl = "url";
|
||||
final Map<String, String> secondaryStorePropertiesMap = Map.of(X_AMZ_HEADER_1, VALUE_1, X_AMZ_HEADER_2, VALUE_2);;
|
||||
when(primaryStoreMock.getObjectStorageProperties(contentUrl)).thenReturn(Collections.emptyMap());
|
||||
when(secondaryStoreMock.getObjectStorageProperties(contentUrl)).thenReturn(secondaryStorePropertiesMap);
|
||||
when(primaryStoreMock.getStorageProperties(contentUrl)).thenReturn(Collections.emptyMap());
|
||||
when(secondaryStoreMock.getStorageProperties(contentUrl)).thenReturn(secondaryStorePropertiesMap);
|
||||
|
||||
final Map<String, String> storageProperties = aggregatingStore.getObjectStorageProperties(contentUrl);
|
||||
final Map<String, String> storageProperties = aggregatingStore.getStorageProperties(contentUrl);
|
||||
|
||||
assertFalse(storageProperties.isEmpty());
|
||||
assertEquals(secondaryStorePropertiesMap, storageProperties);
|
||||
verify(secondaryStoreMock, times(1)).getObjectStorageProperties(contentUrl);
|
||||
verify(primaryStoreMock, times(1)).getObjectStorageProperties(contentUrl);
|
||||
verify(secondaryStoreMock, times(1)).getStorageProperties(contentUrl);
|
||||
verify(primaryStoreMock, times(1)).getStorageProperties(contentUrl);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnEmptyStorageProperties()
|
||||
{
|
||||
final String contentUrl = "url";
|
||||
when(primaryStoreMock.getObjectStorageProperties(contentUrl)).thenReturn(Collections.emptyMap());
|
||||
when(secondaryStoreMock.getObjectStorageProperties(contentUrl)).thenReturn(Collections.emptyMap());
|
||||
when(primaryStoreMock.getStorageProperties(contentUrl)).thenReturn(Collections.emptyMap());
|
||||
when(secondaryStoreMock.getStorageProperties(contentUrl)).thenReturn(Collections.emptyMap());
|
||||
|
||||
final Map<String, String> storageProperties = aggregatingStore.getObjectStorageProperties(contentUrl);
|
||||
final Map<String, String> storageProperties = aggregatingStore.getStorageProperties(contentUrl);
|
||||
|
||||
assertTrue(storageProperties.isEmpty());
|
||||
verify(secondaryStoreMock, times(1)).getObjectStorageProperties(contentUrl);
|
||||
verify(primaryStoreMock, times(1)).getObjectStorageProperties(contentUrl);
|
||||
verify(secondaryStoreMock, times(1)).getStorageProperties(contentUrl);
|
||||
verify(primaryStoreMock, times(1)).getStorageProperties(contentUrl);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user