mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-01 14:41:46 +00:00
TEST ONLY - TenantRoutingFileContentStore with DAU returned
This commit is contained in:
@@ -23,34 +23,38 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.repo.tenant;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.content.ContentLimitProvider;
|
||||
import org.alfresco.repo.content.ContentLimitProvider.NoLimitProvider;
|
||||
import org.alfresco.repo.content.ContentStore;
|
||||
package org.alfresco.repo.tenant;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.content.ContentLimitProvider;
|
||||
import org.alfresco.repo.content.ContentLimitProvider.NoLimitProvider;
|
||||
import org.alfresco.repo.content.ContentStore;
|
||||
import org.alfresco.repo.content.filestore.FileContentStore;
|
||||
import org.alfresco.repo.content.filestore.FileContentUrlProvider;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
* MT-aware File Content Store
|
||||
*/
|
||||
public class TenantRoutingFileContentStore extends AbstractTenantRoutingContentStore
|
||||
{
|
||||
import org.alfresco.service.cmr.repository.DirectAccessUrl;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
* MT-aware File Content Store
|
||||
*/
|
||||
public class TenantRoutingFileContentStore extends AbstractTenantRoutingContentStore
|
||||
{
|
||||
private ContentLimitProvider contentLimitProvider = new NoLimitProvider();
|
||||
private FileContentUrlProvider fileContentUrlProvider;
|
||||
|
||||
/**
|
||||
* Sets a new {@link ContentLimitProvider} which will provide a maximum filesize for content.
|
||||
*/
|
||||
public void setContentLimitProvider(ContentLimitProvider contentLimitProvider)
|
||||
{
|
||||
this.contentLimitProvider = contentLimitProvider;
|
||||
private FileContentUrlProvider fileContentUrlProvider;
|
||||
|
||||
/**
|
||||
* Sets a new {@link ContentLimitProvider} which will provide a maximum filesize for content.
|
||||
*/
|
||||
public void setContentLimitProvider(ContentLimitProvider contentLimitProvider)
|
||||
{
|
||||
this.contentLimitProvider = contentLimitProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,28 +63,53 @@ public class TenantRoutingFileContentStore extends AbstractTenantRoutingContentS
|
||||
public void setFileContentUrlProvider(FileContentUrlProvider fileContentUrlProvider)
|
||||
{
|
||||
this.fileContentUrlProvider = fileContentUrlProvider;
|
||||
}
|
||||
|
||||
protected ContentStore initContentStore(ApplicationContext ctx, String contentRoot)
|
||||
{
|
||||
Map<String, Serializable> extendedEventParams = new HashMap<String, Serializable>();
|
||||
if (!TenantService.DEFAULT_DOMAIN.equals(tenantService.getCurrentUserDomain()))
|
||||
{
|
||||
extendedEventParams.put("Tenant", tenantService.getCurrentUserDomain());
|
||||
}
|
||||
|
||||
FileContentStore fileContentStore = new FileContentStore(ctx, new File(contentRoot), extendedEventParams);
|
||||
|
||||
// Set the content filesize limiter if there is one.
|
||||
if (this.contentLimitProvider != null)
|
||||
{
|
||||
fileContentStore.setContentLimitProvider(contentLimitProvider);
|
||||
}
|
||||
}
|
||||
|
||||
protected ContentStore initContentStore(ApplicationContext ctx, String contentRoot)
|
||||
{
|
||||
Map<String, Serializable> extendedEventParams = new HashMap<String, Serializable>();
|
||||
if (!TenantService.DEFAULT_DOMAIN.equals(tenantService.getCurrentUserDomain()))
|
||||
{
|
||||
extendedEventParams.put("Tenant", tenantService.getCurrentUserDomain());
|
||||
}
|
||||
|
||||
FileContentStore fileContentStore = new FileContentStore(ctx, new File(contentRoot), extendedEventParams);
|
||||
|
||||
// Set the content filesize limiter if there is one.
|
||||
if (this.contentLimitProvider != null)
|
||||
{
|
||||
fileContentStore.setContentLimitProvider(contentLimitProvider);
|
||||
}
|
||||
|
||||
if(fileContentUrlProvider != null)
|
||||
{
|
||||
fileContentStore.setFileContentUrlProvider(fileContentUrlProvider);
|
||||
}
|
||||
return fileContentStore;
|
||||
}
|
||||
}
|
||||
}
|
||||
return fileContentStore;
|
||||
}
|
||||
|
||||
// TODO: remove these temp methods
|
||||
@Override
|
||||
public boolean isContentDirectUrlEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isContentDirectUrlEnabled(NodeRef nodeRef)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectAccessUrl requestContentDirectUrl(String contentUrl, boolean attachment, String fileName, Long validFor)
|
||||
{
|
||||
DirectAccessUrl directAccessUrl = new DirectAccessUrl();
|
||||
directAccessUrl.setContentUrl(contentUrl);
|
||||
directAccessUrl.setAttachment(attachment);
|
||||
Date expiryTime = Date.from(Instant.now().plusSeconds(validFor));
|
||||
directAccessUrl.setExpiryTime(expiryTime);
|
||||
|
||||
return directAccessUrl;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user