mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-01 14:41:46 +00:00
ACS-1582 : Storage classes - java api (#467)
* ACS-1582 : Storage classes - java api - added ContentContext updates - added StorageClasses related exception
This commit is contained in:
committed by
Andrea Ligios
parent
9e7c3f3502
commit
0b840643f9
@@ -26,6 +26,7 @@
|
||||
package org.alfresco.repo.content;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
|
||||
@@ -49,6 +50,7 @@ public class ContentContext implements Serializable
|
||||
|
||||
private ContentReader existingContentReader;
|
||||
private String contentUrl;
|
||||
private Set<String> storageClasses;
|
||||
|
||||
/**
|
||||
* Construct the instance with the content URL.
|
||||
@@ -88,5 +90,22 @@ public class ContentContext implements Serializable
|
||||
{
|
||||
return contentUrl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the storage classes for the content- may be <tt>null</tt>
|
||||
*/
|
||||
public Set<String> getStorageClasses()
|
||||
{
|
||||
return storageClasses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the storage classes for the content- may be <tt>null</tt>
|
||||
*
|
||||
* @param storageClasses
|
||||
*/
|
||||
public void setStorageClasses(Set<String> storageClasses)
|
||||
{
|
||||
this.storageClasses = storageClasses;
|
||||
}
|
||||
}
|
||||
|
@@ -25,6 +25,11 @@
|
||||
*/
|
||||
package org.alfresco.repo.content;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.api.AlfrescoPublicApi;
|
||||
import org.alfresco.service.cmr.repository.ContentAccessor;
|
||||
import org.alfresco.service.cmr.repository.ContentIOException;
|
||||
@@ -33,8 +38,6 @@ import org.alfresco.service.cmr.repository.ContentStreamListener;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.DirectAccessUrl;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Provides low-level retrieval of content
|
||||
* {@link org.alfresco.service.cmr.repository.ContentReader readers} and
|
||||
@@ -88,6 +91,16 @@ public interface ContentStore
|
||||
* The delimiter that must be found in all URLS, i.e <b>://</b>
|
||||
*/
|
||||
public static final String PROTOCOL_DELIMITER = "://";
|
||||
|
||||
/**
|
||||
* The 'default' storage class
|
||||
*
|
||||
* A content is considered to have a default storage class if:
|
||||
* the value is a Set.of("default")
|
||||
* the value is an empty set
|
||||
* the value is null
|
||||
*/
|
||||
public static final String DEFAULT_SC = "default";
|
||||
|
||||
/**
|
||||
* Check if the content URL format is supported by the store.
|
||||
@@ -263,4 +276,64 @@ public interface ContentStore
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return true if the storage classes are supported, false otherwise.
|
||||
*/
|
||||
default boolean isStorageClassesSupported(Set<String> storageClasses)
|
||||
{
|
||||
return storageClasses == null ||
|
||||
storageClasses.isEmpty() ||
|
||||
(1 == storageClasses.size() && storageClasses.contains(DEFAULT_SC));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the complete {@link Set} of supported storage classes by this {@link ContentStore}
|
||||
*/
|
||||
default Set<String> getSupportedStorageClasses()
|
||||
{
|
||||
return Set.of(DEFAULT_SC);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 parameters extra parameters
|
||||
*/
|
||||
default void updateStorageClasses(String contentUrl, Set<String> storageClasses, Map<String, Object> parameters)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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()
|
||||
{
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Data model classes
|
||||
* %%
|
||||
* 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.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
|
||||
/**
|
||||
* Thrown when an operation regarding the storage classes of the content failed to execute.
|
||||
*
|
||||
* @author Lucian Tuca
|
||||
*/
|
||||
public class UnsupportedStorageClassException extends AlfrescoRuntimeException
|
||||
{
|
||||
private final ContentStore contentStore;
|
||||
private final Set<String> storageClasses;
|
||||
|
||||
public UnsupportedStorageClassException(ContentStore contentStore, Set<String> storageClasses, String msg)
|
||||
{
|
||||
super(msg);
|
||||
this.contentStore = contentStore;
|
||||
this.storageClasses = storageClasses;
|
||||
}
|
||||
|
||||
public ContentStore getContentStore()
|
||||
{
|
||||
return contentStore;
|
||||
}
|
||||
|
||||
public Set<String> getStorageClasses()
|
||||
{
|
||||
return storageClasses;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user