/** * Replaces default singular schema name using the configured replacement */ @Nonnull public static String replaceSingularSchemaName(@Nonnull String sql) { Optional<String> customSchema = SingularProperties.getOpt(CUSTOM_SCHEMA_NAME); return customSchema.map(s -> SqlUtil.replaceSchemaName(sql, Constants.SCHEMA, s)).orElse(sql); }
public SingularEntityInterceptor(List<DatabaseObjectNameReplacement> replacements) { Optional<String> schemaName = SingularProperties.getOpt(CUSTOM_SCHEMA_NAME); schemaName.ifPresent(s -> schemaReplacements.add(new DatabaseObjectNameReplacement(Constants.SCHEMA, s))); schemaReplacements.addAll(replacements); }
public ServerContext(String name, String defaultPath, String propertiesBaseKey) { this.name = name; this.propertiesBaseKey = propertiesBaseKey; String key = propertiesBaseKey + ".context"; String path = SingularProperties.getOpt(key).orElse(null); if (path == null || path.length() <= 0) { path = defaultPath; } if (!path.endsWith("/*")) { if (path.endsWith("*")) { path = path.substring(0, path.length() - 2) + "/*"; } else if (path.endsWith("/")) { path += "*"; } else { path += "/*"; } } this.contextPath = path; }
public PServerContext(String name, String defaultPath, String propertiesBaseKey) { this.name = name; this.propertiesBaseKey = propertiesBaseKey; String key = propertiesBaseKey + ".context"; String path = SingularProperties.getOpt(key).orElse(null); if (path == null || path.length() <= 0) { path = defaultPath; } if (!path.endsWith("/*")) { if (path.endsWith("*")) { path = path.substring(0, path.length() - 2) + "/*"; } else if (path.endsWith("/")) { path += "*"; } else { path += "/*"; } } this.contextPath = path; }
ServerContext(String defaultPath, String propertiesBaseKey) { this.propertiesBaseKey = propertiesBaseKey; String key = propertiesBaseKey + ".context"; String path = SingularProperties.getOpt(key).orElse(null); if (path == null || path.length() <= 0) { path = defaultPath; } if (!path.endsWith("/*")) { if (path.endsWith("*")) { path = path.substring(0, path.length() - 2) + "/*"; } else if (path.endsWith("/")) { path += "*"; } else { path += "/*"; } } this.contextPath = path; }
ServerContext(String defaultPath, String propertiesBaseKey) { this.propertiesBaseKey = propertiesBaseKey; String key = propertiesBaseKey + ".context"; String path = SingularProperties.getOpt(key).orElse(null); if (path == null || path.length() <= 0) { path = defaultPath; } if (!path.endsWith("/*")) { if (path.endsWith("*")) { path = path.substring(0, path.length() - 2) + "/*"; } else if (path.endsWith("/")) { path += "*"; } else { path += "/*"; } } this.contextPath = path; }
public PServerContext(String name, String defaultPath, String propertiesBaseKey) { this.name = name; this.propertiesBaseKey = propertiesBaseKey; String key = propertiesBaseKey + ".context"; String path = SingularProperties.getOpt(key).orElse(null); if (path == null || path.length() <= 0) { path = defaultPath; } if (!path.endsWith("/*")) { if (path.endsWith("*")) { path = path.substring(0, path.length() - 2) + "/*"; } else if (path.endsWith("/")) { path += "*"; } else { path += "/*"; } } this.contextPath = path; }
private void changeTargetEndpointAddress(T servicePortType) { Optional<String> propertyValue = SingularProperties.getOpt(property); if (! propertyValue.isPresent()) { throw new WSConnectionException(String.format("WebService endpoint property not found in SingularProperties. Missing property %s", property)); } String value = propertyValue.get(); if (value.endsWith("?wsdl")) { value = value.substring(0, value.length() - "?wsdl".length()); } Map<String, Object> requestContext = ((BindingProvider) servicePortType).getRequestContext(); requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, value); requestContext.put("set-jaxb-validation-event-handler", Boolean.FALSE); }
private Template parseTemplate(String template, boolean ignoreError) { try { TemplateExceptionHandler exceptionHandler = TemplateExceptionHandler.RETHROW_HANDLER; Optional<String> property = SingularProperties.getOpt(SingularProperties.FREEMARKER_IGNORE_ERROR); if (property.isPresent() && FALSE.equalsIgnoreCase(property.get())) { exceptionHandler = TemplateExceptionHandler.RETHROW_HANDLER; } else if ((property.isPresent() && TRUE.equalsIgnoreCase(property.get())) || ignoreError) { exceptionHandler = TemplateExceptionHandler.IGNORE_HANDLER; } return new Template("templateStringParameter", template, getConfiguration(exceptionHandler)); } catch (IOException e) { throw new SingularFormException("Erro fazendo parse do template: " + template, e); } }
/** * Obtém uma referência de service url. * * @param filterConfig filterConfig * @return uma referência de service url */ public Optional<String> resolveServiceUrl(FilterConfig filterConfig) { String filterServiceURL = filterConfig.getInitParameter(SERVICE_URL_PARAM); if (filterServiceURL == null){ return SingularProperties.getOpt(getSingularContext().getServerPropertyKey(SSOFilter.SERVICE_URL_PARAM)); } return Optional.ofNullable(filterServiceURL); } }
/** * Obtém uma referência de service url. * * @param filterConfig filterConfig * @return uma referência de service url */ public Optional<String> resolveServiceUrl(FilterConfig filterConfig) { String filterServiceURL = filterConfig.getInitParameter(SERVICE_URL_PARAM); if (filterServiceURL == null){ return SingularProperties.getOpt(getSingularContext().getServerPropertyKey(SSOFilter.SERVICE_URL_PARAM)); } return Optional.ofNullable(filterServiceURL); } }
/** * Obtém uma referência de service url. * * @param filterConfig filterConfig * @return uma referência de service url */ public Optional<String> resolveServiceUrl(FilterConfig filterConfig) { String filterServiceURL = filterConfig.getInitParameter(SERVICE_URL_PARAM); if (filterServiceURL == null){ return SingularProperties.getOpt(getSingularContext().getServerPropertyKey(SSOFilter.SERVICE_URL_PARAM)); } return Optional.ofNullable(filterServiceURL); } }
public SingularSchedulerBean(DataSource dataSource) { Properties properties = new Properties(); properties.setProperty("org.quartz.scheduler.instanceName", "SingularFlowScheduler"); properties.setProperty("org.quartz.scheduler.instanceId", "AUTO"); if (SingularProperties.get().isTrue(SINGULAR_QUARTZ_JOBSTORE_ENABLED)) { properties.setProperty("org.quartz.jobStore.useProperties", "false"); properties.setProperty("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX"); properties.setProperty("org.quartz.jobStore.driverDelegateClass", SingularProperties.getOpt(SINGULAR_QUARTZ_DRIVER_DELEGATE).orElse("org.quartz.impl.jdbcjobstore.StdJDBCDelegate")); properties.setProperty("org.quartz.jobStore.tablePrefix", SingularProperties.getOpt(SINGULAR_QUARTZ_TABLE_PREFIX).orElse("QRTZ_")); properties.setProperty("org.quartz.jobStore.isClustered", "true"); setDataSource(dataSource); setOverwriteExistingJobs(true); } else { properties.put("org.quartz.jobStore.class", "org.quartz.simpl.RAMJobStore"); } setQuartzProperties(properties); }
super.init(filterConfig); final Map<String, String> params = new HashMap<String, String>(); params.put(SERVER_NAME_PARAM, SingularProperties.getOpt(getSingularContext().getServerPropertyKey(SSOFilter.SSO_CLIENT_SERVER)).orElse(null)); params.put(CAS_SERVER_URL_PREFIX_PARAM, SingularProperties.getOpt(getSingularContext().getServerPropertyKey(SSOFilter.SSO_URL_PREFIX)).orElse(null)); params.put(EXCEPTION_ON_TICKET_INVALID, "true"); Enumeration enumeration = filterConfig.getInitParameterNames();
super.init(filterConfig); final Map<String, String> params = new HashMap<String, String>(); params.put(CAS_SERVER_URL_PREFIX_PARAM, SingularProperties.getOpt(getSingularContext().getServerPropertyKey(SSOFilter.SSO_URL_PREFIX)).orElse(null)); Enumeration enumeration = filterConfig.getInitParameterNames(); while (enumeration.hasMoreElements()) {
/** * Verifies if should use embedded database (usually while running a test or in development mode). */ public static boolean useEmbeddedDatabase() { //In the future, this code should be move to Embedded Database helper class if (SingularProperties.getOpt(USE_EMBEDDED_DATABASE).isPresent()) { return SingularProperties.get().isTrue(USE_EMBEDDED_DATABASE); } else if (SingularProperties.get().isFalse(SINGULAR_DEV_MODE)) { return false; } return true; }
if ("sequence".equals(SingularProperties.getOpt(SingularProperties.HIBERNATE_GENERATOR).orElse(null))) { getSession().doWork(connection -> { String sql = SqlUtil.replaceSingularSchemaName("insert into " + Constants.SCHEMA + ".TB_ATOR (CO_ATOR, CO_USUARIO) VALUES (" + Constants.SCHEMA + ".SQ_CO_ATOR.NEXTVAL, ? )");
if ("sequence".equals(SingularProperties.getOpt(SingularProperties.HIBERNATE_GENERATOR).orElse(null))) { getSession().doWork(connection -> { String sql = SqlUtil.replaceSingularSchemaName("insert into " + Constants.SCHEMA + ".TB_ATOR (CO_ATOR, CO_USUARIO) VALUES (" + Constants.SCHEMA + ".SQ_CO_ATOR.NEXTVAL, ? )");
@DependsOn("createFunctionInitializer") @Bean public LocalSessionFactoryBean sessionFactory(final DataSource dataSource) { final LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean(); sessionFactoryBean.setDataSource(dataSource); sessionFactoryBean.setHibernateProperties(hibernateProperties()); sessionFactoryBean.setPackagesToScan(hibernatePackagesToScan()); Optional<String> schemaName = SingularProperties.getOpt(CUSTOM_SCHEMA_NAME); if (schemaName.isPresent()) { sessionFactoryBean.setEntityInterceptor(new SingularEntityInterceptor()); getLogger().info("Utilizando schema customizado: {}", schemaName.get()); } return sessionFactoryBean; }
@DependsOn("createFunctionInitializer") @Bean public LocalSessionFactoryBean sessionFactory(final DataSource dataSource) { final LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean(); sessionFactoryBean.setDataSource(dataSource); sessionFactoryBean.setHibernateProperties(hibernateProperties()); sessionFactoryBean.setPackagesToScan(hibernatePackagesToScan()); Optional<String> schemaName = SingularProperties.getOpt(CUSTOM_SCHEMA_NAME); if (schemaName.isPresent()) { sessionFactoryBean.setEntityInterceptor(new SingularEntityInterceptor()); getLogger().info("Utilizando schema customizado: {}", schemaName.get()); } return sessionFactoryBean; }