Search in sources :

Example 1 with InvalidStoreTypeException

use of org.craftercms.core.exception.InvalidStoreTypeException in project core by craftercms.

the class ContentStoreServiceImpl method createContext.

/**
 * {@inheritDoc}
 */
@Override
public Context createContext(String storeType, String storeServerUrl, String username, String password, String rootFolderPath, boolean mergingOn, boolean cacheOn, int maxAllowedItemsInCache, boolean ignoreHiddenFiles) throws InvalidStoreTypeException, RootFolderNotFoundException, StoreException, AuthenticationException {
    String id = createContextId(storeType, storeServerUrl, username, password, rootFolderPath, cacheOn, maxAllowedItemsInCache, ignoreHiddenFiles);
    if (!contexts.containsKey(id)) {
        ContentStoreAdapter storeAdapter = storeAdapterRegistry.get(storeType);
        if (storeAdapter == null) {
            throw new InvalidStoreTypeException("No registered content store adapter for store type " + storeType);
        }
        Context context = storeAdapter.createContext(id, storeServerUrl, username, password, rootFolderPath, mergingOn, cacheOn, maxAllowedItemsInCache, ignoreHiddenFiles);
        cacheTemplate.getCacheService().addScope(context);
        contexts.put(id, context);
        return context;
    } else {
        throw new StoreException("A context for id '" + id + "' already exists");
    }
}
Also used : Context(org.craftercms.core.service.Context) InvalidStoreTypeException(org.craftercms.core.exception.InvalidStoreTypeException) ContentStoreAdapter(org.craftercms.core.store.ContentStoreAdapter) StoreException(org.craftercms.core.exception.StoreException)

Aggregations

InvalidStoreTypeException (org.craftercms.core.exception.InvalidStoreTypeException)1 StoreException (org.craftercms.core.exception.StoreException)1 Context (org.craftercms.core.service.Context)1 ContentStoreAdapter (org.craftercms.core.store.ContentStoreAdapter)1