/** * Looks for the property with the giving key. * <p>Never return empty String (in this case they became null) and also trims the resulting String.</p> */ @Nonnull static Optional<String> getOpt(@Nonnull String key) { return get().getPropertyOpt(key); }
public static String getEndpointDefault() { String baseURL = SingularProperties.get(HtmlToPdfConstants.ENDPOINT_WS_WKHTMLTOPDF, ENDPOINT_WS_WKHTMLTOPDF_DEFAULT_VALUE); LoggerFactory.getLogger(RestfulHtmlToPdfConverter.class).warn("Singular property {} not set! Defaulting to {} ", HtmlToPdfConstants.ENDPOINT_WS_WKHTMLTOPDF, ENDPOINT_WS_WKHTMLTOPDF_DEFAULT_VALUE); String context = HtmlToPdfConstants.CONVERT_HTML_TO_PDF_PATH; return baseURL + context; }
/** * 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; }
private void changeTargetEndpointAddress(T servicePortType) { String propertyValue = SingularProperties.get().getProperty(property); if (propertyValue.endsWith("?wsdl")) { propertyValue = propertyValue.substring(0, propertyValue.length() - "?wsdl".length()); } Map<String, Object> requestContext = ((BindingProvider) servicePortType).getRequestContext(); requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, propertyValue); requestContext.put("set-jaxb-validation-event-handler", Boolean.FALSE); }
/** * If true, the database will be recreated. The most common usage is to * configure hibernate to create-drop tables and reinsert initial data. * * @return */ public static boolean isDropCreateDatabase() { return SingularProperties.get().isTrue(SingularProperties.RECREATE_DATABASE); } }
private IScheduleData getDefaultSchedule() { if (scheduleData == null) { scheduleData = SingularProperties .get() .getPropertyOpt(SINGULAR_QUARTZ_DEFAULT_CRON) .map(ScheduleDataBuilder::buildFromCron) .orElse(ScheduleDataBuilder.buildHourly(1)); getLogger().info("SINGULAR DEFAULT SCHEDULER DESCRIPTION: {} - CRON EXPRESSION: {}", scheduleData.getDescription(), scheduleData.getCronExpression()); } return scheduleData; }
@Override public RuntimeConfigurationType getConfigurationType() { if (SingularProperties.get().isFalse(SingularProperties.SINGULAR_DEV_MODE)) { return RuntimeConfigurationType.DEPLOYMENT; } else { return RuntimeConfigurationType.DEVELOPMENT; } }
@Override public RuntimeConfigurationType getConfigurationType() { if (SingularProperties.get().isFalse(SingularProperties.SINGULAR_DEV_MODE)) { return RuntimeConfigurationType.DEPLOYMENT; } else { return RuntimeConfigurationType.DEVELOPMENT; } }
@Override public void configure(WebSecurity web) throws Exception { if (SingularProperties.get().isTrue(SingularProperties.SINGULAR_DEV_MODE)){ // web.debug(true); } super.configure(web); }
protected DataSource jndiDataSourceConfiguration() { getLogger().info("Usando datasource configurado via JNDI"); DataSource dataSource = null; JndiTemplate jndi = new JndiTemplate(); String dataSourceName = SingularProperties.get(JNDI_DATASOURCE, "java:jboss/datasources/singular"); try { dataSource = (DataSource) jndi.lookup(dataSourceName); } catch (NamingException e) { getLogger().error(String.format("Datasource %s not found.", dataSourceName), e); } return dataSource; }
protected DataSource jndiDataSourceConfiguration() { getLogger().info("Usando datasource configurado via JNDI"); DataSource dataSource = null; JndiTemplate jndi = new JndiTemplate(); String dataSourceName = SingularProperties.get(JNDI_DATASOURCE, "java:jboss/datasources/singular"); try { dataSource = (DataSource) jndi.lookup(dataSourceName); } catch (NamingException e) { getLogger().error(String.format("Datasource %s not found.", dataSourceName), e); } return dataSource; }
@Bean public HtmlToPdfConverter htmlToPdfConverter() { if (SingularProperties.get().isTrue(SingularProperties.SINGULAR_DEV_MODE)) { return new MockHtmlToPdfConverter(); } else { return RestfulHtmlToPdfConverter.createUsingDefaultConfig(); } }
@Override public void configure(WebSecurity web) throws Exception { if (SingularProperties.get().isTrue(SingularProperties.SINGULAR_DEV_MODE)){ web.debug(true); } super.configure(web); }
protected void configureCAS(ServletContext servletContext){ if (SingularProperties.get().isTrue(SingularProperties.DEFAULT_CAS_ENABLED)) { addCASFilter(servletContext, WORKLIST); addCASFilter(servletContext, REQUIREMENT); addSingleSignOutListener(servletContext); } }
protected void configureCAS(ServletContext servletContext){ if (SingularProperties.get().isTrue(SingularProperties.DEFAULT_CAS_ENABLED)) { addCASFilter(servletContext, WORKLIST); addCASFilter(servletContext, REQUIREMENT); addSingleSignOutListener(servletContext); } }
private void addJavaMelodyFilter(ServletContext container, AnnotationConfigWebApplicationContext rootContext) { if(SingularProperties.get().isTrue("singular.studio.javamelody.enabled")) { FilterRegistration.Dynamic dynamic = container.addFilter("javamelodyFilter", MonitoringFilter.class); dynamic.addMappingForUrlPatterns(EnumSet.of(DispatcherType.ASYNC, DispatcherType.REQUEST), false, "/*"); dynamic.setAsyncSupported(true); container.addListener(new SessionListener()); } }
@Override @SuppressWarnings("squid:S2095") public void renderHead(IHeaderResponse response) { super.renderHead(response); PackageTextTemplate fileUploadJSTemplate = new PackageTextTemplate(FileUploadListPanel.class, "FileUploadListPanel.js"); Map<String, String> params = new HashMap<>(); params.put("maxChunkSize", SingularProperties.get(SINGULAR_FILEUPLOAD_MAXCHUNKSIZE, DEFAULT_FILE_UPLOAD_MAX_CHUNK_SIZE)); response.render(OnDomReadyHeaderItem.forScript(fileUploadJSTemplate.interpolate(params).asString())); response.render(OnDomReadyHeaderItem.forScript(generateInitJS())); }
@Override public void onStartup(ServletContext servletContext) throws ServletException { super.onStartup(servletContext); if (SingularProperties.get().isTrue(SingularProperties.DEFAULT_CAS_ENABLED)) { addCASFilter(servletContext, PServerContext.WORKLIST); addCASFilter(servletContext, PServerContext.PETITION); addSingleSignOutListener(servletContext); } }
static SIcon resolve(String code) { // recarrega toda vez se em dev mode List<SIconProvider> providers = (SingularProperties.get().isTrue(SingularProperties.SINGULAR_DEV_MODE)) ? loadProviders() : CACHED_PROVIDERS; for (SIconProvider provider : providers) { SIcon icon = provider.resolve(code); if (icon != null) return icon; } return new SIcon().setIconCssClasses(code); }
@Override public void renderHead(IHeaderResponse response) { super.renderHead(response); response.render(CssHeaderItem.forUrl("/singular-static/resources/singular/fonts/google/open-sans.css")); response.render(JavaScriptReferenceHeaderItem.forReference(new PackageResourceReference(ServerTemplate.class, "singular.js"))); response.render(CssHeaderItem.forReference(new PackageResourceReference(ServerTemplate.class, "ServerTemplate.css"))); if (SingularProperties.get().isTrue(SingularProperties.ANALYTICS_ENABLED)) { response.render(JavaScriptHeaderItem.forUrl(skinnableResource("/layout4/scripts/analytics.js"))); } }