Java Code Examples for org.alfresco.repo.content.ContentStore#isContentUrlSupported()

The following examples show how to use org.alfresco.repo.content.ContentStore#isContentUrlSupported() . 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: 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 2
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 3
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 4
Source File: SiteRoutingFileContentStore.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 5
Source File: TenantRoutingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 5 votes vote down vote up
/**
 *
 * {@inheritDoc}
 */
@Override
protected ContentStore getStore(final String contentUrl, final boolean mustExist)
{
    ContentStore readStore = null;

    if (!TenantUtil.isCurrentDomainDefault())
    {
        final String currentDomain = TenantUtil.getCurrentDomain();
        if (this.storeByTenant.containsKey(currentDomain))
        {
            readStore = this.storeByTenant.get(currentDomain);

            if (!readStore.isContentUrlSupported(contentUrl) || (mustExist && !readStore.exists(contentUrl)))
            {
                readStore = null;
            }
        }
    }

    if (readStore == null)
    {
        readStore = super.getStore(contentUrl, mustExist);
    }

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

    ContentStore store = null;
    if (storeForCurrentContext != null)
    {
        LOGGER.debug(
                "Preferentially testing store for current context to select store for read of content URL {} with mustExist flag of {}",
                contentUrl, mustExist);
        if (!mustExist || (storeForCurrentContext.isContentUrlSupported(contentUrl) && storeForCurrentContext.exists(contentUrl)))
        {
            store = storeForCurrentContext;
        }
    }

    if (store == null)
    {
        LOGGER.debug("Delegating to super implementation to select store for read of content URL {} with mustExist flag of {}",
                contentUrl, mustExist);
        store = super.selectStore(contentUrl, mustExist);
    }
    return store;
}
 
Example 7
Source File: SiteRoutingFileContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected ContentStore selectStore(final String contentUrl, final boolean mustExist)
{
    // optimisation: check the likely candidate store based on context first
    final ContentStore storeForCurrentContext = this.selectStoreForCurrentContext();

    ContentStore store = null;
    if (storeForCurrentContext != null)
    {
        LOGGER.debug(
                "Preferentially testing store for current context to select store for read of content URL {} with mustExist flag of {}",
                contentUrl, mustExist);
        if (!mustExist || (storeForCurrentContext.isContentUrlSupported(contentUrl) && storeForCurrentContext.exists(contentUrl)))
        {
            store = storeForCurrentContext;
        }
    }

    if (store == null)
    {
        LOGGER.debug("Delegating to super implementation to select store for read of content URL {} with mustExist flag of {}",
                contentUrl, mustExist);
        store = super.selectStore(contentUrl, mustExist);
    }
    return store;
}
 
Example 8
Source File: EagerContentStoreCleaner.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
private boolean deleteFromStores(String contentUrl, boolean callListeners)
{
    int deleted = 0;
    for (ContentStore store : stores)
    {
        // Bypass if the store is read-only
        if (!store.isWriteSupported())
        {
            continue;
        }
        // MNT-12150 fix, bypass if the store doesn't support the URL but mark as deleted
        if (!store.isContentUrlSupported(contentUrl))
        {
            deleted++;
            continue;
        }
        if (callListeners)
        {
            // Call listeners
            for (ContentStoreCleanerListener listener : listeners)
            {
                try
                {
                    // Since we are in post-commit, we do best-effort
                    listener.beforeDelete(store, contentUrl);
                }
                catch (Throwable e)
                {
                    logger.error(
                            "Content deletion listener failed: \n" +
                            "   URL:    " + contentUrl + "\n" +
                            "   Source: " + store,
                            e);
                }
            }
        }
        // Delete
        if (deleteFromStore(contentUrl, store))
        {
            deleted++;
        }
    }
    // Did we delete from all stores (non-existence is a delete, too)
    return deleted == stores.size();
}
 
Example 9
Source File: AggregatingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 4 votes vote down vote up
@Override
public ContentReader getReader(final String contentUrl)
{
    ContentReader reader = null;
    boolean validReader = false;

    LOGGER.debug("Retrieving content reader for URL {}", contentUrl);

    if (this.primaryStore.isContentUrlSupported(contentUrl))
    {
        reader = this.primaryStore.getReader(contentUrl);
        validReader = reader != null && reader.exists();

        if (validReader)
        {
            LOGGER.debug("Content reader for URL {} retrieved from primary store", contentUrl);
        }
    }

    for (int idx = 0, max = this.secondaryStores.size(); idx < max && !validReader; idx++)
    {
        final ContentStore store = this.secondaryStores.get(idx);
        if (store.isContentUrlSupported(contentUrl))
        {
            reader = store.getReader(contentUrl);

            validReader = reader != null && reader.exists();
            if (validReader)
            {
                LOGGER.debug("Content reader for URL {} retrieved from secondary store #{}", contentUrl, idx + 1);
            }
        }
    }

    if (!validReader)
    {
        LOGGER.debug("No content reader with existing content found for URL {}", contentUrl);
    }

    return reader;
}