org.alfresco.repo.content.ContentStore Java Examples

The following examples show how to use org.alfresco.repo.content.ContentStore. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SiteRoutingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
/**
 *
 * {@inheritDoc}
 */
@Override
protected ContentStore selectStoreForContentDataMove(final NodeRef nodeRef, final QName propertyQName, final ContentData contentData,
        final Void customData)
{
    ContentStore targetStore = this.selectStoreForCurrentContext();
    if (targetStore == null)
    {
        LOGGER.debug(
                "Store-specific logic could not select a store to move {} in current context - delegating to super.selectStoreForContentDataMove",
                contentData);
        targetStore = super.selectStoreForContentDataMove(nodeRef, propertyQName, contentData, customData);
    }

    return targetStore;
}
 
Example #2
Source File: CompressingContentWriter.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
protected CompressingContentWriter(final String contentUrl, final ContentContext context, final ContentStore temporaryContentStore,
        final ContentWriter backingWriter, final String compressionType, final Collection<String> mimetypesToCompress)
{
    super(backingWriter.getContentUrl() != null ? backingWriter.getContentUrl() : context.getContentUrl(),
            context.getExistingContentReader());

    ParameterCheck.mandatory("context", context);
    ParameterCheck.mandatory("temporaryContentStore", temporaryContentStore);
    ParameterCheck.mandatory("backingWriter", backingWriter);

    this.context = context;
    this.temporaryContentStore = temporaryContentStore;
    this.backingWriter = backingWriter;

    this.compressionType = compressionType;
    this.mimetypesToCompress = mimetypesToCompress;

    // we are the first real listener (DoGuessingOnCloseListener always is first)
    super.addListener(this);

    final ContentContext temporaryContext = new ContentContext(context.getExistingContentReader(), null);
    this.temporaryWriter = this.temporaryContentStore.getWriter(temporaryContext);
}
 
Example #3
Source File: TypeRoutingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
/**
 *
 * {@inheritDoc}
 */
@Override
protected ContentStore selectStoreForContentDataMove(final NodeRef nodeRef, final QName propertyQName, final ContentData contentData,
        final Void customData)
{
    final QName nodeTypeQName = this.nodeService.getType(nodeRef);
    ContentStore targetStore = this.resolveStoreForType(nodeRef, nodeTypeQName);
    if (targetStore == null)
    {
        LOGGER.debug("Store-specific logic could not select a store to move {} - delegating to super.selectStoreForContentDataMove",
                contentData);
        targetStore = super.selectStoreForContentDataMove(nodeRef, propertyQName, contentData, customData);
    }

    return targetStore;
}
 
Example #4
Source File: MoveCapableCommonRoutingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
/**
 *
 * {@inheritDoc}
 */
@Override
public boolean isContentUrlSupported(final String contentUrl)
{
    final List<ContentStore> stores = this.getAllStores();
    boolean supported = false;
    for (final ContentStore store : stores)
    {
        if (store.isContentUrlSupported(contentUrl))
        {
            supported = true;
            break;
        }
    }

    LOGGER.debug("The url {} {} supported by at least one store", contentUrl, (supported ? "is" : "is not"));

    return supported;
}
 
Example #5
Source File: SelectorPropertyContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
/**
 *
 * {@inheritDoc}
 */
@Override
protected ContentStore selectStoreForContentDataMove(final NodeRef nodeRef, final QName propertyQName, final ContentData contentData,
        final Serializable selectorValue)
{
    ContentStore targetStore;
    if (this.storeBySelectorPropertyValue.containsKey(selectorValue))
    {
        LOGGER.debug("Selecting store for value {} to move {}", selectorValue, contentData);
        targetStore = this.storeBySelectorPropertyValue.get(selectorValue);
    }
    else
    {
        LOGGER.debug("No store registered for value {} - delegating to super.selectStoreForContentDataMove to move {}", selectorValue,
                contentData);
        targetStore = super.selectStoreForContentDataMove(nodeRef, propertyQName, contentData, selectorValue);
    }
    return targetStore;
}
 
