use of com.servoy.j2db.util.Settings in project servoy-client by Servoy.
the class WebClientsApplication method newRequestCycleProcessor.
@Override
protected IRequestCycleProcessor newRequestCycleProcessor() {
return new UrlCompressingWebRequestProcessor() {
@Override
public void respond(RequestCycle requestCycle) {
// execute events from WebClient.invokeLater() before the respond (render) is started
Session session = Session.get();
if (session instanceof WebClientSession && ((WebClientSession) session).getWebClient() != null) {
((WebClientSession) session).getWebClient().executeEvents();
}
super.respond(requestCycle);
}
/**
* @see wicket.protocol.http.WebRequestCycleProcessor#newRequestCodingStrategy()
*/
@Override
protected IRequestCodingStrategy newRequestCodingStrategy() {
Settings settings = Settings.getInstance();
if (// $NON-NLS-1$ //$NON-NLS-2$
Utils.getAsBoolean(settings.getProperty("servoy.webclient.crypt-urls", "true"))) {
return new ServoyCryptedUrlWebRequestCodingStrategy(new UrlCompressingWebCodingStrategy());
} else {
return new UrlCompressingWebCodingStrategy();
}
}
@Override
protected IRequestTarget resolveListenerInterfaceTarget(RequestCycle requestCycle, Page page, String componentPath, String interfaceName, RequestParameters requestParameters) {
try {
IRequestTarget requestTarget = super.resolveListenerInterfaceTarget(requestCycle, page, componentPath, interfaceName, requestParameters);
if (requestTarget instanceof BehaviorRequestTarget) {
Component target = ((BehaviorRequestTarget) requestTarget).getTarget();
if (!(target instanceof Page)) {
boolean invalidPage = false;
Page page2 = null;
try {
// test if it has a page.
page2 = target.findParent(Page.class);
} catch (Exception e) {
Debug.trace(e);
invalidPage = true;
}
if (page2 == null || !page2.getId().equals(page.getId())) {
invalidPage = true;
}
if (invalidPage) {
// $NON-NLS-1$
Debug.log("Couldn't resolve the page of the component, component already gone from page? returning empty");
return EmptyRequestTarget.getInstance();
}
}
}
return requestTarget;
} catch (Exception e) {
// $NON-NLS-1$
Debug.log("couldnt resolve interface, component page already gone from page? returning empty");
}
return EmptyRequestTarget.getInstance();
}
@Override
public IRequestTarget resolve(final RequestCycle requestCycle, final RequestParameters requestParameters) {
try {
return super.resolve(requestCycle, requestParameters);
} catch (PageExpiredException e) {
// if there is a page expired exception
// then ignore it if there is a current form.
// $NON-NLS-1$
Debug.trace("Page expired, checking for a current form");
Request request = requestCycle.getRequest();
if (request instanceof WebRequest && ((WebRequest) request).isAjax() && requestParameters.isOnlyProcessIfPathActive()) {
// $NON-NLS-1$
Debug.trace("Page expired, it is an ajan/process only if active request");
Session session = Session.get();
if (session instanceof WebClientSession && ((WebClientSession) session).getWebClient() != null) {
WebClient webClient = ((WebClientSession) session).getWebClient();
if (webClient.getFormManager().getCurrentForm() != null) {
// $NON-NLS-1$
Debug.trace("Page expired, there is a current form, ignore this ajax request");
return EmptyAjaxRequestTarget.getInstance();
}
}
}
throw e;
}
}
};
}
use of com.servoy.j2db.util.Settings in project servoy-client by Servoy.
the class AngularIndexPageWriter method getContentSecurityPolicyConfig.
/**
* Get the ContentSecurityPolicyConfig is it should be applied, otherwise return null;
*
* Only when configured and when the browser is a modern browser that supports Content-Security-Policy level 3.
*/
private static ContentSecurityPolicyConfig getContentSecurityPolicyConfig(HttpServletRequest request) {
Settings settings = Settings.getInstance();
if (!getAsBoolean(settings.getProperty("servoy.ngclient.setContentSecurityPolicyHeader", "true"))) {
Debug.trace("ContentSecurityPolicyHeader is disabled by configuration");
return null;
}
String userAgentHeader = request.getHeader("user-agent");
if (!HCUtils.supportsContentSecurityPolicyLevel3(userAgentHeader)) {
if (Debug.tracing()) {
Debug.trace("ContentSecurityPolicyHeader is disabled, user agent '" + userAgentHeader + "' does not support ContentSecurityPolicy level 3");
}
return null;
}
ContentSecurityPolicyConfig contentSecurityPolicyConfig = new ContentSecurityPolicyConfig(HTTPUtils.getNonce(request));
// Overridable directives
setDirectiveOverride(contentSecurityPolicyConfig, "frame-src", settings);
setDirectiveOverride(contentSecurityPolicyConfig, "frame-ancestors", settings);
setDirectiveOverride(contentSecurityPolicyConfig, "style-src", settings);
setDirectiveOverride(contentSecurityPolicyConfig, "img-src", settings);
setDirectiveOverride(contentSecurityPolicyConfig, "font-src", settings);
return contentSecurityPolicyConfig;
}
use of com.servoy.j2db.util.Settings in project servoy-client by Servoy.
the class ComponentFactory method getWebID.
public static String getWebID(Form form, IPersist meta) {
StringBuilder prefix = new StringBuilder();
// to stay javascript id ref compatible
prefix.append(WEB_ID_PREFIX);
if (element_name_as_uid_prefix == null) {
Settings s = Settings.getInstance();
element_name_as_uid_prefix = Boolean.valueOf(Utils.getAsBoolean(s.getProperty("servoy.webclient.templates.element_name_as_uid_prefix")));
}
if (element_name_as_uid_prefix == Boolean.TRUE && meta instanceof ISupportName) {
String name = ((ISupportName) meta).getName();
if (name != null && name.trim().length() != 0) {
prefix.append('_');
prefix.append(name);
}
}
prefix.append('_');
String uid = meta.getUUID().toString();
uid = Utils.stringReplace(uid, "-", "_");
prefix.append(uid);
return prefix.toString();
}
use of com.servoy.j2db.util.Settings in project servoy-client by Servoy.
the class LFPreferencePanel method handleOK.
@Override
public boolean handleOK() {
boolean update = false;
// If the L&F or the font size change, we need to remove all dialog bounds,
// because there is a chance that the dialogs will have different sizes under the
// new L&F or with the new font. If only the theme changes, there should be no
// such situation.
boolean removeAllBounds = false;
LookAndFeelInfo selected = ((LookAndFeelInfoWrapper) lnfBox.getSelectedItem()).getLookAndFeelInfo();
String themeName = (String) themesBox.getSelectedItem();
String themeClassName = (String) themes.get(themeName);
// $NON-NLS-1$//$NON-NLS-2$
String currentTheme = _application.getSettings().getProperty("lnf.theme", "");
if (_choosenFont != null && !_choosenFont.equals(_selectedFont)) {
update = true;
removeAllBounds = true;
_selectedFont = _choosenFont;
_choosenFont = null;
}
if (_current != selected) {
update = true;
removeAllBounds = true;
_current = selected;
}
String clientPrefix = "";
if (RemoteRunnerChecker.getInstance().isRunningWebStart()) {
URL webstartbase = _application.getServerURL();
// $NON-NLS-1$
clientPrefix = webstartbase.getHost() + webstartbase.getPort() + "_";
}
if (themeClassName != null) {
if (!themeClassName.equals(currentTheme)) {
update = true;
// $NON-NLS-1$
_application.getSettings().setProperty(clientPrefix + "lnf.theme", themeClassName);
}
} else {
// clear $NON-NLS-1$//$NON-NLS-2$
_application.getSettings().setProperty(clientPrefix + "lnf.theme", "");
}
if (update) {
String s_laf = UIManager.getSystemLookAndFeelClassName();
if (selected != null)
s_laf = selected.getClassName();
if (_application.putClientProperty(LookAndFeelInfo.class.getName(), s_laf) && _application.putClientProperty(Font.class.getName(), _selectedFont)) {
String c_laf = (_current == null ? "" : _current.getClassName());
// $NON-NLS-1$
_application.getSettings().setProperty(clientPrefix + "selectedlnf", c_laf);
if (_selectedFont != null) {
// $NON-NLS-1$
_application.getSettings().setProperty(clientPrefix + "font", PersistHelper.createFontString(_selectedFont));
}
} else {
// $NON-NLS-1$
_application.getSettings().setProperty(clientPrefix + "lnf.theme", currentTheme);
}
if (removeAllBounds) {
((Settings) _application.getSettings()).deleteAllBounds();
}
}
return true;
}
use of com.servoy.j2db.util.Settings in project servoy-client by Servoy.
the class TusServlet method init.
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
Settings settings = Settings.getInstance();
String uploadDir = settings.getProperty("servoy.ng_web_client.temp.uploadir");
long maxUpload = Utils.getAsLong(settings.getProperty("servoy.webclient.maxuploadsize", "0"), false);
File fileUploadDir = null;
if (uploadDir != null) {
fileUploadDir = new File(uploadDir);
if (!fileUploadDir.exists() && !fileUploadDir.mkdirs()) {
fileUploadDir = null;
Debug.error("Couldn't use the property 'servoy.ng_web_client.temp.uploadir' value: '" + uploadDir + "', directory could not be created or doesn't exists");
}
}
tusFileUploadService = new TusFileUploadService().withUploadURI(config.getServletContext().getContextPath() + "/tus/upload/[0-9]+/.+/.+/.+/");
if (fileUploadDir != null) {
try {
tusFileUploadService = tusFileUploadService.withStoragePath(fileUploadDir.getCanonicalPath());
} catch (IOException e) {
throw new ServletException(e);
}
}
if (maxUpload > 0) {
tusFileUploadService = tusFileUploadService.withMaxUploadSize(Long.valueOf(maxUpload));
}
}
Aggregations