Search in sources :

Example 31 with PostConstruct

use of jakarta.annotation.PostConstruct in project jans by JanssenProject.

the class SelectAccountAction method prepare.

@PostConstruct
public void prepare() {
    currentSessions = Lists.newArrayList();
    Set<String> uids = Sets.newHashSet();
    for (SessionId session : sessionIdService.getCurrentSessions()) {
        final User user = sessionIdService.getUser(session);
        if (user == null) {
            log.error("Failed to get user for session. Skipping it from current_sessions, id: {}", session.getId());
            continue;
        }
        final String uid = StringUtils.isNotBlank(user.getUserId()) ? user.getUserId() : user.getDn();
        if (!currentSessions.contains(session) && !uids.contains(uid)) {
            log.trace("User: {}, sessionId: {}", uid, session.getId());
            currentSessions.add(session);
            uids.add(uid);
        }
    }
    log.trace("Found {} sessions", currentSessions.size());
}
Also used : User(io.jans.as.common.model.common.User) SessionId(io.jans.as.server.model.common.SessionId) PostConstruct(jakarta.annotation.PostConstruct)

Example 32 with PostConstruct

use of jakarta.annotation.PostConstruct in project jans by JanssenProject.

the class ConfigurationFactory method init.

@PostConstruct
public void init() {
    this.isActive = new AtomicBoolean(true);
    try {
        this.persistenceConfiguration = persistanceFactoryService.loadPersistenceConfiguration(LDAP_PROPERTIES_FILE);
        loadBaseConfiguration();
        String confDir = confDir();
        this.configFilePath = confDir + CONFIG_FILE_NAME;
        this.errorsFilePath = confDir + ERRORS_FILE_NAME;
        this.staticConfFilePath = confDir + STATIC_CONF_FILE_NAME;
        String certsDir = this.baseConfiguration.getString(CERTS_DIR);
        if (StringHelper.isEmpty(certsDir)) {
            certsDir = confDir;
        }
        this.webKeysFilePath = certsDir + File.separator + WEB_KEYS_FILE_NAME;
        this.saltFilePath = confDir + SALT_FILE_NAME;
        loadCryptoConfigurationSalt();
    } finally {
        this.isActive.set(false);
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) PostConstruct(jakarta.annotation.PostConstruct)

Example 33 with PostConstruct

use of jakarta.annotation.PostConstruct in project jans by JanssenProject.

the class ActionService method init.

@PostConstruct
private void init() {
    URL url = null;
    try {
        url = new URL(String.format("file://%s%s/", econf.getRootDir(), econf.getScriptsPath()));
    } catch (MalformedURLException e) {
        logger.error(e.getMessage());
        throw new RuntimeException(e);
    }
    logger.debug("Creating a Groovy Script Engine based at {}", url.toString());
    gse = new GroovyScriptEngine(new URL[] { url });
    /*
        //Failed attempt to force scripts have java extension instead of groovy:
        //Dependant scripts are not found if .groovy is not used
        CompilerConfiguration cc = gse.getConfig();
        cc.setDefaultScriptExtension(CLASS_SUFFIX.substring(1));
        
        //Set it so change takes effect
        gse.setConfig(cc);
        */
    loader = gse.getGroovyClassLoader();
    loader.setShouldRecompile(true);
    mapper = new ObjectMapper();
    mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
}
Also used : MalformedURLException(java.net.MalformedURLException) GroovyScriptEngine(groovy.util.GroovyScriptEngine) URL(java.net.URL) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) PostConstruct(jakarta.annotation.PostConstruct)

Example 34 with PostConstruct

use of jakarta.annotation.PostConstruct in project jans by JanssenProject.

the class ServicesFactory method init.

@PostConstruct
public void init() {
    mapper = new ObjectMapper();
    econfig = new EngineConfig();
}
Also used : EngineConfig(io.jans.agama.model.EngineConfig) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) PostConstruct(jakarta.annotation.PostConstruct)

Example 35 with PostConstruct

use of jakarta.annotation.PostConstruct in project jans by JanssenProject.

the class TemplatingService method init.

@PostConstruct
private void init() {
    fmConfig = new Configuration(Configuration.VERSION_2_3_31);
    fmConfig.setDefaultEncoding(UTF_8.toString());
    fmConfig.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    fmConfig.setLogTemplateExceptions(false);
    fmConfig.setWrapUncheckedExceptions(true);
    fmConfig.setFallbackOnNullLoopVariable(false);
    try {
        fmConfig.setDirectoryForTemplateLoading(Paths.get(econf.getRootDir()).toFile());
    } catch (IOException e) {
        logger.error("Error configuring directory for UI templates: {}", e.getMessage());
        throw new RuntimeException(e);
    }
}
Also used : Configuration(freemarker.template.Configuration) IOException(java.io.IOException) PostConstruct(jakarta.annotation.PostConstruct)

Aggregations

PostConstruct (jakarta.annotation.PostConstruct)76 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 IOException (java.io.IOException)6 Date (java.util.Date)6 PostBean (it.vige.rubia.dto.PostBean)4 JSFUtil.handleException (it.vige.rubia.ui.JSFUtil.handleException)4 ArrayList (java.util.ArrayList)4 ForumBean (it.vige.rubia.dto.ForumBean)3 FacesContext (jakarta.faces.context.FacesContext)3 Method (java.lang.reflect.Method)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 ApplicationAssociate (com.sun.faces.application.ApplicationAssociate)2 HTTPServer (io.prometheus.client.exporter.HTTPServer)2 ModuleException (it.vige.rubia.ModuleException)2 CategoryBean (it.vige.rubia.dto.CategoryBean)2 TopicBean (it.vige.rubia.dto.TopicBean)2 SessionScoped (jakarta.enterprise.context.SessionScoped)2 Typed (jakarta.enterprise.inject.Typed)2 ClientWindow (jakarta.faces.lifecycle.ClientWindow)2 Serializable (java.io.Serializable)2