Example #6
Source File: FilesystemSourceUtils.java    From alfresco-bulk-import with Apache License 2.0 6 votes vote down vote up
/**
 * Determines whether the given file is already located in an Alfresco managed content store.  Used to determine
 * whether to perform a streaming or in-place import.
 * 
 * @param contentStore The content store Alfresco is configured to use <i>(must not be null)</i>.
 * @param source The file to test.  Typically this would be the source directory for the import <i>(must not be null)</i>.
 * @return True if the given file is in an Alfresco managed content store, false otherwise.
 */
public final static boolean isInContentStore(final ContentStore contentStore, final File source)
{
    boolean      result           = false;
    final String contentStoreRoot = contentStore.getRootLocation();
    
    if (contentStoreRoot != null && contentStoreRoot.trim().length() > 0)
    {
        final File contentStoreRootFile = new File(contentStoreRoot);
        
        // If the content store root doesn't exist as a file, we're probably dealing with a non-filesystem content store
        if (contentStoreRootFile.exists() && contentStoreRootFile.isDirectory())
        {
            result = isInDirectory(contentStoreRoot, source.getAbsolutePath());
        }
    }

    return(result);
}
 
Example #7
Source File: SelectorPropertyContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
private void afterPropertiesSet_setupStoreData()
{
    PropertyCheck.mandatory(this, "storeBySelectorPropertyValue", this.storeBySelectorPropertyValue);
    if (this.storeBySelectorPropertyValue.isEmpty())
    {
        throw new IllegalStateException("No stores have been defined for property values");
    }

    this.allStores = new ArrayList<>();
    for (final ContentStore store : this.storeBySelectorPropertyValue.values())
    {
        if (!this.allStores.contains(store))
        {
            this.allStores.add(store);
        }
    }

    if (!this.allStores.contains(this.fallbackStore))
    {
        this.allStores.add(this.fallbackStore);
    }
}
 
Example #8
Source File: DeduplicatingContentWriter.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
protected String makeContentUrl(final String digest)
{
    final StringBuilder contentUrlBuilder = new StringBuilder();

    contentUrlBuilder.append(StoreConstants.WILDCARD_PROTOCOL);
    contentUrlBuilder.append(ContentStore.PROTOCOL_DELIMITER);

    final int charsPerByte = this.bytesPerPathSegment * 2;
    for (int segment = 0, digestLength = digest.length(); segment < this.pathSegments
            && digestLength >= (segment + 1) * charsPerByte; segment++)
    {
        final String digestFragment = digest.substring(segment * charsPerByte, (segment + 1) * charsPerByte);
        contentUrlBuilder.append(digestFragment);
        contentUrlBuilder.append('/');
    }

    contentUrlBuilder.append(digest);
    contentUrlBuilder.append(".bin");

    return contentUrlBuilder.toString();
}
 
Example #9
Source File: SiteRoutingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
/**
 *
 * {@inheritDoc}
 */
@Override
public boolean isContentUrlSupported(final String contentUrl)
{
    // optimisation: check the likely candidate store based on context first
    final ContentStore storeForCurrentContext = this.selectStoreForCurrentContext();

    boolean supported = false;
    if (storeForCurrentContext != null)
    {
        LOGGER.debug("Preferentially using store for current context to check support for content URL {}", contentUrl);
        supported = storeForCurrentContext.isContentUrlSupported(contentUrl);
    }

    if (!supported)
    {
        LOGGER.debug("Delegating to super implementation to check support for content URL {}", contentUrl);
        supported = super.isContentUrlSupported(contentUrl);
    }
    return supported;
}
 
Example #10
Source File: MoveCapableCommonRoutingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
/**
 *
 * {@inheritDoc}
 */
@Override
public boolean delete(final String contentUrl) throws ContentIOException
{
    boolean deleted = true;
    final List<ContentStore> stores = this.getAllStores();

    /*
     * This operation has to be performed on all the stores in order to maintain the
     * {@link ContentStore#exists(String)} contract.
     * Still need to apply the isContentUrlSupported guard though.
     */
    for (final ContentStore store : stores)
    {
        if (store.isContentUrlSupported(contentUrl) && store.isWriteSupported())
        {
            deleted &= store.delete(contentUrl);
        }
    }

    LOGGER.debug("Deleted content URL from stores: \n\tStores:  {}\n\tDeleted: {}", stores.size(), deleted);

    return deleted;
}
 
Example #11
Source File: SiteRoutingFileContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
/**
 *
 * {@inheritDoc}
 */
