Search in sources :

Example 1 with DocumentStoreType

use of org.gluu.service.document.store.conf.DocumentStoreType 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)

Example 2 with DocumentStoreType

use of org.gluu.service.document.store.conf.DocumentStoreType in project oxTrust by GluuFederation.

the class JsonConfigurationAction method saveStoreConfigJson.

public String saveStoreConfigJson() {
    // Update JSON configurations
    try {
        log.debug("Saving store-config.json:" + this.storeConfigurationJson);
        if (this.storeConfigurationJson != null) {
            this.storeConfiguration = convertToStoreConfiguration(this.storeConfigurationJson);
            DocumentStoreType type = this.storeConfiguration.getDocumentStoreType();
            if (type.equals(DocumentStoreType.JCA) && !canConnectToJca()) {
                facesMessages.add(FacesMessage.SEVERITY_ERROR, "Error connecting to JCA with provided configuration");
                return OxTrustConstants.RESULT_FAILURE;
            }
            jsonConfigurationService.saveDocumentStoreConfiguration(this.storeConfiguration);
        }
        facesMessages.add(FacesMessage.SEVERITY_INFO, "Document store configuration is updated.");
        return OxTrustConstants.RESULT_SUCCESS;
    } catch (Exception ex) {
        log.error("Failed to update store-config.json", ex);
        facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to update document store configuration in DB");
    }
    return OxTrustConstants.RESULT_FAILURE;
}
Also used : DocumentStoreType(org.gluu.service.document.store.conf.DocumentStoreType) EncryptionException(org.gluu.util.security.StringEncrypter.EncryptionException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 3 with DocumentStoreType

use of org.gluu.service.document.store.conf.DocumentStoreType in project oxCore by GluuFederation.

the class DocumentStoreProviderFactory method getLocalDocumentStoreProvider.

@Produces
@ApplicationScoped
@LocalDocumentStore
public DocumentStoreProvider getLocalDocumentStoreProvider() {
    log.debug("Started to create local document store provider");
    DocumentStoreType documentStoreType = DocumentStoreType.LOCAL;
    DocumentStoreProvider documentStoreProvider = instance.select(LocalDocumentStoreProvider.class).get();
    if (documentStoreProvider == null) {
        throw new RuntimeException("Failed to initialize DocumentStoreProvider, DocumentStoreProviderType is unsupported: " + documentStoreType);
    }
    documentStoreProvider.create();
    return documentStoreProvider;
}
Also used : DocumentStoreType(org.gluu.service.document.store.conf.DocumentStoreType) LocalDocumentStore(org.gluu.service.document.store.LocalDocumentStore) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 4 with DocumentStoreType

use of org.gluu.service.document.store.conf.DocumentStoreType in project oxCore by GluuFederation.

the class DocumentStoreProviderFactory 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 proxied bean
    DocumentStoreProvider documentStoreProvider = null;
    switch(documentStoreType) {
        case LOCAL:
            documentStoreProvider = instance.select(LocalDocumentStoreProvider.class).get();
            break;
        case JCA:
            documentStoreProvider = instance.select(JcaDocumentStoreProvider.class).get();
            break;
        case WEB_DAV:
            documentStoreProvider = instance.select(WebDavDocumentStoreProvider.class).get();
            break;
    }
    if (documentStoreProvider == null) {
        throw new RuntimeException("Failed to initialize DocumentStoreProvider, DocumentStoreProviderType is unsupported: " + documentStoreType);
    }
    documentStoreProvider.create();
    return documentStoreProvider;
}
Also used : DocumentStoreType(org.gluu.service.document.store.conf.DocumentStoreType)

Aggregations

DocumentStoreType (org.gluu.service.document.store.conf.DocumentStoreType)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Produces (javax.enterprise.inject.Produces)1 LocalDocumentStore (org.gluu.service.document.store.LocalDocumentStore)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 EncryptionException (org.gluu.util.security.StringEncrypter.EncryptionException)1