Search in sources :

Example 1 with LocalDocumentStoreProvider

use of org.gluu.service.document.store.provider.LocalDocumentStoreProvider in project oxCore by GluuFederation.

the class StandaloneDocumentStoreProviderFactory method getDocumentStoreProvider.

public DocumentStoreProvider getDocumentStoreProvider(DocumentStoreConfiguration documentStoreConfiguration) {
    DocumentStoreType documentStoreType = documentStoreConfiguration.getDocumentStoreType();
    if (documentStoreType == null) {
        LOG.error("Failed to initialize documentStoreProvider, documentStoreProviderType is null. Fallback to LOCAL type.");
        documentStoreType = DocumentStoreType.LOCAL;
    }
    // Create bean
    DocumentStoreProvider documentStoreProvider = null;
    switch(documentStoreType) {
        case LOCAL:
            LocalDocumentStoreProvider localDocumentStoreProvider = new LocalDocumentStoreProvider();
            localDocumentStoreProvider.configure(documentStoreConfiguration);
            localDocumentStoreProvider.init();
            documentStoreProvider = localDocumentStoreProvider;
            break;
        case JCA:
            if (stringEncrypter == null) {
                throw new RuntimeException("Factory is not initialized properly. stringEncrypter is not specified");
            }
            JcaDocumentStoreProvider jcaDocumentStoreProvider = new JcaDocumentStoreProvider();
            jcaDocumentStoreProvider.configure(documentStoreConfiguration, stringEncrypter);
            jcaDocumentStoreProvider.init();
            documentStoreProvider = jcaDocumentStoreProvider;
            break;
        case WEB_DAV:
            if (stringEncrypter == null) {
                throw new RuntimeException("Factory is not initialized properly. stringEncrypter is not specified");
            }
            WebDavDocumentStoreProvider webDavDocumentStoreProvider = new WebDavDocumentStoreProvider();
            webDavDocumentStoreProvider.configure(documentStoreConfiguration, stringEncrypter);
            webDavDocumentStoreProvider.init();
            documentStoreProvider = webDavDocumentStoreProvider;
            break;
    }
    if (documentStoreProvider == null) {
        throw new RuntimeException("Failed to initialize documentStoreProvider, documentStoreProviderType is unsupported: " + documentStoreType);
    }
    documentStoreProvider.create();
    return documentStoreProvider;
}
Also used : JcaDocumentStoreProvider(org.gluu.service.document.store.provider.JcaDocumentStoreProvider) WebDavDocumentStoreProvider(org.gluu.service.document.store.provider.WebDavDocumentStoreProvider) LocalDocumentStoreProvider(org.gluu.service.document.store.provider.LocalDocumentStoreProvider) DocumentStoreType(org.gluu.service.document.store.conf.DocumentStoreType) LocalDocumentStoreProvider(org.gluu.service.document.store.provider.LocalDocumentStoreProvider) JcaDocumentStoreProvider(org.gluu.service.document.store.provider.JcaDocumentStoreProvider) DocumentStoreProvider(org.gluu.service.document.store.provider.DocumentStoreProvider) WebDavDocumentStoreProvider(org.gluu.service.document.store.provider.WebDavDocumentStoreProvider)

Aggregations

DocumentStoreType (org.gluu.service.document.store.conf.DocumentStoreType)1 DocumentStoreProvider (org.gluu.service.document.store.provider.DocumentStoreProvider)1 JcaDocumentStoreProvider (org.gluu.service.document.store.provider.JcaDocumentStoreProvider)1 LocalDocumentStoreProvider (org.gluu.service.document.store.provider.LocalDocumentStoreProvider)1 WebDavDocumentStoreProvider (org.gluu.service.document.store.provider.WebDavDocumentStoreProvider)1