@Override
public boolean isWriteSupported()
{
    // optimisation: check the likely candidate store based on context first
    final ContentStore storeForCurrentContext = this.selectStoreForCurrentContext();

    boolean supported = false;
    if (storeForCurrentContext != null)
    {
        LOGGER.debug("Preferentially using store for current context to check write suport");
        supported = storeForCurrentContext.isWriteSupported();
    }

    if (!supported)
    {
        LOGGER.debug("Delegating to super implementation to check write support");
        supported = super.isWriteSupported();
    }
    return supported;
}
 
Example #12
Source File: ContentStoreCleanerScalabilityRunner.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void clean()
{
    ContentStoreCleanerListener listener = new ContentStoreCleanerListener()
    {
        private int count = 0;
        public void beforeDelete(ContentStore store, String contentUrl) throws ContentIOException
        {
            count++;
            if (count % 1000 == 0)
            {
                System.out.println(String.format("   Total deleted: %6d", count));
            }
        }
    };
    // We use the default cleaners, but fix them up a bit
    EagerContentStoreCleaner eagerCleaner = (EagerContentStoreCleaner) ctx.getBean("eagerContentStoreCleaner");
    eagerCleaner.setListeners(Collections.singletonList(listener));
    eagerCleaner.setStores(Collections.singletonList(contentStore));
    cleaner = (ContentStoreCleaner) ctx.getBean("contentStoreCleaner");
    cleaner.setProtectDays(0);
    
    // The cleaner has its own txns
    cleaner.execute();
}
 
Example #13
Source File: FileContentStoreTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Checks that the store disallows concurrent writers to be issued to the same URL.
 */
@SuppressWarnings("unused")
@Test
public void testConcurrentWriteDetection() throws Exception
{
    ByteBuffer buffer = ByteBuffer.wrap("Something".getBytes());
    ContentStore store = getStore();

    ContentContext firstContentCtx = ContentStore.NEW_CONTENT_CONTEXT;
    ContentWriter firstWriter = store.getWriter(firstContentCtx);
    String contentUrl = firstWriter.getContentUrl();

    ContentContext secondContentCtx = new ContentContext(null, contentUrl);
    try
    {
        ContentWriter secondWriter = store.getWriter(secondContentCtx);
        fail("Store must disallow more than one writer onto the same content URL: " + store);
    }
    catch (ContentExistsException e)
    {
        // expected
    }
}
 
Example #14
Source File: TenantRoutingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
/**
 *
 * {@inheritDoc}
 */
@Override
protected List<ContentStore> getAllStores()
{
    final List<ContentStore> stores = new ArrayList<>();
    if (!TenantUtil.isCurrentDomainDefault())
    {
        final String currentDomain = TenantUtil.getCurrentDomain();
        final ContentStore tenantStore = this.storeByTenant.get(currentDomain);
        if (tenantStore != null)
        {
            stores.add(tenantStore);
        }
    }
    stores.add(this.fallbackStore);

    return stores;
}
 
Example #15
Source File: TypeRoutingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void onSetNodeType(final NodeRef nodeRef, final QName oldType, final QName newType)
{
    if (StoreRef.STORE_REF_WORKSPACE_SPACESSTORE.equals(nodeRef.getStoreRef()))
    {
        LOGGER.debug("Processing node type change for {} from {} to {}", nodeRef, oldType, newType);

        final ContentStore oldStore = this.resolveStoreForType(nodeRef, oldType);
        final ContentStore newStore = this.resolveStoreForType(nodeRef, newType);

        if (oldStore != newStore)
        {
            LOGGER.debug("Node {} was changed to type for which content sthould be stored in a different store", nodeRef);
            this.checkAndProcessContentPropertiesMove(nodeRef);
        }
        else
        {
            LOGGER.debug("Node {} was not changed to type for which content sthould be stored in a different store", nodeRef);
        }
    }
}
 
Example #16
Source File: MoveCapableCommonRoutingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
/**
 * Gets 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 the store most appropriate for the given context and
 *         <b>never <tt>null</tt></b>
 */
protected ContentStore selectWriteStore(final ContentContext ctx)
{
    final ContentStore writeStore;

    if (this.isRoutable(ctx))
    {
        writeStore = this.selectWriteStoreFromRoutes(ctx);
    }
    else
    {
        writeStore = this.fallbackStore;
    }

    return writeStore;
}
 
