ACS-1711 : [SPIKE] Update the S3 connector to support Storage Classes (#559)

- update the storage class representation
This commit is contained in:
Lucian Tuca
2021-06-29 11:30:03 +03:00
committed by Andrea Ligios
parent 1c915e4fb0
commit cf14112626
19 changed files with 193 additions and 137 deletions

View File

@@ -92,6 +92,10 @@ public interface ContentStore
*/
public static final String PROTOCOL_DELIMITER = "://";
public static final String STORAGE_CLASS_DEFAULT = "default";
public static final String STORAGE_CLASS_ARCHIVE = "archive";
public static final String STORAGE_CLASS_WORM = "worm";
/**
* The 'default' storage class
*
@@ -100,8 +104,10 @@ public interface ContentStore
* the value is an empty set
* the value is null
*/
public static final String DEFAULT_SC = "default";
public static final StorageClassSet SCS_DEFAULT = new StorageClassSet(STORAGE_CLASS_DEFAULT);
public static final StorageClassSet SCS_ARCHIVE = new StorageClassSet(STORAGE_CLASS_ARCHIVE);
public static final StorageClassSet SCS_WORM = new StorageClassSet(STORAGE_CLASS_WORM);
/**
* Check if the content URL format is supported by the store.
*
@@ -280,14 +286,14 @@ public interface ContentStore
/**
* Checks whether or not the current {@link ContentStore} supports the provided {@link Set} storage classes
*
* @param storageClasses The storage classes that will be checked whether or not are supported
* @param storageClassSet The storage classes that will be checked whether or not are supported
* @return true if the storage classes are supported, false otherwise.
*/
default boolean isStorageClassesSupported(Set<String> storageClasses)
default boolean isStorageClassesSupported(StorageClassSet storageClassSet)
{
return storageClasses == null ||
storageClasses.isEmpty() ||
(1 == storageClasses.size() && storageClasses.contains(DEFAULT_SC));
return storageClassSet == null ||
storageClassSet.isEmpty() ||
(1 == storageClassSet.size() && storageClassSet.equals(SCS_DEFAULT));
}
/**
@@ -295,17 +301,18 @@ public interface ContentStore
*/
default Set<String> getSupportedStorageClasses()
{
return Set.of(DEFAULT_SC);
return Set.of(ContentStore.STORAGE_CLASS_DEFAULT);
}
/**
* Updates the storage class for content
*
* @param contentUrl The URL of the content that will have its storage classes updated
* @param storageClasses The new storage classes
* @param storageClassSet The new storage class
* @param parameters extra parameters
*/
default void updateStorageClasses(String contentUrl, Set<String> storageClasses, Map<String, Object> parameters)
default void updateStorageClasses(String contentUrl, StorageClassSet storageClassSet, Map<String, Object> parameters)
{
}
@@ -314,16 +321,16 @@ public interface ContentStore
* @param contentUrl the URL of the content for which the storage classes are to be requested
* @return Returns the current storage classes for the content found at the contentUrl
*/
default Set<String> findStorageClasses(String contentUrl)
default StorageClassSet findStorageClasses(String contentUrl)
{
return Set.of(DEFAULT_SC);
return SCS_DEFAULT;
}
/**
* @return Returns the complete collection of allowed storage classes transitions.
* The key represents the source storage classes while the value (as a {@link Set}) represents all the possible target storage classes.
*/
default Map<Set<String>, Set<Set<String>>> getStorageClassesTransitions()
default Map<StorageClassSet, Set<StorageClassSet>> getStorageClassesTransitions()
{
return Collections.emptyMap();
}
@@ -332,7 +339,7 @@ public interface ContentStore
* @param contentUrl the URL of the content for which the storage classes transitions are to be requested
* @return Returns the complete collection of allowed storage classes transitions for the content found at content URL
*/
default Map<Set<String>, Set<Set<String>>> findStorageClassesTransitions(String contentUrl)
default Map<StorageClassSet, Set<StorageClassSet>> findStorageClassesTransitions(String contentUrl)
{
return Collections.emptyMap();
}

View File

@@ -0,0 +1,45 @@
/*
* #%L
* Alfresco Data model classes
* %%
* 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%
*/
package org.alfresco.repo.content;
import java.util.Collections;
import java.util.HashSet;
/**
* Represents the state of the content and it is internally represented as a set.
* It can have none, one, or multiple storage classes to specify the state
* e.g. [default], [archive], [archive, encrypted]
*
* @author Lucian Tuca
*/
public class StorageClassSet extends HashSet<String>
{
public StorageClassSet(String... storageClasses)
{
super();
Collections.addAll(this, storageClasses);
}
}