Example #17
Source File: FileContentStoreTest.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
@Test
public void predeterminedContentURL() throws Exception
{
    final FileContentStore store = this.createDefaultStore();

    store.afterPropertiesSet();

    Assert.assertTrue("Store should support write", store.isWriteSupported());

    final String testText = generateText(SEED_PRNG.nextLong());
    final String dummyContentUrl = STORE_PROTOCOL + ContentStore.PROTOCOL_DELIMITER + "any/path/will/do";
    final ContentWriter writer = this.testIndividualWriteAndRead(store, new ContentContext(null, dummyContentUrl), testText);

    final String contentUrl = writer.getContentUrl();
    Assert.assertEquals("Effective content URL did not match provided URL", dummyContentUrl, contentUrl);
}
 
Example #18
Source File: TypeRoutingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
/**
 * Resolves the content store to use for a specific node type.
 *
 * @param nodeRef
 *            the node for which a store is to be resolved
 * @param nodeTypeQName
 *            the type of the node being resolved
 * @return the store for the type or {@code null} if no store could was registered for the type or any of its ancestors
 */
protected ContentStore resolveStoreForType(final NodeRef nodeRef, final QName nodeTypeQName)
{
    LOGGER.debug("Looking up store for node {} and type {}", nodeRef, nodeTypeQName);
    ContentStore targetStore = null;
    QName currentTypeQName = nodeTypeQName;
    while (targetStore == null && currentTypeQName != null)
    {
        if (this.storeByTypeQName.containsKey(currentTypeQName))
        {
            LOGGER.debug("Using store defined for type {} (same or ancestor of node type {})", currentTypeQName, nodeTypeQName);
            targetStore = this.storeByTypeQName.get(currentTypeQName);
        }

        currentTypeQName = this.dictionaryService.getType(currentTypeQName).getParentName();
    }
    return targetStore;
}
 
Example #19
Source File: MultiTAdminServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testTenantRoutingContentStoreMayBeNullWhenProxyingAndInterfaceNotImplemented()
{    
    // Represents proxy in front of non-TenantRoutingContentStore ContentStore
    ContentStore contentStore = new FakeSubsystemProxy(true);
    TenantRoutingContentStore router = tenantAdmin.tenantRoutingContentStore(contentStore);
    assertNull(router);
}
 
Example #20
Source File: TimeBasedFileContentUrlProvider.java    From alfresco-simple-content-stores with Apache License 2.0 5 votes vote down vote up
@Override
public String createNewFileStoreUrl()
{
    final StringBuilder sb = new StringBuilder(20);
    sb.append(this.storeProtocol);
    sb.append(ContentStore.PROTOCOL_DELIMITER);
    sb.append(createTimeBasedPath(this.bucketsPerMinute));
    sb.append(GUID.generate()).append(".bin");
    return sb.toString();
}
 
Example #21
Source File: MultiTAdminServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testTenantRoutingContentStoreRetrievedByContentStoreCaps()
{
    ContentStore contentStore = new FakeSubsystemProxy(false);
    TenantRoutingContentStore router = tenantAdmin.tenantRoutingContentStore(contentStore);
    assertNotNull(router);
}
 
Example #22
Source File: DeduplicatingContentStoreTest.java    From alfresco-simple-content-stores with Apache License 2.0 5 votes vote down vote up
private static ContentWriter testIndividualWriteAndRead(final DeduplicatingContentStore deduplicatingContentStore,
        final String testText)
{
    return ContentStoreContext.executeInNewContext(() -> {
        final ContentWriter writer = deduplicatingContentStore.getWriter(new ContentContext(null, null));
        writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
        writer.setEncoding(StandardCharsets.UTF_8.name());
        writer.setLocale(Locale.ENGLISH);
        writer.putContent(testText);

        final String contentUrl = writer.getContentUrl();
        Assert.assertNotNull("Content URL was not set after writing content", contentUrl);
        Assert.assertTrue("Content URL does not start with the configured protocol",
                contentUrl.startsWith(STORE_PROTOCOL + ContentStore.PROTOCOL_DELIMITER));

        Assert.assertTrue("Store does not report content URL to exist after writing content",
                deduplicatingContentStore.exists(contentUrl));

        final ContentReader properReader = deduplicatingContentStore.getReader(contentUrl);
        Assert.assertTrue("Reader was not returned for freshly written content", properReader != null);
        Assert.assertTrue("Reader does not refer to existing file for freshly written content", properReader.exists());

        // reader does not know about mimetype (provided via persisted ContentData at server runtime)
        properReader.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);

        final String readText = properReader.getContentString();
        Assert.assertEquals("Read content does not match written test content", testText, readText);

        return writer;
    });
}
 
Example #23
Source File: FilesystemBulkImportItemVersion.java    From alfresco-bulk-import with Apache License 2.0 5 votes vote down vote up
public FilesystemBulkImportItemVersion(final ServiceRegistry serviceRegistry,
                                       final ContentStore    configuredContentStore,
                                       final MetadataLoader  metadataLoader,
                                       final BigDecimal      versionNumber,
                                       final File            contentFile,
                                       final File            metadataFile)
{
    super(calculateType(metadataLoader,
                        contentFile,
                        metadataFile,
                        ContentModel.TYPE_FOLDER.toPrefixString(serviceRegistry.getNamespaceService()),
                        ContentModel.TYPE_CONTENT.toPrefixString(serviceRegistry.getNamespaceService())),
          versionNumber);

    this.mimeTypeService        = serviceRegistry.getMimetypeService();
    this.namespaceService       = serviceRegistry.getNamespaceService();
    this.configuredContentStore = configuredContentStore;
    this.metadataLoader         = metadataLoader;
    this.contentReference       = contentFile;
    this.metadataReference      = metadataFile;

    // "stat" the content file then cache the results
    this.isDirectory = serviceRegistry.getDictionaryService().isSubClass(createQName(serviceRegistry, getType()), ContentModel.TYPE_FOLDER);

    if (contentFile == null || contentFile.isDirectory())
    {
        cachedSizeInBytes = 0L;
    }
    else
    {
        cachedSizeInBytes = contentFile.length();
    }
}
 
Example #24
Source File: AlternativeProtocolFileContentUrlProviderFacade.java    From alfresco-simple-content-stores with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public String createNewFileStoreUrl()
{
    String fileStoreUrl = this.delegate.createNewFileStoreUrl();

    final int delimiterStart = fileStoreUrl.indexOf(ContentStore.PROTOCOL_DELIMITER);
    fileStoreUrl = this.desiredStoreProtocol + fileStoreUrl.substring(delimiterStart, fileStoreUrl.length());

    return fileStoreUrl;
}
 
Example #25
Source File: SiteRoutingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void onCopyComplete(final QName classRef, final NodeRef sourceNodeRef, final NodeRef targetNodeRef, final boolean copyToNewNode,
        final Map<NodeRef, NodeRef> copyMap)
{
    // only act on active nodes which can actually be in a site
    if (StoreRef.STORE_REF_WORKSPACE_SPACESSTORE.equals(targetNodeRef.getStoreRef()))
    {
        LOGGER.debug("Processing onCopyComplete for copy from {} to {}", sourceNodeRef, targetNodeRef);

        // check for actual move-relevant site copy
        final Boolean moveRelevant = AuthenticationUtil.runAsSystem(() -> {
            final NodeRef sourceSite = this.resolveSiteForNode(sourceNodeRef);
            final NodeRef targetSite = this.resolveSiteForNode(targetNodeRef);

            ContentStore sourceStore = this.resolveStoreForSite(sourceSite);
            sourceStore = sourceStore != null ? sourceStore : this.fallbackStore;
            ContentStore targetStore = this.resolveStoreForSite(targetSite);
            targetStore = targetStore != null ? targetStore : this.fallbackStore;

            final boolean differentStores = sourceStore != targetStore;
            return Boolean.valueOf(differentStores);
        });

        if (Boolean.TRUE.equals(moveRelevant))
        {
            LOGGER.debug("Node {} was copied into a location for which content should be stored in a different store", targetNodeRef);
            this.checkAndProcessContentPropertiesMove(targetNodeRef);
        }
        else
        {
            LOGGER.debug("Node {} was not copied into a location for which content should be stored in a different store",
                    targetNodeRef);
        }
    }
}
 
Example #26
Source File: ContentServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Before
public void before() throws Exception
{
    super.before();
    
    // Get the instance of the required content service
    this.contentService = (ContentService)this.applicationContext.getBean("contentService");
    this.contentStore = (ContentStore) ReflectionTestUtils.getField(contentService, "store");
}
 
Example #27
Source File: DeduplicatingContentStoreTest.java    From alfresco-simple-content-stores with Apache License 2.0 5 votes vote down vote up
@Test
public void noPathPrefixDeduplication() throws Exception
{
    final DictionaryService dictionaryService = EasyMock.mock(DictionaryService.class);

    final DeduplicatingContentStore deduplicatingContentStore = new DeduplicatingContentStore();
    deduplicatingContentStore.setNamespaceService(PREFIX_RESOLVER);
    deduplicatingContentStore.setDictionaryService(dictionaryService);
    deduplicatingContentStore.setPathSegments(0);

    final FileContentStore fileContentStore = new FileContentStore();
    fileContentStore.setRootDirectory(backingStoreFolder.getAbsolutePath());
    fileContentStore.setProtocol(STORE_PROTOCOL);
    deduplicatingContentStore.setBackingStore(fileContentStore);

    final FileContentStore temporaryContentStore = new FileContentStore();
    temporaryContentStore.setRootDirectory(temporaryStoreFolder.getAbsolutePath());
    temporaryContentStore.setProtocol(TEMPORARY_STORE_PROTOCOL);
    deduplicatingContentStore.setTemporaryStore(temporaryContentStore);

    fileContentStore.afterPropertiesSet();
    temporaryContentStore.afterPropertiesSet();
    deduplicatingContentStore.afterPropertiesSet();

    final String commonText = generateText(SEED_PRNG.nextLong());
    final ContentWriter writer = testIndividualWriteAndRead(deduplicatingContentStore, commonText);

    Assert.assertTrue("Content URL of writer does includes unwanted path elements",
            writer.getContentUrl().matches("^" + STORE_PROTOCOL + ContentStore.PROTOCOL_DELIMITER + "[a-fA-F0-9]{128}\\.bin$"));
}
 
Example #28
Source File: AbstractTenantRoutingContentStore.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public long getSpaceTotal()
{
    ContentStore x = getTenantContentStore();
    if(x != null)
    {
        return x.getSpaceTotal();
    }
    else
    {
        return -1;
    }
}
 
Example #29
Source File: TenantRoutingFileContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 5 votes vote down vote up
/**
 *
 * {@inheritDoc}
 */
@Override
protected ContentStore initContentStore(final ApplicationContext ctx, final String contentRoot)
{
    final String domain = this.tenantService.getCurrentUserDomain();
    final Map<String, Serializable> extendedEventParams = new HashMap<>();
    if (!TenantService.DEFAULT_DOMAIN.equals(domain))
    {
        LOGGER.debug("Initialising new tenant file content store for {} with root directory {}", domain, contentRoot);
        extendedEventParams.put("Tenant", domain);
    }
    else
    {
        LOGGER.debug("Initialising new tenant file content store for default tenant with root directory {}", contentRoot);
    }

    final FileContentStore fileContentStore = new FileContentStore();
    fileContentStore.setApplicationContext(ctx);
    fileContentStore.setRootDirectory(contentRoot);
    fileContentStore.setExtendedEventParameters(extendedEventParams);

    fileContentStore.setProtocol(this.protocol);
    fileContentStore.setAllowRandomAccess(this.allowRandomAccess);
    fileContentStore.setReadOnly(this.readOnly);
    fileContentStore.setDeleteEmptyDirs(this.deleteEmptyDirs);

    if (this.contentLimitProvider != null)
    {
        fileContentStore.setContentLimitProvider(this.contentLimitProvider);
    }

    if (this.fileContentUrlProvider != null)
    {
        fileContentStore.setFileContentUrlProvider(this.fileContentUrlProvider);
    }
    fileContentStore.afterPropertiesSet();

    return fileContentStore;
}
 
Example #30
Source File: FileContentStoreTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Ensures that the size is something other than <tt>-1</tt> or <tt>Long.MAX_VALUE</tt>
 */
@Override
@Test
public void testSpaceFree() throws Exception
{
    ContentStore store = getStore();
    long size = store.getSpaceFree();
    assertTrue("Size must be positive", size > 0L);
    assertTrue("Size must not be Long.MAX_VALUE", size < Long.MAX_VALUE);
}