diff --git a/pom.xml b/pom.xml index f1e954b65..408ce4a7b 100644 --- a/pom.xml +++ b/pom.xml @@ -61,7 +61,20 @@ com.guicedee.services uadetector-core + + + com.guicedee.services uadetector-resources @@ -125,7 +138,13 @@ import ${guicedee.version} - + + com.guicedee + guicedee-bom + pom + import + ${guicedee.version} + com.jwebmp jwebmp-bom diff --git a/src/main/java/com/jwebmp/core/Event.java b/src/main/java/com/jwebmp/core/Event.java index fb61e9ff5..fd452c0ee 100644 --- a/src/main/java/com/jwebmp/core/Event.java +++ b/src/main/java/com/jwebmp/core/Event.java @@ -17,8 +17,8 @@ package com.jwebmp.core; import com.fasterxml.jackson.annotation.JsonInclude; - -import com.guicedee.client.*; +import com.guicedee.client.IGuiceContext; +import com.guicedee.services.jsonrepresentation.IJsonRepresentation; import com.guicedee.services.jsonrepresentation.json.StaticStrings; import com.jwebmp.core.base.ComponentEventBase; import com.jwebmp.core.base.ajax.AjaxCall; @@ -49,7 +49,7 @@ @SuppressWarnings("unused") public abstract class Event> extends ComponentEventBase - implements GlobalEvents, IEvent + implements GlobalEvents, IEvent, IJsonRepresentation { /** * A list of all queries to execute on ajax response diff --git a/src/main/java/com/jwebmp/core/FileTemplates.java b/src/main/java/com/jwebmp/core/FileTemplates.java deleted file mode 100644 index 5c5c1a320..000000000 --- a/src/main/java/com/jwebmp/core/FileTemplates.java +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.guicedee.services.jsonrepresentation.json.StaticStrings; - -import lombok.extern.java.Log; -import org.apache.commons.io.IOUtils; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.logging.Level; -import java.util.regex.Matcher; - -import static java.lang.String.*; - -/** - * Contains a cached set of file templates usually per page - * - * @author GedMarc - * @since A long time ago in a galaxy far away - */ -@Log -public class FileTemplates -{ - /** - * All registered templates - */ - @JsonIgnore - private static final Map TemplateScripts = new ConcurrentHashMap<>(); - /** - * All registered variables - */ - @JsonIgnore - private static final Map TemplateVariables = new ConcurrentHashMap<>(); - - private FileTemplates() - { - //no config - } - - /** - * Removes a template - * - * @param templateName - */ - public static void removeTemplate(String templateName) - { - TemplateScripts.remove(templateName); - } - - /** - * Gets the text string for the template script - * - * @param templateName - * - * @return - */ - public static StringBuilder getTemplateScript(String templateName) - { - return TemplateScripts.get(templateName); - } - - /** - * Get the map of all the template scripts - * - * @param template - * - * @return A final HashMap - */ - public static StringBuilder renderTemplateScripts(String template) - { - if (TemplateScripts.containsKey(template) && TemplateScripts.get(template) != null) - { - return processTemplate(template, getTemplateScripts().get(template) - .toString()); - } - - return new StringBuilder(); - } - - /** - * Replaces all instances of the following - * - * @param templateName - * The name of the template being processed - * @param template - * The physical string to process - * - * @return - */ - public static StringBuilder processTemplate(String templateName, String template) - { - String templateOutput = template; - for (String templateVariable : getTemplateVariables().keySet()) - { - String templateScript = null; - try - { - templateScript = Matcher.quoteReplacement(getTemplateVariables().get(templateVariable) - .toString()); - templateOutput = templateOutput.replaceAll(StaticStrings.STRING_EMPTY + templateVariable + StaticStrings.STRING_EMPTY, templateScript); - } - catch (NullPointerException iae) - { - log.log(Level.FINER, "[Error]-[Unable to find specified template];[Script]-[" + templateVariable + "]", iae); - } - catch (IllegalArgumentException iae) - { - log.log(Level.WARNING, format("[Error]-[Invalid Variable Name for Regular Expression Search];[Variable]-[{0}];[Script]-[{1}]", templateVariable, templateScript), - iae); - } - } - return new StringBuilder(templateOutput); - } - - //public boolean doesFileExist() - - /** - * Sets all the template scripts currently loaded in memory - * - * @return - */ - public static Map getTemplateScripts() - { - return TemplateScripts; - } - - /** - * Returns all the template variables currently loaded into memory - * - * @return - */ - public static Map getTemplateVariables() - { - return TemplateVariables; - } - - /** - * Replaces all instances of the following - *

- * %%APP%% - the angular module application name %%DIRECTIVES%% - the angular directives %%MODULES%% the modules generates - * %%CONTROLLER%% the modules generates - * - * @param templateName - * The template name - * @param template - * the template to build - * - * @return the name - */ - public static StringBuilder compileTemplate(String templateName, String template) - { - return processTemplate(templateName, template); - } - - /** - * Replaces all instances of the following - *

- * %%APP%% - the angular module application name %%DIRECTIVES%% - the angular directives %%MODULES%% the modules generates - * %%CONTROLLER%% the modules generates - * - * @param referenceClass - * The class to find where the file is at - * @param templateName - * the template to use - * - * @return the name - */ - public static StringBuilder compileTemplate(Class referenceClass, String templateName) - { - String template = getFileTemplate(referenceClass, templateName).toString(); - return processTemplate(templateName, template); - } - - /** - * Returns the template as a string - * - * @param referenceClass - * The class to reference to locate the file - * @param templateName - * The file without .min.js or .js attached to it - * - * @return The string for the file - */ - public static StringBuilder getFileTemplate(Class referenceClass, String templateName) - { - return getFileTemplate(referenceClass, templateName, templateName); - } - - /** - * Returns the template as a string - * - * @param referenceClass - * The class to reference to locate the file - * @param templateName - * The file without .min.js or .js attached to it - * @param fileName - * - * @return The string for the file - */ - public static StringBuilder getFileTemplate(Class referenceClass, String templateName, String fileName) - { - return getFileTemplate(referenceClass, templateName, fileName, false); - } - - /** - * Returns the template as a string - * - * @param referenceClass - * The class to reference to locate the file - * @param templateName - * The file without .min.js or .js attached to it - * @param fileName - * - * @return The string for the file - */ - public static StringBuilder getFileTemplate(Class referenceClass, String templateName, String fileName, boolean alwaysRefresh) - { - StringBuilder template = TemplateScripts.get(templateName); - if (template == null || alwaysRefresh) - { - String templateFileName = fileName; - if (!(fileName.contains(".html") || fileName.contains(".htm") || fileName.contains(".js") || fileName.contains(".css") || fileName.contains( - ".min") || fileName.contains(".txt"))) - { - templateFileName += ".js"; - } - if (templateFileName.endsWith(".min")) - { - templateFileName = templateFileName + ".js"; - } - try - { - String contents = IOUtils.toString(referenceClass.getResourceAsStream(templateFileName), StaticStrings.UTF_CHARSET); - setTemplateScript(templateName, new StringBuilder(contents)); - } - catch (FileNotFoundException ex) - { - log.log(Level.SEVERE, "[Error]-[unable to find template file];[TemplateFile]-[" + templateName + "];[TemplatePath]-[" + referenceClass.getResource(templateName) - .getPath() + "]", ex); - } - catch (IOException ex) - { - log.log(Level.SEVERE, "Unable to read file contents jwangular template File", ex); - } - catch (NullPointerException npe) - { - log.log(Level.SEVERE, "template file [" + templateFileName + "] not found.", npe); - } - catch (Exception npe) - { - log.log(Level.SEVERE, "Exception Rendering Template", npe); - } - } - return TemplateScripts.get(templateName); - } - - /** - * Sets the template script - * - * @param templateName - * @param templateScript - */ - public static void setTemplateScript(String templateName, StringBuilder templateScript) - { - TemplateScripts.put(templateName, templateScript); - } -} diff --git a/src/main/java/com/jwebmp/core/Page.java b/src/main/java/com/jwebmp/core/Page.java index 9f9e8e87e..d8b9f7a63 100644 --- a/src/main/java/com/jwebmp/core/Page.java +++ b/src/main/java/com/jwebmp/core/Page.java @@ -34,7 +34,7 @@ import com.jwebmp.core.base.references.JavascriptReference; import com.jwebmp.core.services.IPage; import com.jwebmp.core.services.IPageConfigurator; -import com.jwebmp.core.utilities.StaticStrings; +import com.jwebmp.interception.services.StaticStrings; import jakarta.validation.constraints.NotNull; import lombok.extern.java.Log; import net.sf.uadetector.ReadableDeviceCategory; @@ -47,7 +47,6 @@ import static com.guicedee.services.jsonrepresentation.json.StaticStrings.STRING_SEMICOLON; import static com.jwebmp.core.implementations.JWebMPServicesBindings.IPageConfiguratorsKey; -import static com.jwebmp.core.implementations.ReadableUserAgentProvider.defaultAgent; /** * Top level of any HTML page. @@ -76,7 +75,6 @@ public class Page> private ContentSecurityPolicy contentSecurityPolicy; - private ReadableUserAgent readableUserAgent; /** * If this page has already gone through initialization @@ -402,8 +400,8 @@ public DocumentType getDocumentType() public boolean isMobileOrSmartTablet() { Set mobiles = EnumSet.of(ReadableDeviceCategory.Category.SMARTPHONE, - ReadableDeviceCategory.Category.SMART_TV, - ReadableDeviceCategory.Category.TABLET); + ReadableDeviceCategory.Category.SMART_TV, + ReadableDeviceCategory.Category.TABLET); return mobiles.contains(getUserAgent().getDeviceCategory() .getCategory()); } @@ -416,18 +414,7 @@ public boolean isMobileOrSmartTablet() @NotNull public ReadableUserAgent getUserAgent() { - try - { - readableUserAgent = IGuiceContext.get(ReadableUserAgent.class); - } - catch (ProvisionException | OutOfScopeException e) - { - if (readableUserAgent == null) - { - readableUserAgent = defaultAgent(); - } - } - return readableUserAgent; + return IGuiceContext.get(ReadableUserAgent.class); } /** diff --git a/src/main/java/com/jwebmp/core/SessionHelper.java b/src/main/java/com/jwebmp/core/SessionHelper.java deleted file mode 100644 index 6ebd86484..000000000 --- a/src/main/java/com/jwebmp/core/SessionHelper.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core; - - -import com.guicedee.client.*; -import com.jwebmp.core.utilities.StaticStrings; -import jakarta.servlet.http.HttpServletRequest; -import lombok.extern.java.Log; - -import java.util.logging.Level; - -import static com.guicedee.services.jsonrepresentation.json.StaticStrings.STRING_FORWARD_SLASH; - -/** - * @author GedMarc - * @since 05 Apr 2017 - */ -@Log -public class SessionHelper -{ - /** - * The given address - */ - private static String address = null; - - /** - * The given address - */ - private static String rootAddress = null; - - private static boolean cacheAddress = false; - - private static String addressToBeUsedWhenNull = ""; - - /* - * Constructs a new SessionHelper - */ - private SessionHelper() - { - //Nothing needed - } - - /** - * Returns the full server address, without the final section - * - * @return - */ - public static String getServerPath() - { - if (SessionHelper.isCacheAddress() && SessionHelper.getAddress() != null) - { - return SessionHelper.getAddress(); - } - try - { - HttpServletRequest request = IGuiceContext.get(HttpServletRequest.class); - StringBuffer buff = request.getRequestURL(); - if (request.getHeader(StaticStrings.REQUEST_SITE_HEADER_NAME) != null - && !request.getHeader(StaticStrings.REQUEST_SITE_HEADER_NAME).isEmpty()) - { - buff = new StringBuffer(request.getHeader(StaticStrings.REQUEST_SITE_HEADER_NAME)); - } - String address = buff.substring(0, buff.lastIndexOf(STRING_FORWARD_SLASH) + 1); - address = address.replace("[0:0:0:0:0:0:0:1]", "localhost"); - address = address.replace("127.0.0.1", "localhost"); - SessionHelper.address = address; - - return address; - } - catch (Exception e) - { - SessionHelper.log.log(Level.FINER, "Unable to get server path", e); - return SessionHelper.addressToBeUsedWhenNull; - } - } - - /** - * Returns the full server address, without the final section - * - * @return - */ - public static String getServerRootPath() - { - if (SessionHelper.isCacheAddress() && SessionHelper.getRootAddress() != null) - { - return SessionHelper.getRootAddress(); - } - try - { - HttpServletRequest request = IGuiceContext.get(HttpServletRequest.class); - StringBuffer buff = request.getRequestURL(); - if (request.getHeader(StaticStrings.REQUEST_SITE_HEADER_NAME) != null - && !request.getHeader(StaticStrings.REQUEST_SITE_HEADER_NAME).isEmpty()) - { - buff = new StringBuffer(request.getHeader(StaticStrings.REQUEST_SITE_HEADER_NAME)); - } - String address = buff.toString().replace(request.getRequestURI(),"");// buff.substring(0, buff.lastIndexOf(STRING_FORWARD_SLASH) + 1); - address = address.replace("[0:0:0:0:0:0:0:1]", "localhost"); - SessionHelper.rootAddress = address; - - return address; - } - catch (Exception e) - { - SessionHelper.log.log(Level.FINER, "Unable to get server path", e); - return SessionHelper.addressToBeUsedWhenNull; - } - } - - - - /** - * If the helper is using the cached address - * - * @return - */ - public static boolean isCacheAddress() - { - return SessionHelper.cacheAddress; - } - - /** - * Returns the current addross for the session helper - * - * @return - */ - public static String getAddress() - { - return SessionHelper.address; - } - - /** - * Sets the current address for the session helper. Use with cacheAddress to use fully customized address paths - * - * @param address - */ - public static void setAddress(String address) - { - SessionHelper.address = address; - } - - - public static String getRootAddress() - { - return rootAddress; - } - - public static void setRootAddress(String rootAddress) - { - SessionHelper.rootAddress = rootAddress; - } - - /** - * If the address must be cached on first reponse, and used for future calls - * - * @param cacheAddress - */ - public static void setCacheAddress(boolean cacheAddress) - { - SessionHelper.cacheAddress = cacheAddress; - } - - /** - * Returns the last section of the url, to be matched with page configurator url - * - * @return - */ - public static String getServletUrl() - { - try - { - HttpServletRequest request = IGuiceContext.getContext() - .inject() - .getInstance(HttpServletRequest.class); - String buff = request.getServletPath(); - return buff.isEmpty() ? STRING_FORWARD_SLASH : buff; - } - catch (Throwable T) - { - log.log(Level.WARNING, "Unable to get request, returning default /", T); - return "/"; - } - } - - public static String getAddressToBeUsedWhenNull() - { - return SessionHelper.addressToBeUsedWhenNull; - } - - public static void setAddressToBeUsedWhenNull(String addressToBeUsedWhenNull) - { - SessionHelper.addressToBeUsedWhenNull = addressToBeUsedWhenNull; - } -} diff --git a/src/main/java/com/jwebmp/core/annotations/PageConfiguration.java b/src/main/java/com/jwebmp/core/annotations/PageConfiguration.java deleted file mode 100644 index 310eab55b..000000000 --- a/src/main/java/com/jwebmp/core/annotations/PageConfiguration.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core.annotations; - -import com.guicedee.services.jsonrepresentation.json.StaticStrings; - -import java.lang.annotation.*; - -/** - * @author GedMarc - * @since 05 Apr 2017 - */ -@Target({ElementType.TYPE, ElementType.TYPE_USE}) -@Retention(RetentionPolicy.RUNTIME) -@Inherited -@Documented -public @interface PageConfiguration -{ - /** - * Specifies the URL that this page serves - * - * @return - */ - String url() default StaticStrings.STRING_FORWARD_SLASH; - - /** - * Specifies the type this page serves (best to leave it alone - or only use one page for error types etc) - * - * @return - */ - PageTypes type() default PageTypes.Default; - - /** - * If this configuration should be ignored on deployed - * - * @return - */ - boolean ignore() default false; -} diff --git a/src/main/java/com/jwebmp/core/annotations/PageTypes.java b/src/main/java/com/jwebmp/core/annotations/PageTypes.java deleted file mode 100644 index 288d0a61d..000000000 --- a/src/main/java/com/jwebmp/core/annotations/PageTypes.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core.annotations; - -/** - * @author GedMarc - * @since 05 Apr 2017 - */ -public enum PageTypes -{ - Default, - Mobile, - Error; - /** - * Any sub data - */ - private String data; - - /** - * A new PageTypes - */ - PageTypes() - { - - } - - /** - * Returns the name or the data contained within - * - * @return - */ - @Override - public String toString() - { - if (data != null && !data.isEmpty()) - { - return data; - } - else - { - return name(); - } - } -} diff --git a/src/main/java/com/jwebmp/core/base/ComponentHierarchyBase.java b/src/main/java/com/jwebmp/core/base/ComponentHierarchyBase.java index 37dd71e54..988e69d2f 100644 --- a/src/main/java/com/jwebmp/core/base/ComponentHierarchyBase.java +++ b/src/main/java/com/jwebmp/core/base/ComponentHierarchyBase.java @@ -20,10 +20,8 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Strings; -import com.guicedee.client.*; - +import com.guicedee.client.IGuiceContext; import com.guicedee.services.jsonrepresentation.json.StaticStrings; -import com.jwebmp.core.CSSComponent; import com.jwebmp.core.Event; import com.jwebmp.core.Feature; import com.jwebmp.core.Page; @@ -31,21 +29,19 @@ import com.jwebmp.core.base.html.interfaces.GlobalChildren; import com.jwebmp.core.base.html.interfaces.GlobalFeatures; import com.jwebmp.core.base.html.interfaces.events.GlobalEvents; -import com.jwebmp.core.base.interfaces.CastableComponent; import com.jwebmp.core.base.interfaces.IComponentFeatureBase; import com.jwebmp.core.base.interfaces.IComponentHierarchyBase; import com.jwebmp.core.base.interfaces.ICssClassName; import com.jwebmp.core.base.references.CSSReference; import com.jwebmp.core.base.references.JavascriptReference; import com.jwebmp.core.base.servlets.enumarations.ComponentTypes; -import com.jwebmp.core.base.servlets.interfaces.*; +import com.jwebmp.core.base.servlets.interfaces.ICSSComponent; import com.jwebmp.core.databind.IConfiguration; import com.jwebmp.core.databind.IOnComponentAdded; import com.jwebmp.core.databind.IOnComponentHtmlRender; import com.jwebmp.core.htmlbuilder.css.themes.Theme; import com.jwebmp.core.htmlbuilder.javascript.events.interfaces.IEvent; -import com.jwebmp.core.implementations.JWebMPSiteBinder; -import com.jwebmp.core.services.*; +import com.jwebmp.core.services.IPage; import jakarta.validation.constraints.NotNull; import lombok.extern.java.Log; @@ -69,14 +65,16 @@ * @since 24 Apr 2016 */ @Log -@SuppressWarnings({"unchecked", "MissingClassJavaDoc"}) +@SuppressWarnings({"unchecked", + "MissingClassJavaDoc"}) public class ComponentHierarchyBase & AttributeDefinitions, F extends GlobalFeatures, E extends GlobalEvents, J extends ComponentHierarchyBase> extends ComponentThemeBase - implements IComponentHierarchyBase { + implements IComponentHierarchyBase +{ /** * The list of children of this component @@ -113,7 +111,8 @@ public class ComponentHierarchyBase asHierarchyBase() { + public IComponentHierarchyBase asHierarchyBase() + { return this; } @@ -136,16 +136,22 @@ public IComponentHierarchyBase asHierarchyBase() { * @see ComponentEventBase#findEvent(String) */ @Override - public ComponentEventBase findEvent(@NotNull String eventId) { - for (C child : getChildren()) { - for (Object jScript : child.cast().asHierarchyBase() - .getEventsAll()) { - if (jScript == null) { + public ComponentEventBase findEvent(@NotNull String eventId) + { + for (C child : getChildren()) + { + for (Object jScript : child.cast() + .asHierarchyBase() + .getEventsAll()) + { + if (jScript == null) + { continue; } if (((Event) jScript) .getID() - .equals(eventId)) { + .equals(eventId)) + { return (ComponentEventBase) jScript; } } @@ -162,12 +168,14 @@ public IComponentHierarchyBase asHierarchyBase() { */ @Override @NotNull - public J setTiny(boolean tiny) { + public J setTiny(boolean tiny) + { getChildren().stream() - .filter(a -> a != null) - .parallel() - .forEach(child -> child.cast().asBase() - .setTiny(tiny)); + .filter(a -> a != null) + .parallel() + .forEach(child -> child.cast() + .asBase() + .setTiny(tiny)); return super.setTiny(tiny); } @@ -177,10 +185,12 @@ public J setTiny(boolean tiny) { * @return */ @JsonProperty("parent") - private String getParentJSON() { - if (getParent() != null) { + private String getParentJSON() + { + if (getParent() != null) + { return getParent().asBase() - .getID(); + .getID(); } return null; } @@ -193,17 +203,21 @@ private String getParentJSON() { */ @Override @NotNull - public Set getCssReferencesAll() { + public Set getCssReferencesAll() + { Set allCss = super.getCssReferencesAll(); getChildren().forEach(child -> - { - if (child != null) { - for (Object jScript : child.cast().asDependencyBase() - .getCssReferencesAll()) { - allCss.add((CSSReference) jScript); - } - } - }); + { + if (child != null) + { + for (Object jScript : child.cast() + .asDependencyBase() + .getCssReferencesAll()) + { + allCss.add((CSSReference) jScript); + } + } + }); return allCss; } @@ -215,19 +229,24 @@ public Set getCssReferencesAll() { */ @Override @NotNull - public Set getJavascriptReferencesAll() { + public Set getJavascriptReferencesAll() + { Set allJs = super.getJavascriptReferencesAll(); getChildren().forEach(child -> - { - if (child != null) { - for (Object jScript : child.cast().asDependencyBase() - .getJavascriptReferencesAll()) { - if (jScript != null) { - allJs.add((JavascriptReference) jScript); - } - } - } - }); + { + if (child != null) + { + for (Object jScript : child.cast() + .asDependencyBase() + .getJavascriptReferencesAll()) + { + if (jScript != null) + { + allJs.add((JavascriptReference) jScript); + } + } + } + }); return allJs; } @@ -237,7 +256,8 @@ public Set getJavascriptReferencesAll() { * @return int */ @Override - public int hashCode() { + public int hashCode() + { return super.hashCode(); } @@ -248,7 +268,8 @@ public int hashCode() { * @return boolean */ @Override - public boolean equals(Object o) { + public boolean equals(Object o) + { return super.equals(o); } @@ -256,21 +277,29 @@ public boolean equals(Object o) { * Method destroy ... */ @Override - public void destroy() { - if (children != null) { - for (C next : children) { - try { + public void destroy() + { + if (children != null) + { + for (C next : children) + { + try + { next.destroy(); - } catch (Exception e) { + } + catch (Exception e) + { ComponentHierarchyBase.log.log(Level.SEVERE, "UUnable to destroy", e); } } } - if (children != null) { + if (children != null) + { children.clear(); children = null; } - if (classes != null) { + if (classes != null) + { classes.clear(); classes = null; } @@ -284,13 +313,17 @@ public void destroy() { */ @NotNull @SuppressWarnings("unused") - public Set> getFeaturesAll() { + public Set> getFeaturesAll() + { Set> allFeatures = new LinkedHashSet<>(); getChildrenHierarchy().forEach(child -> { - if (child != null) { + if (child != null) + { for (Object event : child.asFeatureBase() - .getFeatures()) { - if (event != null) { + .getFeatures()) + { + if (event != null) + { allFeatures.add((Feature) event); } } @@ -310,9 +343,11 @@ public void destroy() { @NotNull @SuppressWarnings("unchecked") @Override - public > T wrap(@NotNull T component) { + public > T wrap(@NotNull T component) + { IComponentHierarchyBase existingParent = component.getParent(); - if (existingParent != null) { + if (existingParent != null) + { existingParent.remove(component); existingParent.add(this); } @@ -332,11 +367,12 @@ public void destroy() { @NotNull @SuppressWarnings("unchecked") @Override - public > T embed(@NotNull T component) { + public > T embed(@NotNull T component) + { component.getChildren() - .stream() - .filter(Objects::nonNull) - .forEach(a -> add((C) a)); + .stream() + .filter(Objects::nonNull) + .forEach(a -> add((C) a)); return component; } @@ -351,22 +387,29 @@ public void destroy() { @Override @SuppressWarnings("unchecked") @NotNull - public J add(@NotNull C newChild) { - if (newChild == null) { + public J add(@NotNull C newChild) + { + if (newChild == null) + { return (J) this; } - newChild.cast().asHierarchyBase() + newChild.cast() + .asHierarchyBase() .setParent(this); - newChild.cast().asHierarchyBase() + newChild.cast() + .asHierarchyBase() .setTiny(isTiny()); - newChild.cast().asHierarchyBase() + newChild.cast() + .asHierarchyBase() .setPage(getPage()); IComponentHierarchyBase c = (IComponentHierarchyBase) newChild; c.setTiny(isTiny()); boolean added = getChildren().add(newChild); - if (added) { + if (added) + { Set components = IGuiceContext.loaderToSet(ServiceLoader.load(IOnComponentAdded.class)); - for (IOnComponentAdded component : components) { + for (IOnComponentAdded component : components) + { component.onComponentAdded(this, (ComponentHierarchyBase) newChild); } } @@ -385,15 +428,20 @@ public J add(@NotNull C newChild) { @Override @SuppressWarnings("unchecked") @NotNull - public J add(@NotNull Integer position, @NotNull C newChild) { - if (newChild == null) { + public J add(@NotNull Integer position, @NotNull C newChild) + { + if (newChild == null) + { return (J) this; } - newChild.cast().asHierarchyBase() + newChild.cast() + .asHierarchyBase() .setParent(this); - newChild.cast().asHierarchyBase() + newChild.cast() + .asHierarchyBase() .setTiny(isTiny()); - newChild.cast().asHierarchyBase() + newChild.cast() + .asHierarchyBase() .setPage(getPage()); ArrayList componentHierarchyBases = new ArrayList<>(getChildren()); componentHierarchyBases.add(position, newChild); @@ -411,7 +459,8 @@ public J add(@NotNull Integer position, @NotNull C newChild) { @Override @SuppressWarnings("unchecked") @NotNull - public J add(@NotNull String text) { + public J add(@NotNull String text) + { setText(text); return (J) this; } @@ -425,10 +474,12 @@ public J add(@NotNull String text) { */ @Override @SuppressWarnings("unchecked") - public J addClass(@NotNull ICSSComponent classComponent) { + public J addClass(@NotNull ICSSComponent classComponent) + { String className = classComponent.getID(); add((C) classComponent); - if (!getClasses().contains(className)) { + if (!getClasses().contains(className)) + { addClass(className); } @@ -444,9 +495,11 @@ public J addClass(@NotNull ICSSComponent classComponent) { * @see com.jwebmp.core.base.interfaces.IComponentHierarchyBase#addClass(ICSSComponent) */ @Override - public J addClass(ICssClassName className, ICssClassName... classNames) { + public J addClass(ICssClassName className, ICssClassName... classNames) + { addClass(className); - for (ICssClassName name : classNames) { + for (ICssClassName name : classNames) + { addClass(name); } return (J) this; @@ -459,9 +512,11 @@ public J addClass(ICssClassName className, ICssClassName... classNames) { * @see com.jwebmp.core.base.interfaces.IComponentHierarchyBase#getAngularObjectsAll() */ @Override - public Map getAngularObjectsAll() { + public Map getAngularObjectsAll() + { Map map = getJsonObjects(); - for (IComponentHierarchyBase next : getChildrenHierarchy(true)) { + for (IComponentHierarchyBase next : getChildrenHierarchy(true)) + { processAngularObjects(next, map); } return map; @@ -475,8 +530,10 @@ public Map getAngularObjectsAll() { */ @Override @NotNull - public final Set getChildren() { - if (children == null) { + public final Set getChildren() + { + if (children == null) + { children = new LinkedHashSet<>(); } return children; @@ -487,7 +544,8 @@ public final Set getChildren() { * * @param children The children set to apply */ - public void setChildren(Set children) { + public void setChildren(Set children) + { this.children = children; } @@ -499,7 +557,8 @@ public void setChildren(Set children) { */ @Override @NotNull - public Set> getChildrenHierarchy() { + public Set> getChildrenHierarchy() + { return getChildrenHierarchy(true); } @@ -513,9 +572,11 @@ public void setChildren(Set children) { */ @Override @NotNull - public Set> getChildrenHierarchy(boolean includeSelf) { + public Set> getChildrenHierarchy(boolean includeSelf) + { Set> components = new LinkedHashSet<>(); - if (includeSelf) { + if (includeSelf) + { components.add(this); } getChildrenHierarchy(components); @@ -538,15 +599,18 @@ public void setChildren(Set children) { @Override @NotNull public Set> getChildrenHierarchy( - @NotNull Set> componentsToAddTo) { + @NotNull Set> componentsToAddTo) + { getChildren().forEach(child -> - { - if (child != null) { - componentsToAddTo.add((IComponentHierarchyBase) child); - child.cast().asHierarchyBase() - .getChildrenHierarchy(componentsToAddTo); - } - }); + { + if (child != null) + { + componentsToAddTo.add((IComponentHierarchyBase) child); + child.cast() + .asHierarchyBase() + .getChildrenHierarchy(componentsToAddTo); + } + }); return componentsToAddTo; } @@ -557,18 +621,21 @@ public void setChildren(Set children) { */ @Override @NotNull - public Set> getEventsAll() { + public Set> getEventsAll() + { Set> allEvents = new LinkedHashSet<>(); getChildrenHierarchy(true).stream() - .filter(Objects::nonNull) - .forEach(child -> { - for (Object event : child.asEventBase() - .getEvents()) { - if (event != null) { - allEvents.add((IEvent) event); - } - } - }); + .filter(Objects::nonNull) + .forEach(child -> { + for (Object event : child.asEventBase() + .getEvents()) + { + if (event != null) + { + allEvents.add((IEvent) event); + } + } + }); return allEvents; } @@ -580,8 +647,10 @@ public void setChildren(Set children) { */ @Override @NotNull - public IPage getPage() { - if (page == null) { + public IPage getPage() + { + if (page == null) + { setPage(new Page<>()); } return page; @@ -593,7 +662,8 @@ public IPage getPage() { * @return The parent object */ @Override - public IComponentHierarchyBase getParent() { + public IComponentHierarchyBase getParent() + { return parent; } @@ -605,7 +675,8 @@ public IPage getPage() { @Override @NotNull @SuppressWarnings("unchecked") - public J setParent(IComponentHierarchyBase parent) { + public J setParent(IComponentHierarchyBase parent) + { this.parent = parent; return (J) this; } @@ -621,7 +692,8 @@ public J setParent(IComponentHierarchyBase parent) { @Override @NotNull @SuppressWarnings("unchecked") - public J addClass(@NotNull String className) { + public J addClass(@NotNull String className) + { getClasses().add(className); return (J) this; } @@ -636,7 +708,8 @@ public J addClass(@NotNull String className) { */ @Override @SuppressWarnings("unchecked") - public J removeClass(String className) { + public J removeClass(String className) + { getClasses().remove(className); return (J) this; } @@ -651,9 +724,11 @@ public J removeClass(String className) { */ @Override @SuppressWarnings("unchecked") - public J removeClass(String className, String... classNames) { + public J removeClass(String className, String... classNames) + { this.removeClass(className); - for (String name : classNames) { + for (String name : classNames) + { this.removeClass(name); } return (J) this; @@ -666,9 +741,11 @@ public J removeClass(String className, String... classNames) { * @return */ @Override - public J removeClass(@NotNull Enum className, Enum... classNames) { + public J removeClass(@NotNull Enum className, Enum... classNames) + { this.removeClass(className); - for (Enum name : classNames) { + for (Enum name : classNames) + { this.removeClass(name); } return (J) this; @@ -681,11 +758,15 @@ public J removeClass(@NotNull Enum className, Enum... classNames) { * @return */ @Override - public boolean removeClass(@NotNull Enum className) { - if (getClasses().contains(className.toString())) { + public boolean removeClass(@NotNull Enum className) + { + if (getClasses().contains(className.toString())) + { getClasses().remove(className.toString()); return true; - } else { + } + else + { return false; } } @@ -700,7 +781,8 @@ public boolean removeClass(@NotNull Enum className) { @Override @NotNull @SuppressWarnings("unchecked") - public J addClass(@NotNull ICssClassName className) { + public J addClass(@NotNull ICssClassName className) + { getClasses().add(className.toString()); return (J) this; } @@ -713,8 +795,10 @@ public J addClass(@NotNull ICssClassName className) { */ @Override @NotNull - public Set getClasses() { - if (classes == null) { + public Set getClasses() + { + if (classes == null) + { classes = new LinkedHashSet<>(); } return classes; @@ -728,7 +812,8 @@ public Set getClasses() { @NotNull @SuppressWarnings("unchecked") @Override - public J setClasses(Set classes) { + public J setClasses(Set classes) + { this.classes = classes; return (J) this; } @@ -743,8 +828,10 @@ public J setClasses(Set classes) { @Override @NotNull @SuppressWarnings("unchecked") - public J addTheme(@NotNull Theme theme) { - if (!getThemes().contains(theme)) { + public J addTheme(@NotNull Theme theme) + { + if (!getThemes().contains(theme)) + { getThemes().add(theme); addClass(theme.getClassName()); } @@ -760,13 +847,17 @@ public J addTheme(@NotNull Theme theme) { */ @Override @NotNull - public Set getVariablesAll() { + public Set getVariablesAll() + { Set allVariables = new TreeSet<>(); getChildrenHierarchy().forEach(child -> { - if (child != null) { + if (child != null) + { for (Object o : child.asFeatureBase() - .getVariables()) { - if (o != null) { + .getVariables()) + { + if (o != null) + { allVariables.add(o.toString()); } } @@ -781,29 +872,39 @@ public Set getVariablesAll() { * @return */ @Override - public IComponentHierarchyBase getLoadingPart(IEvent... events) { - if (JWebMPSiteBinder.loadingPartClass != null) { + public IComponentHierarchyBase getLoadingPart(IEvent... events) + { + //todo update to use injected component for loader holder + /* if (JWebMPSiteBinder.loadingPartClass != null) + { ComponentHierarchyBase loadingPart = (ComponentHierarchyBase) IGuiceContext.get(JWebMPSiteBinder.loadingPartClass); loadingPart.setID(getID()); - for (IEvent event : events) { + for (IEvent event : events) + { loadingPart.addEvent(event); } return (IComponentHierarchyBase) loadingPart; - } + }*/ return null; } @Override - protected StringBuilder renderHTML(int tabCount) { + protected StringBuilder renderHTML(int tabCount) + { boolean renderChildren = true; Set htmlRenderTriggers = IGuiceContext.loaderToSet(ServiceLoader.load(IOnComponentHtmlRender.class)); - for (IOnComponentHtmlRender htmlRenderTrigger : htmlRenderTriggers) { - try { + for (IOnComponentHtmlRender htmlRenderTrigger : htmlRenderTriggers) + { + try + { boolean result = htmlRenderTrigger.onHtmlRender((ComponentHierarchyBase) this); - if (!result) { + if (!result) + { renderChildren = result; } - } catch (Throwable T) { + } + catch (Throwable T) + { log.log(Level.WARNING, "Error in processing html render interceptor", T); } } @@ -818,7 +919,8 @@ protected StringBuilder renderHTML(int tabCount) { * @return true if there are children attached */ @Override - public boolean hasChildren() { + public boolean hasChildren() + { return !getChildren().isEmpty(); } @@ -831,7 +933,8 @@ public boolean hasChildren() { * @return True if the child was part of this components children's list */ @Override - public boolean remove(C childToRemove) { + public boolean remove(C childToRemove) + { getChildren().remove(childToRemove); return true; } @@ -844,17 +947,19 @@ public boolean remove(C childToRemove) { */ @Override @NotNull - public StringBuilder renderJavascriptAll() { + public StringBuilder renderJavascriptAll() + { preConfigure(); StringBuilder sb = new StringBuilder(); Set allScripts = new LinkedHashSet<>(); Set queries = getQueriesAll(); queries.forEach(a -> - { - if (!Strings.isNullOrEmpty(a.toString())) { - allScripts.add(a.toString()); - } - }); + { + if (!Strings.isNullOrEmpty(a.toString())) + { + allScripts.add(a.toString()); + } + }); allScripts.forEach(sb.append(getNewLine())::append); return sb; } @@ -865,8 +970,10 @@ public StringBuilder renderJavascriptAll() { * @see ComponentHTMLAttributeBase#preConfigure() */ @Override - public void preConfigure() { - if (!isConfigured()) { + public void preConfigure() + { + if (!isConfigured()) + { setNewLineForClosingTag(hasChildren()); } super.preConfigure(); @@ -880,12 +987,14 @@ public void preConfigure() { */ @Override @NotNull - protected StringBuilder renderClasses() { + protected StringBuilder renderClasses() + { StringBuilder sb = new StringBuilder(); Set eachClass = getClasses(); eachClass.forEach(a -> sb.append(a) - .append(StaticStrings.STRING_SPACE)); - if (sb.length() > 0) { + .append(StaticStrings.STRING_SPACE)); + if (sb.length() > 0) + { sb.deleteCharAt(sb.length() - 1); } return sb; @@ -897,7 +1006,8 @@ protected StringBuilder renderClasses() { @Override @NotNull @SuppressWarnings("unchecked") - public J cloneComponent() { + public J cloneComponent() + { ComponentHierarchyBase cloned = super.cloneComponent(); //noinspection CastCanBeRemovedNarrowingVariableType return (J) cloned; @@ -911,12 +1021,15 @@ public J cloneComponent() { */ @Override @NotNull - public Set getQueriesAll() { + public Set getQueriesAll() + { Set reallyAllQueries = new LinkedHashSet<>(); Set> allComponents = getChildrenHierarchy(true); Consumer> action = componentQuery -> processComponentQueries(componentQuery, reallyAllQueries); - for (IComponentHierarchyBase allComponent : allComponents) { - if (allComponent != null) { + for (IComponentHierarchyBase allComponent : allComponents) + { + if (allComponent != null) + { action.accept(allComponent); } } @@ -931,15 +1044,18 @@ public Set getQueriesAll() { */ @Override @NotNull - public String toString() { + public String toString() + { getChildren().forEach(next -> - { - if (next != null) { - if (!next.isConfigured()) { - next.preConfigure(); - } - } - }); + { + if (next != null) + { + if (!next.isConfigured()) + { + next.preConfigure(); + } + } + }); return super.toString(); } @@ -950,18 +1066,19 @@ public String toString() { * @param reallyAllQueries */ @SuppressWarnings("unchecked") - private void processComponentQueries(@NotNull IComponentHierarchyBase componentQuery, @NotNull Set reallyAllQueries) { + private void processComponentQueries(@NotNull IComponentHierarchyBase componentQuery, @NotNull Set reallyAllQueries) + { reallyAllQueries.addAll(getQueries()); @SuppressWarnings("rawtypes") List> features = new ArrayList(componentQuery.asFeatureBase() - .getFeatures()); + .getFeatures()); features.forEach(feature -> reallyAllQueries.add(feature.renderJavascript())); features.sort(comparing(ComponentFeatureBase::getSortOrder)); Set events = (Set) componentQuery.asEventBase() - .getEvents(); + .getEvents(); events.forEach(event -> reallyAllQueries.add(((IComponentFeatureBase) event).asFeatureBase() - .renderJavascript())); + .renderJavascript())); features.sort(comparing(ComponentFeatureBase::getSortOrder)); } @@ -975,12 +1092,14 @@ private void processComponentQueries(@NotNull IComponentHierarchyBase comp */ @Override @SuppressWarnings("unchecked") - public J setPage(IPage page) { + public J setPage(IPage page) + { this.page = page; getChildren().stream() - .filter(a -> a != null) - .forEach(child -> child.cast().asHierarchyBase() - .setPage(page)); + .filter(a -> a != null) + .forEach(child -> child.cast() + .asHierarchyBase() + .setPage(page)); return (J) this; } @@ -990,18 +1109,26 @@ public J setPage(IPage page) { * @param next * @param map */ - private void processAngularObjects(@NotNull IComponentHierarchyBase next, @NotNull Map map) { + private void processAngularObjects(@NotNull IComponentHierarchyBase next, @NotNull Map map) + { for (Map.Entry entry : next.asAngularBase() - .getJsonObjects() - .entrySet()) { + .getJsonObjects() + .entrySet()) + { String key = entry.getKey(); Object value = entry.getValue(); - if (key != null) { - try { + if (key != null) + { + try + { map.put(key, value); - } catch (ClassCastException cce) { + } + catch (ClassCastException cce) + { ComponentHierarchyBase.log.log(Level.WARNING, "Incorrect Object Type, Perhaps JavaScriptPart?", cce); - } catch (Exception e) { + } + catch (Exception e) + { ComponentHierarchyBase.log.log(Level.WARNING, "Unable to render angular object", e); } } @@ -1016,19 +1143,26 @@ private void processAngularObjects(@NotNull IComponentHierarchyBase next, * @return */ @SuppressWarnings("unused") - public boolean readChildrenPropertyFirstResult(String propertyName, boolean returnBool) { - for (IComponentHierarchyBase next : getChildrenHierarchy(true)) { - if (next != null) { + public boolean readChildrenPropertyFirstResult(String propertyName, boolean returnBool) + { + for (IComponentHierarchyBase next : getChildrenHierarchy(true)) + { + if (next != null) + { if (next.asBase() .getProperties() - .containsKey(propertyName)) { + .containsKey(propertyName)) + { String propertyValue = next.asBase() - .getProperties() - .get(propertyName) - .toString(); - try { + .getProperties() + .get(propertyName) + .toString(); + try + { return Boolean.parseBoolean(propertyValue); - } catch (Exception e) { + } + catch (Exception e) + { ComponentHierarchyBase.log.log(Level.WARNING, "Property value was not a boolean.", e); } } @@ -1045,7 +1179,8 @@ public boolean readChildrenPropertyFirstResult(String propertyName, boolean retu * @return */ @Override - public > T findParent(Class parentType) { + public > T findParent(Class parentType) + { return findParent(this, parentType); } @@ -1057,11 +1192,14 @@ public boolean readChildrenPropertyFirstResult(String propertyName, boolean retu * @return */ @SuppressWarnings("unchecked") - private > T findParent(@NotNull IComponentHierarchyBase root, @NotNull Class parentType) { - if (root.getParent() != null) { + private > T findParent(@NotNull IComponentHierarchyBase root, @NotNull Class parentType) + { + if (root.getParent() != null) + { T found; found = (T) root.getParent(); - while (found != null && !parentType.isAssignableFrom(found.getClass())) { + while (found != null && !parentType.isAssignableFrom(found.getClass())) + { found = (T) found.getParent(); } return found; @@ -1075,14 +1213,16 @@ public boolean readChildrenPropertyFirstResult(String propertyName, boolean retu * @param childType of type Class T * @return T */ - @SuppressWarnings({"unchecked", "unused"}) + @SuppressWarnings({"unchecked", + "unused"}) @Override - public > T findChild(@NotNull Class childType) { + public > T findChild(@NotNull Class childType) + { return (T) getChildren().stream() - .filter(componentHierarchyBase -> componentHierarchyBase.getClass() - .equals(childType)) - .findFirst() - .orElse(null); + .filter(componentHierarchyBase -> componentHierarchyBase.getClass() + .equals(childType)) + .findFirst() + .orElse(null); } /** @@ -1094,10 +1234,13 @@ public boolean readChildrenPropertyFirstResult(String propertyName, boolean retu * @return The Obvious */ @SuppressWarnings("unused") - protected boolean containsClass(@NotNull Class classType) { - for (C next : getChildren()) { + protected boolean containsClass(@NotNull Class classType) + { + for (C next : getChildren()) + { if (next.getClass() - .equals(classType)) { + .equals(classType)) + { return true; } } @@ -1112,30 +1255,38 @@ protected boolean containsClass(@NotNull Class classType) { */ @Override @NotNull - protected StringBuilder renderChildren() { + protected StringBuilder renderChildren() + { StringBuilder sb = new StringBuilder(); - if (!renderChildren) { + if (!renderChildren) + { return sb; } - if (renderBeforeChildren() != null) { + if (renderBeforeChildren() != null) + { sb.append(renderBeforeChildren()); } CopyOnWriteArraySet objects = new CopyOnWriteArraySet<>(); objects.addAll(getChildren()); objects.stream() - .filter(Objects::nonNull) - .forEach(child -> { - try { + .filter(Objects::nonNull) + .forEach(child -> { + try + { sb.append(getNewLine()) - .append(child.toString(child.cast().asBase() - .isTiny() ? 0 : getCurrentTabIndents() + 1)); - } catch (Exception e) { + .append(child.toString(child.cast() + .asBase() + .isTiny() ? 0 : getCurrentTabIndents() + 1)); + } + catch (Exception e) + { log.log(Level.SEVERE, "Cannot work on child object - " + child.getClass() - .getCanonicalName() + "\n, adding to the tree\n", e); + .getCanonicalName() + "\n, adding to the tree\n", e); } } - ); - if (renderAfterChildren() != null) { + ); + if (renderAfterChildren() != null) + { sb.append(renderAfterChildren()); } return sb; @@ -1151,10 +1302,14 @@ protected StringBuilder renderChildren() { */ @Override @NotNull - public Boolean isNewLineForClosingTag() { - if (hasChildren() && !isTiny()) { + public Boolean isNewLineForClosingTag() + { + if (hasChildren() && !isTiny()) + { return true; - } else { + } + else + { return super.isNewLineForClosingTag(); } } @@ -1168,7 +1323,8 @@ public Boolean isNewLineForClosingTag() { */ @Override - protected StringBuilder renderBeforeChildren() { + protected StringBuilder renderBeforeChildren() + { return null; } @@ -1181,32 +1337,38 @@ protected StringBuilder renderBeforeChildren() { */ @Override - protected StringBuilder renderAfterChildren() { + protected StringBuilder renderAfterChildren() + { return null; } private Set configurations = new HashSet<>(); - protected Set getConfigurations() { - if (configurations == null) { + protected Set getConfigurations() + { + if (configurations == null) + { configurations = new HashSet<>(); } return configurations; } - public J addConfiguration(IConfiguration configuration) { + public J addConfiguration(IConfiguration configuration) + { getConfigurations().add(configuration); return (J) this; } - public Set getConfigurations(Class configurationType) { + public Set getConfigurations(Class configurationType) + { Set out = new LinkedHashSet<>(); - for (IComponentHierarchyBase iComponentHierarchyBase : getChildrenHierarchy(true)) { + for (IComponentHierarchyBase iComponentHierarchyBase : getChildrenHierarchy(true)) + { ComponentHierarchyBase chb = (ComponentHierarchyBase) iComponentHierarchyBase; out.addAll((Set) chb.getConfigurations() - .stream() - .filter(b -> configurationType.isAssignableFrom(b.getClass())) - .collect(Collectors.toSet())); + .stream() + .filter(b -> configurationType.isAssignableFrom(b.getClass())) + .collect(Collectors.toSet())); } return out; } @@ -1216,7 +1378,8 @@ public Set getConfigurations(Class configurationType) { * * @return */ - public boolean isRenderChildren() { + public boolean isRenderChildren() + { return renderChildren; } @@ -1226,7 +1389,8 @@ public boolean isRenderChildren() { * @param renderChildren * @return */ - public J setRenderChildren(boolean renderChildren) { + public J setRenderChildren(boolean renderChildren) + { this.renderChildren = renderChildren; return (J) this; } diff --git a/src/main/java/com/jwebmp/core/base/ContentSecurityPolicy.java b/src/main/java/com/jwebmp/core/base/ContentSecurityPolicy.java index f31108a50..18a08874a 100644 --- a/src/main/java/com/jwebmp/core/base/ContentSecurityPolicy.java +++ b/src/main/java/com/jwebmp/core/base/ContentSecurityPolicy.java @@ -1,26 +1,22 @@ package com.jwebmp.core.base; import com.google.common.base.Strings; -import com.google.inject.servlet.RequestScoped; -//import com.guicedee.guicedservlets.servlets.services.scopes.CallScope; import com.guicedee.guicedservlets.servlets.services.scopes.CallScope; import com.jwebmp.core.base.html.DivSimple; import com.jwebmp.core.base.interfaces.IContentSecurityPolicy; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.LinkedHashSet; import java.util.Set; import java.util.TreeSet; import static com.guicedee.services.jsonrepresentation.json.StaticStrings.STRING_SPACE; -import static com.jwebmp.core.base.html.attributes.MetaAttributes.*; -import static com.jwebmp.core.base.servlets.enumarations.ComponentTypes.*; +import static com.jwebmp.core.base.html.attributes.MetaAttributes.Http_Equiv; +import static com.jwebmp.core.base.servlets.enumarations.ComponentTypes.Metadata; @CallScope public class ContentSecurityPolicy extends DivSimple implements IContentSecurityPolicy, - com.jwebmp.core.base.html.interfaces.children.HeadChildren { + com.jwebmp.core.base.html.interfaces.children.HeadChildren +{ private static final String httpEquivName = "Content-Security-Policy"; @@ -46,60 +42,98 @@ public class ContentSecurityPolicy private final Set frameAncestors = new TreeSet<>(); private final Set pluginTypes = new TreeSet<>(); - public ContentSecurityPolicy() { + public ContentSecurityPolicy() + { setTag(Metadata); addAttribute(Http_Equiv.toString(), httpEquivName); } @Override - public void preConfigure() { - if (!isConfigured()) { + public void preConfigure() + { + if (!isConfigured()) + { StringBuilder output = new StringBuilder(); - if (!defaultSrc.isEmpty()) { - output.append("default-src ").append(setToList(defaultSrc)).append("; "); + if (!defaultSrc.isEmpty()) + { + output.append("default-src ") + .append(setToList(defaultSrc)) + .append("; "); } - if (!scriptSrc.isEmpty()) { - output.append("script-src ").append(setToList(scriptSrc)).append(" ; "); + if (!scriptSrc.isEmpty()) + { + output.append("script-src ") + .append(setToList(scriptSrc)) + .append(" ; "); } - if (!styleSrc.isEmpty()) { - output.append("style-src ").append(setToList(styleSrc)).append(" ; "); + if (!styleSrc.isEmpty()) + { + output.append("style-src ") + .append(setToList(styleSrc)) + .append(" ; "); } - if (!imgSrc.isEmpty()) { - output.append("img-src ").append(setToList(imgSrc)).append(" ; "); + if (!imgSrc.isEmpty()) + { + output.append("img-src ") + .append(setToList(imgSrc)) + .append(" ; "); } - if (!connectSrc.isEmpty()) { - output.append("connect-src ").append(setToList(connectSrc)).append(" ; "); + if (!connectSrc.isEmpty()) + { + output.append("connect-src ") + .append(setToList(connectSrc)) + .append(" ; "); } - if (!fontSrc.isEmpty()) { - output.append("font-src ").append(setToList(fontSrc)).append(" ; "); + if (!fontSrc.isEmpty()) + { + output.append("font-src ") + .append(setToList(fontSrc)) + .append(" ; "); } - if (!objectSrc.isEmpty()) { - output.append("object-src ").append(setToList(objectSrc)).append(" ; "); + if (!objectSrc.isEmpty()) + { + output.append("object-src ") + .append(setToList(objectSrc)) + .append(" ; "); } - if (!mediaSrc.isEmpty()) { - output.append("media-src ").append(setToList(mediaSrc)).append(" ; "); + if (!mediaSrc.isEmpty()) + { + output.append("media-src ") + .append(setToList(mediaSrc)) + .append(" ; "); } - if (!frameSrc.isEmpty()) { - output.append("frame-src ").append(setToList(frameSrc)).append(" ; "); + if (!frameSrc.isEmpty()) + { + output.append("frame-src ") + .append(setToList(frameSrc)) + .append(" ; "); } - if (!childSrc.isEmpty()) { - output.append("child-src ").append(setToList(childSrc)).append(" ; "); + if (!childSrc.isEmpty()) + { + output.append("child-src ") + .append(setToList(childSrc)) + .append(" ; "); } if (!Strings.isNullOrEmpty(output.toString())) + { addAttribute("content", output.toString()); + } super.preConfigure(); } } - public StringBuilder setToList(Set set) { + public StringBuilder setToList(Set set) + { StringBuilder output = new StringBuilder(); - set.forEach(s -> output.append(s).append(STRING_SPACE)); + set.forEach(s -> output.append(s) + .append(STRING_SPACE)); output.deleteCharAt(output.length() - 1); return output; } @Override - public ContentSecurityPolicy registerSelf() { + public ContentSecurityPolicy registerSelf() + { defaultSrc.add(self); scriptSrc.add(self); scriptSrc.add(unsafeInline); @@ -116,81 +150,97 @@ public ContentSecurityPolicy registerSelf() { return this; } - public IContentSecurityPolicy asMe() { + public IContentSecurityPolicy asMe() + { return this; } @Override - public Set getDefaultSrc() { + public Set getDefaultSrc() + { return defaultSrc; } @Override - public Set getScriptSrc() { + public Set getScriptSrc() + { return scriptSrc; } @Override - public Set getStyleSrc() { + public Set getStyleSrc() + { return styleSrc; } @Override - public Set getImgSrc() { + public Set getImgSrc() + { return imgSrc; } @Override - public Set getConnectSrc() { + public Set getConnectSrc() + { return connectSrc; } @Override - public Set getFontSrc() { + public Set getFontSrc() + { return fontSrc; } @Override - public Set getObjectSrc() { + public Set getObjectSrc() + { return objectSrc; } @Override - public Set getMediaSrc() { + public Set getMediaSrc() + { return mediaSrc; } @Override - public Set getFrameSrc() { + public Set getFrameSrc() + { return frameSrc; } @Override - public Set getSandbox() { + public Set getSandbox() + { return sandbox; } @Override - public Set getReportUi() { + public Set getReportUi() + { return reportUi; } @Override - public Set getChildSrc() { + public Set getChildSrc() + { return childSrc; } @Override - public Set getFormAction() { + public Set getFormAction() + { return formAction; } @Override - public Set getFrameAncestors() { + public Set getFrameAncestors() + { return frameAncestors; } - public Set getPluginTypes() { + public Set getPluginTypes() + { return pluginTypes; } diff --git a/src/main/java/com/jwebmp/core/base/page/ScriptsDynamicPageConfigurator.java b/src/main/java/com/jwebmp/core/base/page/ScriptsDynamicPageConfigurator.java index b6b9e6b01..953efc1ea 100644 --- a/src/main/java/com/jwebmp/core/base/page/ScriptsDynamicPageConfigurator.java +++ b/src/main/java/com/jwebmp/core/base/page/ScriptsDynamicPageConfigurator.java @@ -1,26 +1,23 @@ package com.jwebmp.core.base.page; -import com.guicedee.client.*; +import com.guicedee.client.IGuiceContext; +import com.guicedee.services.jsonrepresentation.json.StaticStrings; import com.jwebmp.core.Page; -import com.jwebmp.core.SessionHelper; -import com.jwebmp.core.base.interfaces.*; -import com.jwebmp.core.implementations.JWebMPSiteBinder; import com.jwebmp.core.base.ComponentHierarchyBase; -import com.jwebmp.core.base.html.CSSLink; import com.jwebmp.core.base.html.Paragraph; import com.jwebmp.core.base.html.Script; import com.jwebmp.core.base.html.Style; import com.jwebmp.core.base.html.attributes.ScriptAttributes; +import com.jwebmp.core.base.interfaces.IComponentHierarchyBase; import com.jwebmp.core.htmlbuilder.css.composer.CSSComposer; import com.jwebmp.core.services.*; -import com.guicedee.services.jsonrepresentation.json.StaticStrings; - - import jakarta.validation.constraints.NotNull; + import java.util.ServiceLoader; import java.util.Set; -import static com.jwebmp.core.implementations.JWebMPServicesBindings.*; +import static com.jwebmp.core.implementations.JWebMPServicesBindings.RenderAfterDynamicScriptsKey; +import static com.jwebmp.core.implementations.JWebMPServicesBindings.RenderBeforeDynamicScriptsKey; /** * Configures the dynamic script insertions that run last into the page @@ -30,236 +27,227 @@ */ @SuppressWarnings("unused") public class ScriptsDynamicPageConfigurator - implements IPageConfigurator + implements IPageConfigurator { - /** - * If this configurator is enabled - */ - private static boolean enabled = true; - - /** - * Constructor ScriptsDynamicPageConfigurator creates a new ScriptsDynamicPageConfigurator instance. - */ - public ScriptsDynamicPageConfigurator() - { - //No config required - } - - /** - * Method isEnabled returns the enabled of this AngularAnimatedChangePageConfigurator object. - *

- * If this configurator is enabled - * - * @return the enabled (type boolean) of this AngularAnimatedChangePageConfigurator object. - */ - public static boolean isEnabled() - { - return ScriptsDynamicPageConfigurator.enabled; - } - - /** - * Method setEnabled sets the enabled of this AngularAnimatedChangePageConfigurator object. - *

- * If this configurator is enabled - * - * @param mustEnable - * the enabled of this AngularAnimatedChangePageConfigurator object. - */ - public static void setEnabled(boolean mustEnable) - { - ScriptsDynamicPageConfigurator.enabled = mustEnable; - } - - /** - * Configures the given page for the parameters - * - * @param pager - * The page incoming - * - * @return The original page incoming or a new page, never null - */ - @NotNull - @Override - @SuppressWarnings("unchecked") - public Page configure(IPage pager) - { - Page page = (Page)pager; - if (!page.isConfigured() && enabled()) - { - //Render Before Dynamic Scripts - Paragraph beforeText = new Paragraph().setTextOnly(true); - StringBuilder sbBeforeText = new StringBuilder(); - Set beforeLoader = IGuiceContext.get(RenderBeforeDynamicScriptsKey); - for (RenderBeforeDynamicScripts renderAfterDynamicScripts : beforeLoader) - { - sbBeforeText.append(IGuiceContext.get(renderAfterDynamicScripts.getClass()) - .render(page) - .append(page.getNewLine())); - } - if (!sbBeforeText.toString() - .isEmpty()) - { - beforeText.setText(sbBeforeText.toString()); - page.getBody() - .add(beforeText); - } - - Style s = getCss(page); - if (page.getOptions() - .isDynamicRender()) - { - if (s != null) - { - page.getHead() + /** + * If this configurator is enabled + */ + private static boolean enabled = true; + + /** + * Constructor ScriptsDynamicPageConfigurator creates a new ScriptsDynamicPageConfigurator instance. + */ + public ScriptsDynamicPageConfigurator() + { + //No config required + } + + /** + * Method isEnabled returns the enabled of this AngularAnimatedChangePageConfigurator object. + *

+ * If this configurator is enabled + * + * @return the enabled (type boolean) of this AngularAnimatedChangePageConfigurator object. + */ + public static boolean isEnabled() + { + return ScriptsDynamicPageConfigurator.enabled; + } + + /** + * Method setEnabled sets the enabled of this AngularAnimatedChangePageConfigurator object. + *

+ * If this configurator is enabled + * + * @param mustEnable the enabled of this AngularAnimatedChangePageConfigurator object. + */ + public static void setEnabled(boolean mustEnable) + { + ScriptsDynamicPageConfigurator.enabled = mustEnable; + } + + /** + * Configures the given page for the parameters + * + * @param pager The page incoming + * @return The original page incoming or a new page, never null + */ + @NotNull + @Override + @SuppressWarnings("unchecked") + public Page configure(IPage pager) + { + Page page = (Page) pager; + if (!page.isConfigured() && enabled()) + { + //Render Before Dynamic Scripts + Paragraph beforeText = new Paragraph().setTextOnly(true); + StringBuilder sbBeforeText = new StringBuilder(); + Set beforeLoader = IGuiceContext.get(RenderBeforeDynamicScriptsKey); + for (RenderBeforeDynamicScripts renderAfterDynamicScripts : beforeLoader) + { + sbBeforeText.append(IGuiceContext.get(renderAfterDynamicScripts.getClass()) + .render(page) + .append(page.getNewLine())); + } + if (!sbBeforeText.toString() + .isEmpty()) + { + beforeText.setText(sbBeforeText.toString()); + page.getBody() + .add(beforeText); + } + + Style s = getCss(page); + if (page.getOptions() + .isDynamicRender()) + { + if (s != null) + { + /* page.getHead() .add(new CSSLink<>(SessionHelper.getServerPath() + JWebMPSiteBinder.getCSSLocation() - .replaceAll(StaticStrings.STRING_FORWARD_SLASH, StaticStrings.STRING_EMPTY))); - } - - Set dynamicRenderingServlets = IGuiceContext.instance() - .getLoader(IDynamicRenderingServlet.class, ServiceLoader.load(IDynamicRenderingServlet.class)); - for (IDynamicRenderingServlet dynamicRenderingServlet : dynamicRenderingServlets) - { - if (dynamicRenderingServlet.enabled()) - { - page.getBody() - .add(getDynamicReference(dynamicRenderingServlet.getScriptLocation(page))); - } - } - } - else - { - if (s != null) - { - page.getHead() - .add(s); - } - ComponentHierarchyBase addable; - if (page.getOptions() - .isScriptsInHead()) - { - addable = page.getHead(); - } - else - { - addable = page.getBody(); - } - - Set dynamicRenderingServlets = IGuiceContext.instance() - .getLoader(IDynamicRenderingServlet.class, ServiceLoader.load(IDynamicRenderingServlet.class)); - for (IDynamicRenderingServlet dynamicRenderingServlet : dynamicRenderingServlets) - { - if (dynamicRenderingServlet.enabled()) - { - IComponentHierarchyBase script = dynamicRenderingServlet.renderScript(page); - if (script != null) - { - addable.add(script); - } - } - } - } - //Render After Dynamic Scripts - Paragraph afterText = new Paragraph().setTextOnly(true); - StringBuilder sbAfterText = new StringBuilder(); - Set afterLoader = IGuiceContext.get(RenderAfterDynamicScriptsKey); - for (RenderAfterDynamicScripts renderAfterDynamicScripts : afterLoader) - { - sbAfterText.append(IGuiceContext - .get(renderAfterDynamicScripts.getClass()) - .render(page) - .append(page.getNewLine())); - } - if (!sbAfterText.toString() - .isEmpty()) - { - afterText.setText(sbAfterText.toString()); - page.getBody() - .add(afterText); - } - } - return page; - } - - @Override - public boolean enabled() - { - return ScriptsDynamicPageConfigurator.enabled; - } - - /** - * Method getCss returns the CSS for the page - * - * @param page - * of type Page - * - * @return Style - */ - private Style getCss(Page page) - { - CSSComposer comp = new CSSComposer(); - comp.addComponent(page, true); - String generated = comp.toString(); - - StringBuilder css = page.getBody() - .renderCss(0) - .append(generated); - if (css.toString() - .isEmpty()) - { - return null; - } - Style style = new Style(); - style.setText(css); - return style; - } - - /** - * Method getDynamicReference ... - * - * @param urlLocation - * of type String - * - * @return Script - */ - @NotNull - private Script getDynamicReference(String urlLocation) - { - Script jwScript = new Script(); - jwScript.addAttribute(ScriptAttributes.Type, StaticStrings.HTML_HEADER_JAVASCRIPT); - jwScript.addAttribute(ScriptAttributes.Src, SessionHelper.getServerPath() + urlLocation); - return jwScript; - } - - /** - * Method newScript ... - * - * @param contents - * of type String - * - * @return Script - */ - private Script newScript(String contents) - { - Script s = new Script(); - s.addAttribute(ScriptAttributes.Type, StaticStrings.HTML_HEADER_JAVASCRIPT); - s.setText(contents); - return s; - } - - /** - * Sort order for startup, Default 100. - * - * @return the sort order never null. Integer. MAX - * - * @see com.jwebmp.core.services.IPageConfigurator#sortOrder() - */ - @Override - public Integer sortOrder() - { - return Integer.MAX_VALUE; - } + .replaceAll(StaticStrings.STRING_FORWARD_SLASH, StaticStrings.STRING_EMPTY)));*/ + } + + Set dynamicRenderingServlets = IGuiceContext.instance() + .getLoader(IDynamicRenderingServlet.class, ServiceLoader.load(IDynamicRenderingServlet.class)); + for (IDynamicRenderingServlet dynamicRenderingServlet : dynamicRenderingServlets) + { + if (dynamicRenderingServlet.enabled()) + { + page.getBody() + .add(getDynamicReference(dynamicRenderingServlet.getScriptLocation(page))); + } + } + } + else + { + if (s != null) + { + page.getHead() + .add(s); + } + ComponentHierarchyBase addable; + if (page.getOptions() + .isScriptsInHead()) + { + addable = page.getHead(); + } + else + { + addable = page.getBody(); + } + + Set dynamicRenderingServlets = IGuiceContext.instance() + .getLoader(IDynamicRenderingServlet.class, ServiceLoader.load(IDynamicRenderingServlet.class)); + for (IDynamicRenderingServlet dynamicRenderingServlet : dynamicRenderingServlets) + { + if (dynamicRenderingServlet.enabled()) + { + IComponentHierarchyBase script = dynamicRenderingServlet.renderScript(page); + if (script != null) + { + addable.add(script); + } + } + } + } + //Render After Dynamic Scripts + Paragraph afterText = new Paragraph().setTextOnly(true); + StringBuilder sbAfterText = new StringBuilder(); + Set afterLoader = IGuiceContext.get(RenderAfterDynamicScriptsKey); + for (RenderAfterDynamicScripts renderAfterDynamicScripts : afterLoader) + { + sbAfterText.append(IGuiceContext + .get(renderAfterDynamicScripts.getClass()) + .render(page) + .append(page.getNewLine())); + } + if (!sbAfterText.toString() + .isEmpty()) + { + afterText.setText(sbAfterText.toString()); + page.getBody() + .add(afterText); + } + } + return page; + } + + @Override + public boolean enabled() + { + return ScriptsDynamicPageConfigurator.enabled; + } + + /** + * Method getCss returns the CSS for the page + * + * @param page of type Page + * @return Style + */ + private Style getCss(Page page) + { + CSSComposer comp = new CSSComposer(); + comp.addComponent(page, true); + String generated = comp.toString(); + + StringBuilder css = page.getBody() + .renderCss(0) + .append(generated); + if (css.toString() + .isEmpty()) + { + return null; + } + Style style = new Style(); + style.setText(css); + return style; + } + + /** + * Method getDynamicReference ... + * + * @param urlLocation of type String + * @return Script + */ + @NotNull + private Script getDynamicReference(String urlLocation) + { + Script jwScript = new Script(); + jwScript.addAttribute(ScriptAttributes.Type, StaticStrings.HTML_HEADER_JAVASCRIPT); + //todo script reference + //jwScript.addAttribute(ScriptAttributes.Src, SessionHelper.getServerPath() + urlLocation); + return jwScript; + } + + /** + * Method newScript ... + * + * @param contents of type String + * @return Script + */ + private Script newScript(String contents) + { + Script s = new Script(); + s.addAttribute(ScriptAttributes.Type, StaticStrings.HTML_HEADER_JAVASCRIPT); + s.setText(contents); + return s; + } + + /** + * Sort order for startup, Default 100. + * + * @return the sort order never null. Integer. MAX + * @see com.jwebmp.core.services.IPageConfigurator#sortOrder() + */ + @Override + public Integer sortOrder() + { + return Integer.MAX_VALUE; + } } diff --git a/src/main/java/com/jwebmp/core/base/servlets/AjaxReceiverServlet.java b/src/main/java/com/jwebmp/core/base/servlets/AjaxReceiverServlet.java deleted file mode 100644 index 60f00affc..000000000 --- a/src/main/java/com/jwebmp/core/base/servlets/AjaxReceiverServlet.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core.base.servlets; - -import com.google.inject.Singleton; -import com.guicedee.guicedservlets.GuicedServletKeys; -import com.guicedee.services.jsonrepresentation.IJsonRepresentation; -import com.jwebmp.core.Event; -import com.jwebmp.core.base.ajax.*; -import com.jwebmp.core.exceptions.InvalidRequestException; -import com.jwebmp.core.exceptions.MissingComponentException; -import com.jwebmp.core.utilities.TextUtilities; -import com.jwebmp.interception.services.AjaxCallIntercepter; -import jakarta.servlet.http.HttpServletRequest; -import lombok.extern.java.Log; - -import java.util.logging.Level; - -import static com.guicedee.client.IGuiceContext.get; -import static com.guicedee.services.jsonrepresentation.json.StaticStrings.CHAR_DOT; -import static com.guicedee.services.jsonrepresentation.json.StaticStrings.CHAR_UNDERSCORE; -import static com.jwebmp.interception.JWebMPInterceptionBinder.AjaxCallInterceptorKey; -import static java.nio.charset.StandardCharsets.UTF_8; - -/** - * Handles all AJAX Requests performed by a client connection. Session codes are used in order to identify - *

- * - * @author GedMarc - */ -@Singleton -@Log -public class AjaxReceiverServlet - extends JWDefaultServlet -{ - public AjaxReceiverServlet() - { - //Quick construction - } - - @Override - public void perform() - { - StringBuilder output = new StringBuilder(); - HttpServletRequest request = get(GuicedServletKeys.getHttpServletRequestKey()); - try - { - AjaxCall ajaxCallIncoming = IJsonRepresentation.From(request.getInputStream(), AjaxCall.class); - AjaxCall ajaxCall = get(AjaxCall.class); - ajaxCall.fromCall(ajaxCallIncoming); - ajaxCall.setPageCall(true); - AjaxResponse ajaxResponse = get(AjaxResponse.class); - - validateCall(ajaxCall); - validatePage(); - validateRequest(ajaxCall); - Event triggerEvent = processEvent(); - - for (AjaxCallIntercepter ajaxCallIntercepter : get(AjaxCallInterceptorKey)) - { - ajaxCallIntercepter.intercept(ajaxCall, ajaxResponse); - } - - triggerEvent.fireEvent(ajaxCall, ajaxResponse); - - output = new StringBuilder(ajaxResponse.toString()); - } - catch (InvalidRequestException ie) - { - AjaxResponse ajaxResponse = new AjaxResponse<>(); - ajaxResponse.setSuccess(false); - AjaxResponseReaction arr = new AjaxResponseReaction<>("Invalid Request Value", "A value in the request was found to be incorrect.
" + ie.getMessage(), - ReactionType.DialogDisplay); - arr.setResponseType(AjaxResponseType.Danger); - ajaxResponse.addReaction(arr); - output = new StringBuilder(ajaxResponse.toString()); - AjaxReceiverServlet.log.log(Level.SEVERE, "[SessionID]-[" + request.getSession() - .getId() + "];" + "[Exception]-[Invalid Request]", ie); - } - catch (MissingComponentException mce) - { - AjaxResponse ajaxResponse = new AjaxResponse<>(); - ajaxResponse.setSuccess(false); - AjaxResponseReaction arr = new AjaxResponseReaction<>("Invalid Request Value", "The specified Component ID does not seem linked to the page.
" + mce.getMessage(), - ReactionType.DialogDisplay); - arr.setResponseType(AjaxResponseType.Danger); - ajaxResponse.addReaction(arr); - output = new StringBuilder(ajaxResponse.toString()); - AjaxReceiverServlet.log.log(Level.SEVERE, "[SessionID]-[" + request.getSession() - .getId() + "];" + "[Exception]-[Missing Component]", mce); - } - catch (Exception T) - { - AjaxResponse ajaxResponse = new AjaxResponse<>(); - ajaxResponse.setSuccess(false); - AjaxResponseReaction arr = new AjaxResponseReaction<>("Unknown Error", - "An AJAX call resulted in an unknown server error
" + T.getMessage() + "
" + TextUtilities.stackTraceToString( - T), ReactionType.DialogDisplay); - arr.setResponseType(AjaxResponseType.Danger); - ajaxResponse.addReaction(arr); - output = new StringBuilder(ajaxResponse.toString()); - AjaxReceiverServlet.log.log(Level.SEVERE, "Unknown in ajax reply\n", T); - } - finally - { - writeOutput(output, "application/json;charset=UTF-8", UTF_8); - } - } - - protected Event processEvent() throws InvalidRequestException - { - Event triggerEvent = null; - try - { - AjaxCall call = get(AjaxCall.class); - Class eventClass = Class.forName(call.getClassName() - .replace(CHAR_UNDERSCORE, CHAR_DOT)); - triggerEvent = (Event) get(eventClass); - } - catch (ClassNotFoundException cnfe) - { - AjaxReceiverServlet.log.log(Level.FINEST, "Unable to find the event class specified", cnfe); - throw new InvalidRequestException("The Event To Be Triggered Could Not Be Found"); - } - return triggerEvent; - } -} diff --git a/src/main/java/com/jwebmp/core/base/servlets/CSSServlet.java b/src/main/java/com/jwebmp/core/base/servlets/CSSServlet.java deleted file mode 100644 index d2c3400e5..000000000 --- a/src/main/java/com/jwebmp/core/base/servlets/CSSServlet.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core.base.servlets; - -import com.google.inject.Singleton; -import com.guicedee.client.*; -import com.jwebmp.core.Page; -import com.guicedee.services.jsonrepresentation.json.StaticStrings; - -import com.guicedee.guicedservlets.GuicedServletKeys; -import com.jwebmp.core.services.IPage; - -/** - * This Servlet supplies all the JavaScript for a given HTML Page - * - * @author GedMarc - */ -@Singleton -public class CSSServlet - extends JWDefaultServlet -{ - @Override - public void perform() - { - @SuppressWarnings("MismatchedQueryAndUpdateOfStringBuilder") - StringBuilder scripts = new StringBuilder(); - Page page = (Page) IGuiceContext.get(IPage.class); - StringBuilder css = page.getBody() - .renderCss(0); - scripts.append(css); - writeOutput(css, StaticStrings.HTML_HEADER_CSS, StaticStrings.UTF_CHARSET); - } -} diff --git a/src/main/java/com/jwebmp/core/base/servlets/DataServlet.java b/src/main/java/com/jwebmp/core/base/servlets/DataServlet.java deleted file mode 100644 index ab04a7335..000000000 --- a/src/main/java/com/jwebmp/core/base/servlets/DataServlet.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core.base.servlets; - -import com.google.inject.Singleton; -import com.guicedee.guicedservlets.GuicedServletKeys; -import com.guicedee.services.jsonrepresentation.json.StaticStrings; -import com.jwebmp.core.Page; -import com.jwebmp.core.base.ajax.AjaxCall; -import com.jwebmp.core.base.ajax.AjaxResponse; -import com.jwebmp.core.base.servlets.interfaces.IDataComponent; -import com.jwebmp.interception.services.DataCallIntercepter; -import jakarta.servlet.http.HttpServletRequest; -import lombok.extern.java.Log; - -import static com.guicedee.client.IGuiceContext.get; -import static com.jwebmp.interception.JWebMPInterceptionBinder.DataCallInterceptorKey; - -/** - * Provides the data for a specific component - * - * @author GedMarc - * @version 1.0 - * @since Nov 15, 2016 - */ -@Singleton -@Log -public class DataServlet - extends JWDefaultServlet -{ - - /** - * A data server - */ - public DataServlet() - { - //Nothing Needed - } - - /** - * When to perform any commands - */ - @Override - @SuppressWarnings("unchecked") - public void perform() - { - HttpServletRequest request = get(GuicedServletKeys.getHttpServletRequestKey()); - String componentID = request.getParameter("component"); - StringBuilder responseString = new StringBuilder(); - try - { - Class clazz = (Class) Class.forName( - componentID.replace(StaticStrings.CHAR_UNDERSCORE, StaticStrings.CHAR_DOT)); - IDataComponent component = get(clazz); - StringBuilder renderData = component.renderData(); - responseString.append(renderData); - } - catch (Exception e) - { - Page p = getErrorPageHtml(e); - writeOutput(new StringBuilder(p.toString(0)), StaticStrings.HTML_HEADER_DEFAULT_CONTENT_TYPE, StaticStrings.UTF_CHARSET); - return; - } - for (DataCallIntercepter dataCallIntercepter : get(DataCallInterceptorKey)) - { - dataCallIntercepter.intercept(get(AjaxCall.class),get(AjaxResponse.class)); - } - writeOutput(responseString, StaticStrings.HTML_HEADER_JSON, StaticStrings.UTF_CHARSET); - } - -} diff --git a/src/main/java/com/jwebmp/core/base/servlets/JWDefaultServlet.java b/src/main/java/com/jwebmp/core/base/servlets/JWDefaultServlet.java deleted file mode 100644 index c4e322ad8..000000000 --- a/src/main/java/com/jwebmp/core/base/servlets/JWDefaultServlet.java +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core.base.servlets; - -import com.guicedee.client.*; - -import com.guicedee.guicedservlets.GuicedServletKeys; -import com.guicedee.services.jsonrepresentation.json.StaticStrings; -import com.jwebmp.core.Page; -import com.jwebmp.core.base.ajax.AjaxCall; -import com.jwebmp.core.base.ajax.AjaxResponse; -import com.jwebmp.core.base.html.Body; -import com.jwebmp.core.base.html.PreFormattedText; -import com.jwebmp.core.exceptions.InvalidRequestException; -import com.jwebmp.core.exceptions.MissingComponentException; -import com.jwebmp.core.htmlbuilder.javascript.events.enumerations.EventTypes; -import com.jwebmp.core.services.IErrorPage; -import com.jwebmp.core.utilities.TextUtilities; -import com.jwebmp.interception.services.SiteCallIntercepter; -import jakarta.servlet.http.HttpServlet; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.constraints.NotNull; -import lombok.extern.java.Log; - -import java.io.IOException; -import java.io.PrintWriter; -import java.nio.charset.Charset; -import java.util.Date; -import java.util.ServiceLoader; -import java.util.Set; -import java.util.logging.Level; - -import static com.guicedee.client.IGuiceContext.get; -import static com.jwebmp.interception.JWebMPInterceptionBinder.SiteCallInterceptorKey; - -/** - * Provides default methods for authentication authorization etc - * - * @author GedMarc - * @version 1.0 - * @since Nov 14, 2016 - */ -@Log -@SuppressWarnings("unused") -public abstract class JWDefaultServlet - extends HttpServlet -{ - /** - * Field allowOrigin - */ - private static String allowOrigin = "*"; - - /** - * Construct a new default servlett - */ - public JWDefaultServlet() - { - //Nothing needed - } - - /** - * Sets the stream allow origins - * - * @return The current origins allowed - */ - public static String getAllowOrigin() - { - return JWDefaultServlet.allowOrigin; - } - - /** - * Sets the streams allow origins - * - * @param allowOrigin The allowed origins, default * - */ - public static void setAllowOrigin(@NotNull String allowOrigin) - { - JWDefaultServlet.allowOrigin = allowOrigin; - } - - /** - * Validates the given call for the servlet - * - * @param ajaxCall optional parameter to validate on more fields - * - * @return If this call is valid - */ - @SuppressWarnings({"WeakerAccess", "UnusedReturnValue"}) - public boolean validateCall(AjaxCall ajaxCall) throws InvalidRequestException - { - HttpServletRequest request = get(GuicedServletKeys.getHttpServletRequestKey()); - if (ajaxCall.getComponentId() == null) - { - JWDefaultServlet.log.log(Level.SEVERE, "[SessionID]-[{0}];[Security]-[Component ID Not Found]", request.getSession() - .getId()); - throw new InvalidRequestException("There is no Component ID in this call."); - } - - String componentId = ajaxCall.getComponentId(); - if (componentId.isEmpty()) - { - JWDefaultServlet.log.log(Level.FINER, "[SessionID]-[{0}];[Security]-[Component ID Incorrect]", request.getSession() - .getId()); - } - return true; - } - - /** - * Validates if the page is found and correct - * - * @return If the page can be retrieved - * - * @throws com.jwebmp.core.exceptions.MissingComponentException if page returned is null - */ - @SuppressWarnings({"WeakerAccess", "UnusedReturnValue"}) - public boolean validatePage() throws MissingComponentException - { - Page page = get(Page.class); - if (page == null) - { - throw new MissingComponentException( - "Page has not been bound yet. Please use a binder to map Page to the required page object. Also consider using a @Provides method to apply custom logic. See https://github.com/google/guice/wiki/ProvidesMethods "); - } - return true; - } - - /** - * Validates the request if it from a legitimate source - * - * @param ajaxCall The incoming call object - * - * @return if the request was validated - * - * @throws InvalidRequestException If the request is invalid - */ - @SuppressWarnings({"WeakerAccess", "UnusedReturnValue"}) - public boolean validateRequest(AjaxCall ajaxCall) throws InvalidRequestException - { - HttpServletRequest request = get(GuicedServletKeys.getHttpServletRequestKey()); - Date datetime = ajaxCall.getDatetime(); - if (datetime == null) - { - JWDefaultServlet.log.log(Level.SEVERE, "[SessionID]-[{0}];[Security]-[Date Time Incorrect]", request.getSession() - .getId()); - throw new InvalidRequestException("Invalid Date Time Value"); - } - EventTypes eventType = (EventTypes) ajaxCall.getEventType(); - if (eventType == null) - { - JWDefaultServlet.log.log(Level.SEVERE, "[SessionID]-[{0}];[Security]-[Event Type Incorrect]", request.getSession() - .getId()); - throw new InvalidRequestException("Invalid Event Type"); - } - for (SiteCallIntercepter siteCallIntercepter : get(SiteCallInterceptorKey)) - { - siteCallIntercepter.intercept(ajaxCall, IGuiceContext.get(AjaxResponse.class)); - } - - return true; - } - - /** - * Generates the Page HTML - * - * @return The page html - */ - @SuppressWarnings("WeakerAccess") - protected StringBuilder getPageHTML() - { - StringBuilder html; - - - - try - { - html = new StringBuilder(getPageFromGuice().toString(true)); - } - catch (Throwable T) - { - return new StringBuilder(getErrorPageHtml(T).toString(0)); - } - return html; - } - - /** - * Finds the page for the current URL - * - * @return The page instance - */ - @SuppressWarnings("WeakerAccess") - protected Page getPageFromGuice() - { - Page p = get(Page.class); - p.getOptions() - .setGenerator("JWebMP - https://www.jwebmp.com"); - return p; - } - - /** - * In the event of any error return this page. - * - * @param t The exception thrown - * - * @return The rendered HTML. - */ - @SuppressWarnings({"WeakerAccess"}) - protected Page getErrorPageHtml(Throwable t) - { - JWDefaultServlet.log.log(Level.SEVERE, "Exception incoming", t); - Set errorPages = IGuiceContext.instance() - .getLoader(IErrorPage.class, ServiceLoader.load(IErrorPage.class)); - if (!errorPages.iterator() - .hasNext()) - { - Page p = new Page<>(); - p.getOptions() - .setTitle("Exception occurred in application"); - p.getOptions() - .setAuthor("GedMarc"); - p.getOptions() - .setDescription("JWebMP Error Generated Page"); - p.getOptions() - .setGenerator("JWebMP - https://www.jwebmp.com"); - - Body b = p.getBody(); - b.add("The following error was encountered during render


"); - b.add(new PreFormattedText<>(TextUtilities.stackTraceToString(t))); - return p; - } - else - { - IErrorPage p = get(errorPages.iterator() - .next() - .getClass()); - return (Page) p.renderPage(t); - } - } - - /** - * Does a default security check on the request - * - * @param req The request - * @param resp The response - */ - @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) - { - // scope.enter(); - try - { - perform(); - } - catch (Exception e) - { - JWDefaultServlet.log.log(Level.SEVERE, "Unable to Do Get", e); - }finally { - // scope.exit(); - } - } - - /** - * When to perform any commands - */ - public abstract void perform(); - - /** - * The output to write to the output stream - * - * @param output The specified output - * @param contentType The content type to send out - * @param charSet The charset to use - */ - public void writeOutput(StringBuilder output, String contentType, Charset charSet) - { - HttpServletResponse response = get(GuicedServletKeys.getHttpServletResponseKey()); - try (PrintWriter out = response.getWriter()) - { - Date dataTransferDate = new Date(); - response.setContentType(contentType); - response.setCharacterEncoding(charSet == null ? StaticStrings.UTF_CHARSET - .toString() : charSet.displayName()); - response.setHeader(StaticStrings.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER_NAME, JWDefaultServlet.allowOrigin); - response.setHeader(StaticStrings.ACCESS_CONTROL_ALLOW_CREDENTIALS_HEADER_NAME, "true"); - response.setHeader(StaticStrings.ACCESS_CONTROL_ALLOW_METHODS_HEADER_NAME, "GET, POST"); - response.setHeader(StaticStrings.ACCESS_CONTROL_ALLOW_HEADERS_HEADER_NAME, "Content-Type, Accept"); - out.write(output.toString()); - - long transferTime = new Date().getTime() - dataTransferDate.getTime(); - JWDefaultServlet.log.log(Level.FINER, "[Network Reply Data Size]-[" + output.length() + "];"); - JWDefaultServlet.log.log(Level.FINER, "[Network Reply]-[" + output + "];[Time]-[" + transferTime + "];"); - } - catch (IOException io) - { - JWDefaultServlet.log.log(Level.SEVERE, "Unable to send response to client", io); - } - } - - /** - * Does a default security check on the request - * - * @param req The request - * @param resp The response - */ - @Override - protected void doPost(HttpServletRequest req, HttpServletResponse resp) - { - try - { - perform(); - } - catch (Exception e) - { - JWDefaultServlet.log.log(Level.SEVERE, "Security Exception in Validation", e); - } - } - -} diff --git a/src/main/java/com/jwebmp/core/base/servlets/JWScriptServlet.java b/src/main/java/com/jwebmp/core/base/servlets/JWScriptServlet.java deleted file mode 100644 index 55bb8fd90..000000000 --- a/src/main/java/com/jwebmp/core/base/servlets/JWScriptServlet.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core.base.servlets; - -import com.google.inject.*; -import com.guicedee.client.*; -import com.guicedee.services.jsonrepresentation.json.*; -import com.guicedee.guicedservlets.*; -import com.jwebmp.core.*; -import jakarta.servlet.http.*; - -import static com.guicedee.client.IGuiceContext.*; - -/** - * @author GedMarc - */ -@Singleton -public class JWScriptServlet - extends JWDefaultServlet -{ - /** - * Field FILE_TEMPLATE_NAME - */ - public static final String FILE_TEMPLATE_NAME = "jwscript"; - - /** - * When to perform any commands - */ - @Override - public void perform() - { - HttpServletRequest request = IGuiceContext.get(GuicedServletKeys.getHttpServletRequestKey()); - FileTemplates.getFileTemplate(JWScriptServlet.class, JWScriptServlet.FILE_TEMPLATE_NAME, "siteloader"); - FileTemplates.getTemplateVariables() - .put("SITEADDRESSINSERT", new StringBuilder(SessionHelper.getServerPath())); - FileTemplates.getTemplateVariables() - .put("ROOTADDRESSINSERT", new StringBuilder(SessionHelper.getServerRootPath())); - try - { - FileTemplates.getTemplateVariables() - .put("PAGECLASS", new StringBuilder(IGuiceContext.get(Page.class) - .getClass() - .getCanonicalName())); - - } - catch (ProvisionException | OutOfScopeException e) - { - FileTemplates.getTemplateVariables() - .put("PAGECLASS", new StringBuilder()); - } - - try - { - HttpServletRequest hsr = get(HttpServletRequest.class); - FileTemplates.getTemplateVariables() - .put("%USERAGENT%", new StringBuilder(hsr.getHeader("user-agent"))); - FileTemplates.getTemplateVariables() - .put("%MYIP%", new StringBuilder(hsr.getRemoteAddr())); - FileTemplates.getTemplateVariables() - .put("%REFERER%", new StringBuilder(hsr.getHeader("referer"))); - } - catch (Throwable T) - { - - } - StringBuilder output = FileTemplates.renderTemplateScripts(JWScriptServlet.FILE_TEMPLATE_NAME); - writeOutput(output, StaticStrings.HTML_HEADER_JAVASCRIPT, StaticStrings.UTF_CHARSET); - } - -} diff --git a/src/main/java/com/jwebmp/core/base/servlets/JWebMPServlet.java b/src/main/java/com/jwebmp/core/base/servlets/JWebMPServlet.java deleted file mode 100644 index 4bd66f341..000000000 --- a/src/main/java/com/jwebmp/core/base/servlets/JWebMPServlet.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core.base.servlets; - -import com.google.inject.Singleton; - -import com.guicedee.client.*; -import com.guicedee.guicedservlets.GuicedServletKeys; -import com.guicedee.services.jsonrepresentation.json.StaticStrings; -import jakarta.servlet.http.HttpServletResponse; -import lombok.extern.java.Log; - -import java.util.logging.Level; - -/** - * The base Servlet for the JWebSwing environment. Constructs each page on call - * - * @author GedMarc - * @version 1.1 - * @since 2012/10/09 - */ -@Singleton -@Log -public class JWebMPServlet - extends JWDefaultServlet -{ - - /** - * Constructs a new JWebSwing Servlet that is not session aware - */ - public JWebMPServlet() - { - //Nothing Needed - } - - /** - * When to perform any commands - */ - @Override - public void perform() - { - - HttpServletResponse response = IGuiceContext.get(GuicedServletKeys.getHttpServletResponseKey()); - sendPage(response); - } - - /** - * Sends the page out - * - * @param response - * The response object - */ - private void sendPage(HttpServletResponse response) - { - response.setContentType(StaticStrings.HTML_HEADER_DEFAULT_CONTENT_TYPE); - writeOutput(getPageHTML(), StaticStrings.HTML_HEADER_DEFAULT_CONTENT_TYPE, StaticStrings.UTF_CHARSET); - } - - /** - * Destroys this object and all references to it - */ - @Override - public void destroy() - { - try - { - JWebMPServlet.log.log(Level.INFO, "Destroying Servlet JWebMP Servlet and all Static Objects"); - IGuiceContext.getContext().destroy(); - } - catch (Exception t) - { - JWebMPServlet.log.log(Level.SEVERE, "Unable to destroy", t); - } - super.destroy(); - } -} diff --git a/src/main/java/com/jwebmp/core/base/servlets/JavaScriptServlet.java b/src/main/java/com/jwebmp/core/base/servlets/JavaScriptServlet.java deleted file mode 100644 index 59608336d..000000000 --- a/src/main/java/com/jwebmp/core/base/servlets/JavaScriptServlet.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core.base.servlets; - -import com.google.inject.Singleton; -import com.guicedee.client.*; -import com.jwebmp.core.FileTemplates; -import com.jwebmp.core.Page; -import com.guicedee.services.jsonrepresentation.json.StaticStrings; - -import com.guicedee.guicedservlets.GuicedServletKeys; -import com.jwebmp.core.base.ajax.AjaxCall; -import com.jwebmp.core.base.ajax.AjaxResponse; -import com.jwebmp.core.services.IPage; -import com.jwebmp.interception.services.AjaxCallIntercepter; - -import jakarta.servlet.http.HttpServletRequest; - -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; - -import static com.guicedee.client.IGuiceContext.get; -import static com.jwebmp.core.implementations.JWebMPJavaScriptDynamicScriptRenderer.renderJavascript; -import static com.jwebmp.interception.JWebMPInterceptionBinder.*; -import static java.nio.charset.StandardCharsets.UTF_8; - -/** - * This Servlet supplies all the JavaScript for a given HTML Page - * - * @author GedMarc - */ -@Singleton -public class JavaScriptServlet - extends JWDefaultServlet -{ - /** - * Field scriptReplacement - */ - private static final String scriptReplacement = "JW_JAVASCRIPT;"; - - /** - * When to perform any commands - */ - @Override - public void perform() - { - if(renderJavascript) { - Page page = (Page) get(IPage.class); - for (AjaxCallIntercepter ajaxCallIntercepter : get(AjaxCallInterceptorKey)) { - - ajaxCallIntercepter.intercept(IGuiceContext.get(AjaxCall.class), IGuiceContext.get(AjaxResponse.class)); - } - page.toString(0); - FileTemplates.removeTemplate(JavaScriptServlet.scriptReplacement); - FileTemplates.getFileTemplate(JavaScriptServlet.class, JavaScriptServlet.scriptReplacement, "javascriptScript"); - FileTemplates.getTemplateVariables() - .put(JavaScriptServlet.scriptReplacement, page.renderJavascript()); - StringBuilder scripts = FileTemplates.renderTemplateScripts(JavaScriptServlet.scriptReplacement); - writeOutput(scripts, StaticStrings.HTML_HEADER_JAVASCRIPT, UTF_8); - FileTemplates.getTemplateVariables() - .remove(JavaScriptServlet.scriptReplacement); - } - } -} diff --git a/src/main/java/com/jwebmp/core/base/servlets/javascriptScript.js b/src/main/java/com/jwebmp/core/base/servlets/javascriptScript.js deleted file mode 100644 index 47674a61a..000000000 --- a/src/main/java/com/jwebmp/core/base/servlets/javascriptScript.js +++ /dev/null @@ -1 +0,0 @@ -JW_JAVASCRIPT; \ No newline at end of file diff --git a/src/main/java/com/jwebmp/core/base/servlets/javascriptScript.min.js b/src/main/java/com/jwebmp/core/base/servlets/javascriptScript.min.js deleted file mode 100644 index 47674a61a..000000000 --- a/src/main/java/com/jwebmp/core/base/servlets/javascriptScript.min.js +++ /dev/null @@ -1 +0,0 @@ -JW_JAVASCRIPT; \ No newline at end of file diff --git a/src/main/java/com/jwebmp/core/base/servlets/options/AngularDataServletInitData.java b/src/main/java/com/jwebmp/core/base/servlets/options/AngularDataServletInitData.java deleted file mode 100644 index 0c6d9713c..000000000 --- a/src/main/java/com/jwebmp/core/base/servlets/options/AngularDataServletInitData.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core.base.servlets.options; - -import com.google.inject.servlet.RequestScoped; -import com.jwebmp.core.htmlbuilder.javascript.JavaScriptPart; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author GedMarc - * @since 05 Apr 2017 - */ -@RequestScoped -public class AngularDataServletInitData> - extends JavaScriptPart -{ - /** - * The local storage map to be set for the provider - */ - private Map localStorage; - /** - * The session storage map - */ - private Map sessionStorage; - /** - * The parameters for the initialized data - */ - private Map parameters; - - /* - * Constructs a new AngularDataServletInitData - */ - public AngularDataServletInitData() - { - //Nothing needed - } - - public Map getLocalStorage() - { - return localStorage; - } - - public void setLocalStorage(Map localStorage) - { - this.localStorage = localStorage; - } - - public Map getSessionStorage() - { - return sessionStorage; - } - - public void setSessionStorage(Map sessionStorage) - { - this.sessionStorage = sessionStorage; - } - - public Map getParameters() - { - if (parameters == null) - { - parameters = new HashMap<>(); - } - return parameters; - } - - public void setParameters(Map parameters) - { - this.parameters = parameters; - } -} diff --git a/src/main/java/com/jwebmp/core/base/servlets/options/AngularFileTransferData.java b/src/main/java/com/jwebmp/core/base/servlets/options/AngularFileTransferData.java deleted file mode 100644 index bfe832e33..000000000 --- a/src/main/java/com/jwebmp/core/base/servlets/options/AngularFileTransferData.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core.base.servlets.options; - -import com.fasterxml.jackson.annotation.JsonAutoDetect; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.google.inject.servlet.RequestScoped; -import com.jwebmp.core.htmlbuilder.javascript.JavaScriptPart; - -import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.*; -import static com.fasterxml.jackson.annotation.JsonInclude.Include.*; - -/** - * @author GedMarc - * @since 05 Apr 2017 - */ -@RequestScoped -@JsonAutoDetect(fieldVisibility = ANY, - getterVisibility = NONE, - setterVisibility = NONE) -@JsonInclude(NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public class AngularFileTransferData> - extends JavaScriptPart -{ - - - /** - * If this transfer is part of a multipart - */ - private boolean multiPart; - /** - * If this transfer is part of a multipart - */ - private boolean finalPart; - - /** - * The bytes in the transfer (so far) - */ - private byte[] bytes; - /** - * The mime type sent with the transfer - */ - private String mimeType; - - /* - * Constructs a new AngularDataServletInitData - */ - public AngularFileTransferData() - { - //Nothing needed - } - - /** - * If this file transfer is a multi part chunked transfer - * - * @return - */ - public boolean isMultiPart() - { - return multiPart; - } - - /** - * If this transfer is a multi part transfer - * - * @param multiPart - * - * @return - */ - @SuppressWarnings("unchecked") - public J setMultiPart(boolean multiPart) - { - this.multiPart = multiPart; - - return (J) this; - } - - /** - * If this is the final part of the multi part transfer - * - * @return - */ - public boolean isFinalPart() - { - return finalPart; - } - - /** - * If this is the final part of the multipart transfer - * - * @param finalPart - * - * @return - */ - @SuppressWarnings("unchecked") - public J setFinalPart(boolean finalPart) - { - this.finalPart = finalPart; - return (J) this; - } - - public byte[] getBytes() - { - return bytes; - } - - public void setBytes(byte[] bytes) - { - this.bytes = bytes; - } - - public String getMimeType() - { - return mimeType; - } - - public void setMimeType(String mimeType) - { - this.mimeType = mimeType; - } -} diff --git a/src/main/java/com/jwebmp/core/base/servlets/siteloader.js b/src/main/java/com/jwebmp/core/base/servlets/siteloader.js deleted file mode 100644 index af33ddc8c..000000000 --- a/src/main/java/com/jwebmp/core/base/servlets/siteloader.js +++ /dev/null @@ -1,549 +0,0 @@ -/* global BootstrapDialog, eval,cordova */ -function DeltaTimer(render, interval) { - var timeout; - var lastTime; - - this.start = start; - this.stop = stop; - - /** - @description Start the timer. - @public - @function - @returns {number} The UTC time in milliseconds when the timer started. - */ - - function start() { - timeout = setTimeout(loop, 0); - lastTime = Date.now(); - return lastTime; - } - - /** - @description Stop the timer. - @public - @function - @returns {number} The UTC time in milliseconds when the timer stopped. - */ - - function stop() { - clearTimeout(timeout); - return lastTime; - } - - /** - @description Loop the timer continuously and call the render function. - @private - @function - */ - - function loop() { - var thisTime = Date.now(); - var deltaTime = thisTime - lastTime; - var delay = Math.max(interval - deltaTime, 0); - timeout = setTimeout(loop, delay); - lastTime = thisTime + delay; - render(thisTime); - } -} - -var jw = {isLoading: false, pageLoading: true}; -window.jw = jw; -jw.siteAddress = 'SITEADDRESSINSERT'; -var domain; -//find & remove protocol (http, ftp, etc.) and get domain -if (jw.siteAddress.indexOf('://') > -1) { - domain = jw.siteAddress.split('/')[2]; -} if (jw.siteAddress.indexOf('//') === 0) { - domain = jw.siteAddress.split('/')[2]; -} else { - domain = jw.siteAddress.split('/')[0]; -} - -//find & remove port number -domain = domain.split(':')[0]; -jw.rootAddress = 'ROOTADDRESSINSERT'; -jw.pageClass = 'PAGECLASS'; - -jw.useragent = '%USERAGENT%'; -jw.myIP = '%MYIP%'; -jw.referer = '%REFERER%'; -jw.sessionid = document.cookie.match(/JSESSIONID=[^;]+/); -jw.angularExists = false; - -jw.angularLoading = false; - -jw.mobile = {}; -jw.actions = {}; - -jw.localstorage = {}; - -var jwebswingPermStore = {}; - -try { - if (Persist) { - jwebswingPermStore = new Persist.Store('JWebSwingStore'); - jwebswingPermStore.iterate(function (k, v) { - jw.localstorage[k] = v; - }); - } -} catch (e) { - console.warn("LocalStorage may not work. No persist library added"); -} - -jw.sessionstorage = {}; -if (window.sessionStorage) { - if (window.sessionStorage) { - for (var i = 0; i < window.sessionStorage.length; i++) { - jw.sessionstorage[window.sessionStorage.key(i)] = window.sessionStorage.getItem(window.sessionStorage.key(i)); - } - } -} - -jw.env = {}; -jw.env.loadescripts = []; -jw.env.loadedcss = []; -jw.env.controller = null; - - -$('head link[rel$=\'stylesheet\']').each(function (item) { - jw.env.loadedcss.push($(this).attr('href')); -}); - - -/** - * Loads an angular JSON variables object from the server - * @param {type} data - * @returns {undefined} - */ -jw.actions.loadData = function (data, $scope, $parse, $timeout) { - $.each(data.variables, function (i, item) { - var the_string = item.variableName; - if ($parse) { - var model = $parse(the_string); - model.assign($scope, item.variable); - } - }); - if ($timeout) { - $timeout(function () { - }); - } -}; - -/** - * Creates a new variable object translatable by the server - * @param {type} name The name of the object - * @param {type} object The physical object - * @returns {Object} The new data bound object - */ -jw.actions.dataVariable = function (name, object) { - var newVariable = {}; - newVariable.variableName = name; - newVariable.variableObject = object; - return newVariable; -}; - -/** - * Processes the response received from the ajax handler - * @param {type} result - *@param {type} status - * @param {type} xhr - * @returns {undefined} - */ -jw.actions.processResponse = function (result, $scope, $parse, $timeout, $compile, $rootScope) { - jw.actions.processLocalStorage(result); - jw.actions.processSessionStorage(result); - jw.actions.processHtml(result, $scope, $compile, $rootScope); - jw.actions.processCssReferences(result); - jw.actions.processJSReferences(result); - jw.actions.processCss(result); - jw.actions.loadData(result, $scope, $parse, $timeout); - jw.actions.processReactions(result); - - - //jw.actions.processJsScripts(result) -}; - -jw.actions.processLocalStorage = function (result) { - if (result.localStorage) { - for (var name in result.localStorage) { - if (!result.localStorage.hasOwnProperty(name)) - continue; //Skip inherited properties - - var value = result.localStorage[name]; - try { - if (Persist) { - jwebswingPermStore.set(name, value); - jwebswingPermStore.save(); - } - } catch (e) { - console.warn("LocalStorage may not work. No persist library added"); - } - jw.localstorage[name] = value; - } - } -}; - - -jw.actions.processSessionStorage = function (result) { - if (result.sessionStorage) { - for (var name in result.sessionStorage) { - if (!result.sessionStorage.hasOwnProperty(name)) - continue; //Skip inherited properties - - var value = result.sessionStorage[name]; - jw.sessionstorage[name] = value; - //Do things - window.sessionStorage.setItem(name, value); - } - } -}; - -/** - * Adds the style tag to the html - * @param {type} result - * @returns {undefined} - */ -jw.actions.processCss = function (result) { - $('.dynamic-css').remove(); - if (result.css) - $('head').append(''); -}; - -/* - * Loads the next reference or call the callback if on the final position - * @param {type} array - * @param {type} position - * @param {type} completedCallback - * @returns {undefined} - */ -jw.actions.loadNextJSReference = function (array, position, completedCallback) { - position = position + 1; - if (position === (array.length)) { - completedCallback(); - } else { - jw.actions.synchronizedJSReferencesLoad(array, position, completedCallback); - } -}; - -/** - * Loads a list of java script references in synchronized order, fires the last callback when done - * @param {type} array - * @param {type} position - * @param {type} completedCallback - * @returns {undefined} - */ -jw.actions.synchronizedJSReferencesLoad = function (array, position, completedCallback) { - var ref = array[position]; - if (ref) { - if (ref.endsWith('/jwas') || ref.endsWith('/jwjs') || ref.endsWith('/jwad') || ref.endsWith('/jwdata') || ref.endsWith('/jwajax')) { - position = position + 1; - $.notCachedScriptSync(ref).complete(jw.actions.loadNextJSReference(array, position, completedCallback)); - } else { - position = position + 1; - $.cachedScriptSync(ref).complete(jw.actions.loadNextJSReference(array, position, completedCallback)); - } - } -}; -/** - * Adds the JS Reference - * @param {type} result - * @returns {undefined} - */ -jw.actions.processJSReferences = function (result) { - if (result.jsReferences) { - jw.actions.synchronizedJSReferencesLoad(result.jsReferences, 0, function () { - jw.actions.processJsScripts(result); - }); - } else { - jw.actions.processJsScripts(result); - } -}; -/** - * Process the JavaScripts returned - * @param {type} result - * @returns {undefined} - */ -jw.actions.processJsScripts = function (result) { - if (result.jsScripts) { - $.each(result.jsScripts, function (i, item) { - jw.actions.loadScript(item); - }); - } - if (result.events) { - $.each(result.events, function (i, item) { - jw.actions.loadScript(item); - }); - } - if (result.features) { - $.each(result.features, function (i, item) { - jw.actions.loadScript(item); - }); - } -}; - -jw.actions.loadScript = function (item, tries) { - try { - var result = eval(item); - } catch (e) { - console.error('cannot run script -' + item); - console.log(e); - } -}; - -/** - * Adds the css reference to the head - * @param {type} result - * @returns {undefined} - */ -jw.actions.processCssReferences = function (result) { - $.each(result.cssLinks, function (i, item) { - var ss = document.styleSheets; - var found = false; - for (var i = 0, max = ss.length; i < max; i++) { - if (ss[i].href === item) { - found = true; - break; - } - } - if (!found) { - $('head').append(''); - } - }); -}; -/** - * Goes through each component replacing its html - * @param {type} result - * @returns {undefined} - */ -jw.actions.processHtml = function (result, $scope, $compile, $rootScope) { - if (result.components) { - $.each(result.components, function (i, item) { - var htmlString; - var jqHtmlString = $(item.html); - if (item.insertType === 'Replace') { - $('#' + item.id).replaceWith(jqHtmlString); - } else if (item.insertType === 'Append') { - $('#' + item.id).after(jqHtmlString); - } else if (item.insertType === 'Prepend') { - $('#' + item.id).before(jqHtmlString); - } else if (item.insertType === 'Insert') { - $('#' + item.id).prepend(jqHtmlString); - } else if (item.insertType === 'Insert_Last') { - $('#' + item.id).append(jqHtmlString); - } else if (item.insertType === 'InsertLast') { - $('#' + item.id).append(jqHtmlString); - } else if (item.insertType === 'Remove') { - $('#' + item.id).remove(); - } - var myNewSelf = $('#' + item.id); - try { - $compile(myNewSelf)($scope); - } catch (e) { - $compile(myNewSelf)($rootScope); - } - }); - try { - $scope.$apply(); - } catch (e) { - $rootScope.$apply(); - } - } -}; -/** - * Goes through each reaction performing each task - * @param {type} result - * @returns {undefined} - */ -jw.actions.processReactions = function (result) { - $.each(result.reactions, function (i, item) { - var title = item.reactionTitle; - var message = item.reactionMessage; - var type = item.reactionType; - var dialogType = item.type; - var timeout = item.actionTimeout; - var options = item.options; - - if (type === 'DialogDisplay') { - jw.actions.showDialog(title, message, dialogType, options); - } else if (type === 'RedirectHome') { - setTimeout('location.reload();', timeout); - } else if (type === 'RedirectUrl') { - var location = 'window.location.assign("' + message + '")'; - setTimeout(location, timeout); - } - }); -}; - -/** - * @param title The title of the dialog - * @param message The message to display - * @param type the type of dialog - Danger,Success,Warning,Primary,Information,Default - */ -jw.actions.showDialog = function (title, message, type, options) { - if (BootstrapDialog) { - if (options) { - options.title = title; - options.message = message; - BootstrapDialog.show(options); - } - if (type === 'Danger') - BootstrapDialog.show({ - title: title, - message: message, - size: BootstrapDialog.SIZE_EXTRAWIDE, - type: BootstrapDialog.TYPE_DANGER - }); - else if (type === 'Success') - BootstrapDialog.show({ - title: title, - message: message, - type: BootstrapDialog.TYPE_SUCCESS - }); - else if (type === 'Secondary') - BootstrapDialog.show({ - title: title, - message: message, - type: BootstrapDialog.TYPE_SECONDARY - }); - else if (type === 'Dark') - BootstrapDialog.show({ - title: title, - message: message, - type: BootstrapDialog.TYPE_DARK - }); - else if (type === 'Light') - BootstrapDialog.show({ - title: title, - message: message, - type: BootstrapDialog.TYPE_LIGHT - }); - else if (type === 'Warning') - BootstrapDialog.show({ - title: title, - message: message, - type: BootstrapDialog.TYPE_WARNING - }); - else if (type === 'Primary') - BootstrapDialog.show({ - title: title, - message: message, - type: BootstrapDialog.TYPE_PRIMARY - }); - else if (type === 'Information') - BootstrapDialog.show({ - title: title, - message: message, - type: BootstrapDialog.TYPE_INFO - }); - else if (type === 'Default') - BootstrapDialog.show({ - title: title, - message: message, - type: BootstrapDialog.TYPE_INFO - }); - } -}; - - -/** - * Loads up cached url script objects. - * Used when pulling scripts from the server - * $.cachedScript( "ajax/test.js" ).done(function( script, textStatus ) {}); - * $.cachedScript( "ajax/test.js",{async:true).done(function( script, textStatus ) {}); - * @param {type} url The URL to use - * @param {type} options Any $.ajax options - * - * @returns {jqXHR} The ajax object for chaining - */ -jQuery.cachedScript = function (url, options) { - // Allow user to set any option except for dataType, cache, and url - options = $.extend(options || {}, { - dataType: "script", - cache: true, - url: url, - async: true - }); - // Use $.ajax() since it is more flexible than $.getScript - // Return the jqXHR object so we can chain callbacks - return jQuery.ajax(options); -}; - -/** - * Loads up cached url script objects. - * Used when pulling scripts from the server - * $.cachedScript( "ajax/test.js" ).done(function( script, textStatus ) {}); - * $.cachedScript( "ajax/test.js",{async:true).done(function( script, textStatus ) {}); - * @param {type} url The URL to use - * @param {type} options Any $.ajax options - * - * @returns {jqXHR} The ajax object for chaining - */ -jQuery.cachedScriptSync = function (url, options) { - // Allow user to set any option except for dataType, cache, and url - options = $.extend(options || {}, { - dataType: "script", - cache: true, - url: url, - async: false - }); - // Use $.ajax() since it is more flexible than $.getScript - // Return the jqXHR object so we can chain callbacks - return jQuery.ajax(options); -}; - -/** - * Loads up non-cached url script objects. - * Used when pulling scripts from the server - * $.cachedScript( "ajax/test.js" ).done(function( script, textStatus ) {}); - * $.cachedScript( "ajax/test.js",{async:true).done(function( script, textStatus ) {}); - * @param {type} url The URL to use - * @param {type} options Any $.ajax options - * - * @returns {jqXHR} The ajax object for chaining - */ -jQuery.notCachedScript = function (url, options) { - // Allow user to set any option except for dataType, cache, and url - options = $.extend(options || {}, { - dataType: "script", - cache: false, - url: url, - async: true - }); - // Use $.ajax() since it is more flexible than $.getScript - // Return the jqXHR object so we can chain callbacks - return jQuery.ajax(options); -}; - -/** - * Loads up non-cached url script objects. - * Used when pulling scripts from the server - * $.cachedScript( "ajax/test.js" ).done(function( script, textStatus ) {}); - * $.cachedScript( "ajax/test.js",{async:true).done(function( script, textStatus ) {}); - * @param {type} url The URL to use - * @param {type} options Any $.ajax options - * - * @returns {jqXHR} The ajax object for chaining - */ -jQuery.notCachedScriptSync = function (url, options) { - // Allow user to set any option except for dataType, cache, and url - options = $.extend(options || {}, { - dataType: "script", - cache: false, - url: url, - async: false - }); - // Use $.ajax() since it is more flexible than $.getScript - // Return the jqXHR object so we can chain callbacks - return jQuery.ajax(options); -}; - - -function getParametersObject() { - try { - var search = location.search.substring(1); - return dataObject = JSON.parse('{"' + decodeURI(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}'); - } catch (err) { - return {}; - } -} diff --git a/src/main/java/com/jwebmp/core/base/servlets/siteloader.min.js b/src/main/java/com/jwebmp/core/base/servlets/siteloader.min.js deleted file mode 100644 index 77c9e75a5..000000000 --- a/src/main/java/com/jwebmp/core/base/servlets/siteloader.min.js +++ /dev/null @@ -1 +0,0 @@ -function DeltaTimer(render,interval){var timeout;var lastTime;this.start=start;this.stop=stop;function start(){timeout=setTimeout(loop,0);lastTime=Date.now();return lastTime}function stop(){clearTimeout(timeout);return lastTime}function loop(){var thisTime=Date.now();var deltaTime=thisTime-lastTime;var delay=Math.max(interval-deltaTime,0);timeout=setTimeout(loop,delay);lastTime=thisTime+delay;render(thisTime)}}var jw={isLoading:false,pageLoading:true};window.jw=jw;jw.siteAddress="SITEADDRESSINSERT";var domain;if(jw.siteAddress.indexOf("://")>-1){domain=jw.siteAddress.split("/")[2]}if(jw.siteAddress.indexOf("//")===0){domain=jw.siteAddress.split("/")[2]}else{domain=jw.siteAddress.split("/")[0]}domain=domain.split(":")[0];jw.rootAddress="ROOTADDRESSINSERT";jw.pageClass="PAGECLASS";jw.useragent="%USERAGENT%";jw.myIP="%MYIP%";jw.referer="%REFERER%";jw.sessionid=document.cookie.match(/JSESSIONID=[^;]+/);jw.angularExists=false;jw.angularLoading=false;jw.mobile={};jw.actions={};jw.localstorage={};var jwebswingPermStore={};try{if(Persist){jwebswingPermStore=new Persist.Store("JWebSwingStore");jwebswingPermStore.iterate(function(k,v){jw.localstorage[k]=v})}}catch(e){console.warn("LocalStorage may not work. No persist library added")}jw.sessionstorage={};if(window.sessionStorage){if(window.sessionStorage){for(var i=0;i'+result.css+"")};jw.actions.loadNextJSReference=function(array,position,completedCallback){position=position+1;if(position===array.length){completedCallback()}else{jw.actions.synchronizedJSReferencesLoad(array,position,completedCallback)}};jw.actions.synchronizedJSReferencesLoad=function(array,position,completedCallback){var ref=array[position];if(ref){if(ref.endsWith("/jwas")||ref.endsWith("/jwjs")||ref.endsWith("/jwad")||ref.endsWith("/jwdata")||ref.endsWith("/jwajax")){position=position+1;$.notCachedScriptSync(ref).complete(jw.actions.loadNextJSReference(array,position,completedCallback))}else{position=position+1;$.cachedScriptSync(ref).complete(jw.actions.loadNextJSReference(array,position,completedCallback))}}};jw.actions.processJSReferences=function(result){if(result.jsReferences){jw.actions.synchronizedJSReferencesLoad(result.jsReferences,0,function(){jw.actions.processJsScripts(result)})}else{jw.actions.processJsScripts(result)}};jw.actions.processJsScripts=function(result){if(result.jsScripts){$.each(result.jsScripts,function(i,item){jw.actions.loadScript(item)})}if(result.events){$.each(result.events,function(i,item){jw.actions.loadScript(item)})}if(result.features){$.each(result.features,function(i,item){jw.actions.loadScript(item)})}};jw.actions.loadScript=function(item,tries){try{var result=eval(item)}catch(e){console.error("cannot run script -"+item);console.log(e)}};jw.actions.processCssReferences=function(result){$.each(result.cssLinks,function(i,item){var ss=document.styleSheets;var found=false;for(var i=0,max=ss.length;i')}})};jw.actions.processHtml=function(result,$scope,$compile,$rootScope){if(result.components){$.each(result.components,function(i,item){var htmlString;var jqHtmlString=$(item.html);if(item.insertType==="Replace"){$("#"+item.id).replaceWith(jqHtmlString)}else if(item.insertType==="Append"){$("#"+item.id).after(jqHtmlString)}else if(item.insertType==="Prepend"){$("#"+item.id).before(jqHtmlString)}else if(item.insertType==="Insert"){$("#"+item.id).prepend(jqHtmlString)}else if(item.insertType==="Insert_Last"){$("#"+item.id).append(jqHtmlString)}else if(item.insertType==="InsertLast"){$("#"+item.id).append(jqHtmlString)}else if(item.insertType==="Remove"){$("#"+item.id).remove()}var myNewSelf=$("#"+item.id);try{$compile(myNewSelf)($scope)}catch(e){$compile(myNewSelf)($rootScope)}});try{$scope.$apply()}catch(e){$rootScope.$apply()}}};jw.actions.processReactions=function(result){$.each(result.reactions,function(i,item){var title=item.reactionTitle;var message=item.reactionMessage;var type=item.reactionType;var dialogType=item.type;var timeout=item.actionTimeout;var options=item.options;if(type==="DialogDisplay"){jw.actions.showDialog(title,message,dialogType,options)}else if(type==="RedirectHome"){setTimeout("location.reload();",timeout)}else if(type==="RedirectUrl"){var location='window.location.assign("'+message+'")';setTimeout(location,timeout)}})};jw.actions.showDialog=function(title,message,type,options){if(BootstrapDialog){if(options){options.title=title;options.message=message;BootstrapDialog.show(options)}if(type==="Danger")BootstrapDialog.show({title:title,message:message,size:BootstrapDialog.SIZE_EXTRAWIDE,type:BootstrapDialog.TYPE_DANGER});else if(type==="Success")BootstrapDialog.show({title:title,message:message,type:BootstrapDialog.TYPE_SUCCESS});else if(type==="Secondary")BootstrapDialog.show({title:title,message:message,type:BootstrapDialog.TYPE_SECONDARY});else if(type==="Dark")BootstrapDialog.show({title:title,message:message,type:BootstrapDialog.TYPE_DARK});else if(type==="Light")BootstrapDialog.show({title:title,message:message,type:BootstrapDialog.TYPE_LIGHT});else if(type==="Warning")BootstrapDialog.show({title:title,message:message,type:BootstrapDialog.TYPE_WARNING});else if(type==="Primary")BootstrapDialog.show({title:title,message:message,type:BootstrapDialog.TYPE_PRIMARY});else if(type==="Information")BootstrapDialog.show({title:title,message:message,type:BootstrapDialog.TYPE_INFO});else if(type==="Default")BootstrapDialog.show({title:title,message:message,type:BootstrapDialog.TYPE_INFO})}};jQuery.cachedScript=function(url,options){options=$.extend(options||{},{dataType:"script",cache:true,url:url,async:true});return jQuery.ajax(options)};jQuery.cachedScriptSync=function(url,options){options=$.extend(options||{},{dataType:"script",cache:true,url:url,async:false});return jQuery.ajax(options)};jQuery.notCachedScript=function(url,options){options=$.extend(options||{},{dataType:"script",cache:false,url:url,async:true});return jQuery.ajax(options)};jQuery.notCachedScriptSync=function(url,options){options=$.extend(options||{},{dataType:"script",cache:false,url:url,async:false});return jQuery.ajax(options)};function getParametersObject(){try{var search=location.search.substring(1);return dataObject=JSON.parse('{"'+decodeURI(search).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}')}catch(err){return{}}} \ No newline at end of file diff --git a/src/main/java/com/jwebmp/core/exceptions/InvalidRequestException.java b/src/main/java/com/jwebmp/core/exceptions/InvalidRequestException.java deleted file mode 100644 index 881fd0138..000000000 --- a/src/main/java/com/jwebmp/core/exceptions/InvalidRequestException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core.exceptions; - -/** - * Occurs when no Servlet was found in an event situation - * - * @author GedMarc - * @since 09 May 2016 - */ -public class InvalidRequestException - extends Exception -{ - - public InvalidRequestException() - { - } - - public InvalidRequestException(String message) - { - super(message); - } - - public InvalidRequestException(String message, Throwable cause) - { - super(message, cause); - } - - public InvalidRequestException(Throwable cause) - { - super(cause); - } - - public InvalidRequestException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) - { - super(message, cause, enableSuppression, writableStackTrace); - } -} diff --git a/src/main/java/com/jwebmp/core/exceptions/MissingComponentException.java b/src/main/java/com/jwebmp/core/exceptions/MissingComponentException.java deleted file mode 100644 index e06957cd6..000000000 --- a/src/main/java/com/jwebmp/core/exceptions/MissingComponentException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core.exceptions; - -/** - * Occurs when no Servlet was found in an event situation - * - * @author GedMarc - * @since 09 May 2016 - */ -public class MissingComponentException - extends Exception -{ - - public MissingComponentException() - { - } - - public MissingComponentException(String message) - { - super(message); - } - - public MissingComponentException(String message, Throwable cause) - { - super(message, cause); - } - - public MissingComponentException(Throwable cause) - { - super(cause); - } - - public MissingComponentException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) - { - super(message, cause, enableSuppression, writableStackTrace); - } -} diff --git a/src/main/java/com/jwebmp/core/exceptions/NoServletFoundException.java b/src/main/java/com/jwebmp/core/exceptions/NoServletFoundException.java deleted file mode 100644 index b182e5547..000000000 --- a/src/main/java/com/jwebmp/core/exceptions/NoServletFoundException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core.exceptions; - -/** - * Occurs when no Servlet was found in an event situation - * - * @author GedMarc - * @since 09 May 2016 - */ -public class NoServletFoundException - extends Exception -{ - - public NoServletFoundException() - { - } - - public NoServletFoundException(String message) - { - super(message); - } - - public NoServletFoundException(String message, Throwable cause) - { - super(message, cause); - } - - public NoServletFoundException(Throwable cause) - { - super(cause); - } - - public NoServletFoundException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) - { - super(message, cause, enableSuppression, writableStackTrace); - } -} diff --git a/src/main/java/com/jwebmp/core/exceptions/NullComponentException.java b/src/main/java/com/jwebmp/core/exceptions/NullComponentException.java deleted file mode 100644 index ad197aac3..000000000 --- a/src/main/java/com/jwebmp/core/exceptions/NullComponentException.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core.exceptions; - -/** - * Exception thrown when a component cannot be null - * - * @author GedMarc - * @since 29 Jul 2016 - */ -public class NullComponentException - extends RuntimeException -{ - - /** - * Exception thrown when a component cannot be null - */ - public NullComponentException() - { - } - - /** - * Exception thrown when a component cannot be null - * - * @param message - * a message for the exception - */ - public NullComponentException(String message) - { - super(message); - } - - /** - * Exception thrown when a component cannot be null - * - * @param message - * A message for the exception - * @param cause - * the exception - */ - public NullComponentException(String message, Throwable cause) - { - super(message, cause); - } - - /** - * Exception thrown when a component cannot be null - * - * @param cause - * the exception that caused this - */ - - public NullComponentException(Throwable cause) - { - super(cause); - } - - /** - * Exception thrown when a component cannot be null - * - * @param message - * The message for the exception - * @param cause - * the exception that caused it - * @param enableSuppression - * enable suppression - * @param writableStackTrace - * make the stack trace writable - */ - public NullComponentException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) - { - super(message, cause, enableSuppression, writableStackTrace); - } - -} diff --git a/src/main/java/com/jwebmp/core/exceptions/UserSecurityException.java b/src/main/java/com/jwebmp/core/exceptions/UserSecurityException.java deleted file mode 100644 index 0e5f4efab..000000000 --- a/src/main/java/com/jwebmp/core/exceptions/UserSecurityException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core.exceptions; - -/** - * Occurs when no Servlet was found in an event situation - * - * @author GedMarc - * @since 09 May 2016 - */ -public class UserSecurityException - extends Exception -{ - - public UserSecurityException() - { - } - - public UserSecurityException(String message) - { - super(message); - } - - public UserSecurityException(String message, Throwable cause) - { - super(message, cause); - } - - public UserSecurityException(Throwable cause) - { - super(cause); - } - - public UserSecurityException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) - { - super(message, cause, enableSuppression, writableStackTrace); - } -} diff --git a/src/main/java/com/jwebmp/core/htmlbuilder/javascript/events/enumerations/EventTypes.java b/src/main/java/com/jwebmp/core/htmlbuilder/javascript/events/enumerations/EventTypes.java index dccc7d4d3..f93c363aa 100644 --- a/src/main/java/com/jwebmp/core/htmlbuilder/javascript/events/enumerations/EventTypes.java +++ b/src/main/java/com/jwebmp/core/htmlbuilder/javascript/events/enumerations/EventTypes.java @@ -54,258 +54,254 @@ * @author GedMarc */ public enum EventTypes - implements Comparable, com.jwebmp.core.services.IEventTypes + implements Comparable, com.jwebmp.core.services.IEventTypes { + /** + * Sends an Ajax call to the server to perform any command on document render. Very flexible, Maybe overly so + */ + performCommand(OnComponentLoadedEvent.class, null), + /** + * Registers a Mouse Over event + */ + mouseOver(MouseOverAdapter.class, null), + /** + * Registers a Mouse Over event + */ + mouseOut(MouseOutAdapter.class, null), + mouseDown(MouseDownAdapter.class, null), + mouseUp(MouseDownAdapter.class, null), + mouseEnter(MouseEnterAdapter.class, null), + mouseMove(MouseMoveAdapter.class, null), + keyDown(MouseMoveAdapter.class, null), + keyPressed(MouseMoveAdapter.class, null), + keyUp(MouseMoveAdapter.class, null), + /** + * Registers a Right Click event + */ + contextmenu(RightClickAdapter.class, null), + /* + * Registers a normal click event + */ + click(ClickAdapter.class, null), + changed(null, null), + /** + * Known as focus-lost in Swing Triggered when the menu loses focus. + */ + blur(BlurAdapter.class, null), + /** + * Triggered when focus is moved to an item (not selecting). The default action is to replace the text field's value with the value of the focused item, though only if the + * event was triggered by a + * keyboard interaction. + *

+ * Canceling this event prevents the value from being updated, but does not prevent the menu item from being focused. + */ + focus(FocusAdapter.class, null), + /** + * Registers when a drag starts Triggered when the user starts dragging the dialog. + */ + dragStart(DragStartAdapter.class, null), + /** + * Registers when a drag stops Triggered after the dialog has been dragged. + */ + dragStop(DragStopAdapter.class, null), + /** + * Triggered when an accepted Draggable is dropped on the droppable (based on the tolerance option). + */ + drop(DropAdapter.class, null), + /** + * Triggered when a dialog is about to close. If canceled, the dialog will not close. + */ + beforeClose(BeforeCloseAdapter.class, null), + /** + * Triggered when the menu is hidden. Not every close event will be accompanied by a change event. Triggered when the dialog is closed. Triggered when the menu is hidden. + */ + close(CloseAdapter.class, null), + /** + * Triggered when the accordion is created. If the accordion is collapsed, ui.header and ui.panel will be empty jQuery objects. Triggered when the dialog is created. Triggered + * when the progressbar + * is created. Triggered when the selectmenu is created. + */ + create(CreateAdapter.class, null), + /** + * Prevents interactions from starting on specified elements. + */ + cancel(CancelAdapter.class, null), + /** + * Triggered while the dialog is being dragged. + */ + drag(DragAdapter.class, null), + /** + * Triggered when the suggestion menu is opened or updated. Triggered when the dialog is opened. + */ + open(OpenAdapter.class, null), + /** + * Triggered while the dialog is being resized. + */ + resize(ResizeAdapter.class, null), + /** + * Triggered when the user starts resizing the dialog. + */ + resizeStart(ResizeStartAdapter.class, null), + /** + * This event is triggered at the end of a resize operation. Triggered after the dialog has been resized. + */ + resizeStop(ResizeStopAdapter.class, null), + /** + * Triggered after a panel has been activated (after animation completes). If the accordion was previously collapsed, ui.oldHeader and ui.oldPanel will be empty jQuery objects. + * If the accordion is + * collapsing, ui.newHeader and ui.newPanel will be empty jQuery objects. + */ + activate(ActivateAdapter.class, null), + /** + * Triggered directly before a panel is activated. Can be canceled to prevent the panel from activating. If the accordion is currently collapsed, ui.oldHeader and ui.oldPanel + * will be empty jQuery + * objects. If the accordion is collapsing, ui.newHeader and ui.newPanel will be empty jQuery objects. + *

+ * Triggered immediately before a tab is activated. Can be canceled to prevent the tab from activating. If the tabs are currently collapsed, ui.oldTab and ui.oldPanel will be + * empty jQuery objects. + * If the tabs are collapsing, ui.newTab and ui.newPanel will be empty jQuery objects. + */ + beforeActivate(BeforeActivateAdapter.class, null), + beforeStop(BeforeStopAdapter.class, null), + buttonClickEvent(ButtonClickAdapter.class, null), + /** + * Triggered when the field is blurred, if the value has changed. Triggered when the value of the progressbar changes. Triggered when the selected item has changed. Not every + * select event will + * fire a change event. + */ + change(ChangeAdapter.class, null), + unselected(UnselectedAdapter.class, null), + selected(SelectedAdapter.class, null), + selecting(SelectingAdapter.class, null), + deactivate(DeactivateAdapter.class, null), + out(MouseOutAdapter.class, null), + over(MouseOverAdapter.class, null), + receive(ReceiveAdapter.class, null), + remove(RemoveAdapter.class, null), + sort(SortAdapter.class, null), + /** + * Triggered when the user starts sliding. + */ + start(StartAdapter.class, null), + /** + * Triggered after the user slides a handle. + */ + stop(StopAdapter.class, null), + /** + * Triggered after a search completes, before the menu is shown. + *

+ * Useful for local manipulation of suggestion data, where a custom source option callback is not required. This event is always triggered when a search completes, even if the + * menu will not be + * shown because there are no results or the Autocomplete is disabled. + */ + response(ResponseAdapter.class, null), + /** + * Triggered before a search is performed, after minLength and delay are met. If canceled, then no request will be started and no items suggested. + */ + search(SearchAdapter.class, null), + /** + * Triggered when an item is selected from the menu. + *

+ * The default action is to replace the text field's value with the value of the selected item. + *

+ * Canceling this event prevents the value from being updated, but does not prevent the menu from closing. + *

+ * Triggered when a menu item is selected. + */ + select(SelectedAdapter.class, null), + /** + * Triggered when the value of the progressbar reaches the maximum value. + */ + complete(CompleteAdapter.class, null), + /** + * Triggered on every mouse move during slide. The value provided in the event as ui.value represents the value that the handle will have as a result of the current movement. + * Canceling the event + * will prevent the handle from moving and the handle will continue to have its previous value. + */ + slide(SlideAdapter.class, null), + /** + *

+ * Triggered when a remote tab is about to be loaded, after the beforeActivate event. Can be canceled to prevent the tab panel from loading content; though the panel will still + * be activated. This + * event is triggered just before the Ajax request is made, so modifications can be made to ui.jqXHR and ui.ajaxSettings. + *

+ * Note: Although ui.ajaxSettings is provided and can be modified, some of these properties have already been processed by jQuery. For example, prefilters have been applied, + * data has been + * processed, and type has been determined. The beforeLoad event occurs at the same time, and therefore has the same restrictions, as the beforeSend callback from + * jQuery.ajax(). + *

+ */ + beforeLoad(BeforeLoadAdapter.class, null), + /** + * Triggered after a remote tab has been loaded. + */ + load(LoadAdapter.class, null), + update(UpdateAdapter.class, null), + undefined(null, null), + /** + * Triggered during increment/decrement (to determine direction of spin compare current value with ui.value). + *

+ * Can be canceled, preventing the value from being updated. + */ + spin(SpinAdapter.class, null), + /** + * Marks a data. Always null, Internal. + */ + data(null, null), + checked(CheckedAdapter.class, null), + submit(SubmitAdapter.class, null), - /** - * Sends an Ajax call to the server to perform any command on document render. Very flexible, Maybe overly so - */ - /** - * Sends an Ajax call to the server to perform any command on document render. Very flexible, Maybe overly so - */ - performCommand(OnComponentLoadedEvent.class, null), - /** - * Registers a Mouse Over event - */ - mouseOver(MouseOverAdapter.class, null), - /** - * Registers a Mouse Over event - */ - mouseOut(MouseOutAdapter.class, null), - mouseDown(MouseDownAdapter.class, null), - mouseUp(MouseDownAdapter.class, null), - mouseEnter(MouseEnterAdapter.class, null), - mouseMove(MouseMoveAdapter.class, null), - keyDown(MouseMoveAdapter.class, null), - keyPressed(MouseMoveAdapter.class, null), - keyUp(MouseMoveAdapter.class, null), - /** - * Registers a Right Click event - */ - contextmenu(RightClickAdapter.class, null), - /* - * Registers a normal click event - */ - click(ClickAdapter.class, null), - changed(null, null), - /** - * Known as focus-lost in Swing Triggered when the menu loses focus. - */ - blur(BlurAdapter.class, null), - /** - * Triggered when focus is moved to an item (not selecting). The default action is to replace the text field's value with the value of the focused item, though only if the - * event was triggered by a - * keyboard interaction. - *

- * Canceling this event prevents the value from being updated, but does not prevent the menu item from being focused. - */ - focus(FocusAdapter.class, null), - /** - * Registers when a drag starts Triggered when the user starts dragging the dialog. - */ - dragStart(DragStartAdapter.class, null), - /** - * Registers when a drag stops Triggered after the dialog has been dragged. - */ - dragStop(DragStopAdapter.class, null), - /** - * Triggered when an accepted Draggable is dropped on the droppable (based on the tolerance option). - */ - drop(DropAdapter.class, null), - /** - * Triggered when a dialog is about to close. If canceled, the dialog will not close. - */ - beforeClose(BeforeCloseAdapter.class, null), - /** - * Triggered when the menu is hidden. Not every close event will be accompanied by a change event. Triggered when the dialog is closed. Triggered when the menu is hidden. - */ - close(CloseAdapter.class, null), - /** - * Triggered when the accordion is created. If the accordion is collapsed, ui.header and ui.panel will be empty jQuery objects. Triggered when the dialog is created. Triggered - * when the progressbar - * is created. Triggered when the selectmenu is created. - */ - create(CreateAdapter.class, null), - /** - * Prevents interactions from starting on specified elements. - */ - cancel(CancelAdapter.class, null), - /** - * Triggered while the dialog is being dragged. - */ - drag(DragAdapter.class, null), - /** - * Triggered when the suggestion menu is opened or updated. Triggered when the dialog is opened. - */ - open(OpenAdapter.class, null), - /** - * Triggered while the dialog is being resized. - */ - resize(ResizeAdapter.class, null), - /** - * Triggered when the user starts resizing the dialog. - */ - resizeStart(ResizeStartAdapter.class, null), - /** - * This event is triggered at the end of a resize operation. Triggered after the dialog has been resized. - */ - resizeStop(ResizeStopAdapter.class, null), - /** - * Triggered after a panel has been activated (after animation completes). If the accordion was previously collapsed, ui.oldHeader and ui.oldPanel will be empty jQuery objects. - * If the accordion is - * collapsing, ui.newHeader and ui.newPanel will be empty jQuery objects. - */ - activate(ActivateAdapter.class, null), - /** - * Triggered directly before a panel is activated. Can be canceled to prevent the panel from activating. If the accordion is currently collapsed, ui.oldHeader and ui.oldPanel - * will be empty jQuery - * objects. If the accordion is collapsing, ui.newHeader and ui.newPanel will be empty jQuery objects. - *

- * Triggered immediately before a tab is activated. Can be canceled to prevent the tab from activating. If the tabs are currently collapsed, ui.oldTab and ui.oldPanel will be - * empty jQuery objects. - * If the tabs are collapsing, ui.newTab and ui.newPanel will be empty jQuery objects. - */ - beforeActivate(BeforeActivateAdapter.class, null), - beforeStop(BeforeStopAdapter.class, null), - buttonClickEvent(ButtonClickAdapter.class, null), - /** - * Triggered when the field is blurred, if the value has changed. Triggered when the value of the progressbar changes. Triggered when the selected item has changed. Not every - * select event will - * fire a change event. - */ - change(ChangeAdapter.class, null), - unselected(UnselectedAdapter.class, null), - selected(SelectedAdapter.class, null), - selecting(SelectingAdapter.class, null), - deactivate(DeactivateAdapter.class, null), - out(MouseOutAdapter.class, null), - over(MouseOverAdapter.class, null), - receive(ReceiveAdapter.class, null), - remove(RemoveAdapter.class, null), - sort(SortAdapter.class, null), - /** - * Triggered when the user starts sliding. - */ - start(StartAdapter.class, null), - /** - * Triggered after the user slides a handle. - */ - stop(StopAdapter.class, null), - /** - * Triggered after a search completes, before the menu is shown. - *

- * Useful for local manipulation of suggestion data, where a custom source option callback is not required. This event is always triggered when a search completes, even if the - * menu will not be - * shown because there are no results or the Autocomplete is disabled. - */ - response(ResponseAdapter.class, null), - /** - * Triggered before a search is performed, after minLength and delay are met. If canceled, then no request will be started and no items suggested. - */ - search(SearchAdapter.class, null), - /** - * Triggered when an item is selected from the menu. - *

- * The default action is to replace the text field's value with the value of the selected item. - *

- * Canceling this event prevents the value from being updated, but does not prevent the menu from closing. - *

- * Triggered when a menu item is selected. - */ - select(SelectedAdapter.class, null), - /** - * Triggered when the value of the progressbar reaches the maximum value. - */ - complete(CompleteAdapter.class, null), - /** - * Triggered on every mouse move during slide. The value provided in the event as ui.value represents the value that the handle will have as a result of the current movement. - * Canceling the event - * will prevent the handle from moving and the handle will continue to have its previous value. - */ - slide(SlideAdapter.class, null), - /** - *

- * Triggered when a remote tab is about to be loaded, after the beforeActivate event. Can be canceled to prevent the tab panel from loading content; though the panel will still - * be activated. This - * event is triggered just before the Ajax request is made, so modifications can be made to ui.jqXHR and ui.ajaxSettings. - *

- * Note: Although ui.ajaxSettings is provided and can be modified, some of these properties have already been processed by jQuery. For example, prefilters have been applied, - * data has been - * processed, and type has been determined. The beforeLoad event occurs at the same time, and therefore has the same restrictions, as the beforeSend callback from - * jQuery.ajax(). - *

- */ - beforeLoad(BeforeLoadAdapter.class, null), - /** - * Triggered after a remote tab has been loaded. - */ - load(LoadAdapter.class, null), - update(UpdateAdapter.class, null), - undefined(null, null), - /** - * Triggered during increment/decrement (to determine direction of spin compare current value with ui.value). - *

- * Can be canceled, preventing the value from being updated. - */ - spin(SpinAdapter.class, null), - /** - * Marks a data. Always null, Internal. - */ - data(null, null), - checked(CheckedAdapter.class, null), - submit(SubmitAdapter.class, null), + async(null, null), + custom(null, null); - async(null, null), - custom(null, null); + private final Class classType; + private final Class ajaxOptionsReturn; - private final Class classType; - private final Class ajaxOptionsReturn; + /** + * Registers and Ajax Event Type + * + * @param classType + * @param groupedType + */ + EventTypes(Class classType, Class groupedType) + { + this.classType = classType; + ajaxOptionsReturn = groupedType; + } - /** - * Registers and Ajax Event Type - * - * @param classType - * @param groupedType - */ - EventTypes(Class classType, Class groupedType) - { - this.classType = classType; - ajaxOptionsReturn = groupedType; - } + /** + * Get the class type that this AJAX event type is matched to + * + * @return Get the class type that this AJAX event type is matched to + */ + @Override + public Class getClassType() + { + return classType; + } - /** - * Get the class type that this AJAX event type is matched to - * - * @return Get the class type that this AJAX event type is matched to - */ - @Override - public Class getClassType() - { - return classType; - } + /** + * Gets the Ajax Event Types that this event is linked to + * + * @return Gets the Ajax Event Types that this event is linked to + */ + @Override + public Class getAjaxOptionsReturn() + { + return ajaxOptionsReturn; + } - /** - * Gets the Ajax Event Types that this event is linked to - * - * @return Gets the Ajax Event Types that this event is linked to - */ - @Override - public Class getAjaxOptionsReturn() - { - return ajaxOptionsReturn; - } - - @Override - public Enum from(String s) - { - return valueOf(s); - } - - @Override - @JsonValue - public String toString() - { - return name().toLowerCase(); - } + @Override + public Enum from(String s) + { + return valueOf(s); + } + + @Override + @JsonValue + public String toString() + { + return name().toLowerCase(); + } } diff --git a/src/main/java/com/jwebmp/core/implementations/JWebMPDynamicScriptRenderer.java b/src/main/java/com/jwebmp/core/implementations/JWebMPDynamicScriptRenderer.java deleted file mode 100644 index e14e494c8..000000000 --- a/src/main/java/com/jwebmp/core/implementations/JWebMPDynamicScriptRenderer.java +++ /dev/null @@ -1,160 +0,0 @@ -package com.jwebmp.core.implementations; - -import com.google.common.base.Strings; -import com.google.inject.*; -import com.guicedee.client.*; -import com.jwebmp.core.FileTemplates; -import com.jwebmp.core.Page; -import com.jwebmp.core.SessionHelper; -import com.jwebmp.core.base.html.Script; -import com.jwebmp.core.base.html.attributes.*; -import com.jwebmp.core.base.servlets.JWScriptServlet; -import com.jwebmp.core.services.*; -import com.guicedee.services.jsonrepresentation.json.StaticStrings; -import jakarta.servlet.http.HttpServletRequest; - -import static com.guicedee.client.IGuiceContext.*; - -public class JWebMPDynamicScriptRenderer implements IDynamicRenderingServlet -{ - @Override - public String getScriptLocation(IPage page) - { - String queryParams = ""; - try - { - HttpServletRequest hsr = get(HttpServletRequest.class); - queryParams = hsr.getQueryString(); - } - catch (Throwable T) - { - - } - return JWebMPSiteBinder - .getJWScriptLocation() - .replaceAll(StaticStrings.STRING_FORWARD_SLASH, StaticStrings.STRING_EMPTY) + "?" + Strings.nullToEmpty(queryParams); - } - - @Override - public Script renderScript(IPage page) - { - return getSiteLoaderScript(); - } - - private static final String[] HEADERS_TO_TRY = {"X-Forwarded-For", "Proxy-Client-IP", "WL-Proxy-Client-IP", "HTTP_X_FORWARDED_FOR", "HTTP_X_FORWARDED", "HTTP_X_CLUSTER_CLIENT_IP", "HTTP_CLIENT_IP", "HTTP_FORWARDED_FOR", "HTTP_FORWARDED", "HTTP_VIA", "REMOTE_ADDR"}; - - private String getClientIpAddress(HttpServletRequest request) - { - for (String header : HEADERS_TO_TRY) - { - String ip = request.getHeader(header); - if (ip != null && ip.length() != 0 && !"unknown".equalsIgnoreCase(ip)) - { - return ip; - } - } - return request.getRemoteAddr(); - } - - /** - * Method getSiteLoaderScript returns the siteLoaderScript of this ScriptsDynamicPageConfigurator object. - * - * @return the siteLoaderScript (type Script) of this ScriptsDynamicPageConfigurator object. - */ - private Script getSiteLoaderScript() - { - FileTemplates.getFileTemplate(JWScriptServlet.class, JWScriptServlet.FILE_TEMPLATE_NAME, "siteloader"); - FileTemplates - .getTemplateVariables() - .put("SITEADDRESSINSERT", new StringBuilder(SessionHelper.getServerPath())); - FileTemplates - .getTemplateVariables() - .put("ROOTADDRESSINSERT", new StringBuilder(SessionHelper.getServerRootPath())); - - try - { - FileTemplates - .getTemplateVariables() - .put("PAGECLASS", - new StringBuilder(IGuiceContext - .get(Page.class) - .getClass() - .getCanonicalName())); - - } - catch (ProvisionException | OutOfScopeException e) - { - FileTemplates - .getTemplateVariables() - .put("PAGECLASS", new StringBuilder()); - } - - try - { - HttpServletRequest hsr = get(HttpServletRequest.class); - FileTemplates - .getTemplateVariables() - .put("%USERAGENT%", new StringBuilder(hsr.getHeader("user-agent"))); - - String ipAddress = getClientIpAddress(hsr); - if ("[::1]".equals(ipAddress)) - { - ipAddress = "localhost"; - } - if ("127.0.0.1".equals(ipAddress)) - { - ipAddress = "localhost"; - } - if ("[0:0:0:0:0:0:0:1]".equals(ipAddress)) - { - ipAddress = "localhost"; - } - FileTemplates - .getTemplateVariables() - .put("%MYIP%", new StringBuilder(ipAddress)); - - FileTemplates - .getTemplateVariables() - .put("%REFERER%", new StringBuilder(hsr.getHeader("referer"))); - } - catch (Throwable T) - { - - } - - StringBuilder jsScript = FileTemplates.renderTemplateScripts(JWScriptServlet.FILE_TEMPLATE_NAME); - if (!jsScript - .toString() - .trim() - .isEmpty()) - { - return newScript(jsScript.toString()); - } - return new Script<>().setText("could not find site loader script"); - } - - public Script newScript(String contents) - { - Script s = new Script<>(); - s.addAttribute(ScriptAttributes.Type, StaticStrings.HTML_HEADER_JAVASCRIPT); - s.setText(contents); - return s; - } - - /** - * Default Sort Order INTEGER.MAX - 1000 - * - * @return INTEGER.MAX - 1000 - */ - @Override - public Integer sortOrder() - { - return Integer.MAX_VALUE - 1000; - } - - @Override - public boolean enabled() - { - return false; - } -} diff --git a/src/main/java/com/jwebmp/core/implementations/JWebMPJacksonModule.java b/src/main/java/com/jwebmp/core/implementations/JWebMPJacksonModule.java new file mode 100644 index 000000000..5668eb2dd --- /dev/null +++ b/src/main/java/com/jwebmp/core/implementations/JWebMPJacksonModule.java @@ -0,0 +1,14 @@ +package com.jwebmp.core.implementations; + +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.jwebmp.core.htmlbuilder.javascript.events.interfaces.IEvent; +import com.jwebmp.core.services.IEventTypes; + +public class JWebMPJacksonModule extends SimpleModule +{ + public JWebMPJacksonModule() + { + addDeserializer(IEvent.class, new JacksonEventDeserializer()); + addDeserializer(IEventTypes.class, new JacksonEventTypeDeserializer()); + } +} diff --git a/src/main/java/com/jwebmp/core/implementations/JWebMPJavaScriptDynamicScriptRenderer.java b/src/main/java/com/jwebmp/core/implementations/JWebMPJavaScriptDynamicScriptRenderer.java deleted file mode 100644 index ccb471499..000000000 --- a/src/main/java/com/jwebmp/core/implementations/JWebMPJavaScriptDynamicScriptRenderer.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.jwebmp.core.implementations; - -import com.google.common.base.Strings; -import com.jwebmp.core.Page; -import com.jwebmp.core.base.html.Script; -import com.jwebmp.core.base.html.attributes.*; -import com.jwebmp.core.services.*; -import com.guicedee.services.jsonrepresentation.json.StaticStrings; -import jakarta.servlet.http.HttpServletRequest; - -import static com.guicedee.client.IGuiceContext.*; - - -public class JWebMPJavaScriptDynamicScriptRenderer implements IDynamicRenderingServlet -{ - public static boolean renderJavascript = true; - - @Override - public String getScriptLocation(IPage page) - { - String queryParams = ""; - try - { - HttpServletRequest hsr = get(HttpServletRequest.class); - queryParams = hsr.getQueryString(); - } - catch (Throwable T) - { - - } - return JWebMPSiteBinder - .getJavaScriptLocation() - .replaceAll(StaticStrings.STRING_FORWARD_SLASH, StaticStrings.STRING_EMPTY) + "?" + Strings.nullToEmpty(queryParams); - } - - @Override - public Script renderScript(IPage page) - { - return getJavascriptScript(page); - } - - public Script newScript(String contents) - { - Script s = new Script<>(); - s.addAttribute(ScriptAttributes.Type, StaticStrings.HTML_HEADER_JAVASCRIPT); - s.setText(contents); - return s; - } - - /** - * Method getJavascriptScript ... - * - * @return Script - */ - private Script getJavascriptScript(IPage pager) - { - Page page = (Page)pager; - if (renderJavascript) - { - StringBuilder js = page.renderJavascript(); - return newScript(page.getNewLine() + js); - } - return null; - } - - /** - * Default Sort Order INTEGER.MAX - 900 - * - * @return Default Sort Order INTEGER.MAX - 900 - */ - @Override - public Integer sortOrder() - { - return Integer.MAX_VALUE - 900; - } - - @Override - public boolean enabled() - { - return false; - } -} diff --git a/src/main/java/com/jwebmp/core/implementations/JWebMPPostStartup.java b/src/main/java/com/jwebmp/core/implementations/JWebMPPostStartup.java new file mode 100644 index 000000000..cf632e567 --- /dev/null +++ b/src/main/java/com/jwebmp/core/implementations/JWebMPPostStartup.java @@ -0,0 +1,19 @@ +package com.jwebmp.core.implementations; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.guicedee.client.IGuiceContext; +import com.guicedee.guicedinjection.interfaces.IGuicePostStartup; +import com.guicedee.guicedinjection.interfaces.ObjectBinderKeys; + +public class JWebMPPostStartup implements IGuicePostStartup +{ + @Override + public void postLoad() + { + IGuiceContext.get(ObjectMapper.class) + .registerModule(new JWebMPJacksonModule()); + IGuiceContext.get(ObjectBinderKeys.DefaultObjectMapper) + .registerModule(new JWebMPJacksonModule()); + ; + } +} diff --git a/src/main/java/com/jwebmp/core/implementations/JWebMPServicesBindings.java b/src/main/java/com/jwebmp/core/implementations/JWebMPServicesBindings.java index a1338997c..4c42495b6 100644 --- a/src/main/java/com/jwebmp/core/implementations/JWebMPServicesBindings.java +++ b/src/main/java/com/jwebmp/core/implementations/JWebMPServicesBindings.java @@ -4,59 +4,77 @@ import com.google.inject.Key; import com.google.inject.Singleton; import com.google.inject.TypeLiteral; - -import com.guicedee.client.*; +import com.guicedee.client.IGuiceContext; import com.guicedee.guicedinjection.interfaces.IGuiceModule; +import com.jwebmp.core.Page; import com.jwebmp.core.services.*; import java.util.ServiceLoader; import java.util.Set; -@SuppressWarnings({"Convert2Diamond", "MissingFieldJavaDoc"}) +@SuppressWarnings({"Convert2Diamond", + "MissingFieldJavaDoc"}) public class JWebMPServicesBindings - extends AbstractModule - implements IGuiceModule + extends AbstractModule + implements IGuiceModule { - public static final Key> IPageConfiguratorsKey = Key.get(new TypeLiteral>() {}); - public static final Key> RenderAfterScriptsKey = Key.get(new TypeLiteral>() {}); - public static final Key> RenderAfterDynamicScriptsKey = Key.get(new TypeLiteral>() {}); - public static final Key> RenderBeforeScriptsKey = Key.get(new TypeLiteral>() {}); - public static final Key> RenderBeforeDynamicScriptsKey = Key.get(new TypeLiteral>() {}); - public static final Key> RenderBeforeLinksKey = Key.get(new TypeLiteral>() {}); - public static final Key> RenderAfterLinksKey = Key.get(new TypeLiteral>() {}); + public static final Key> IPageConfiguratorsKey = Key.get(new TypeLiteral>() + { + }); + public static final Key> RenderAfterScriptsKey = Key.get(new TypeLiteral>() + { + }); + public static final Key> RenderAfterDynamicScriptsKey = Key.get(new TypeLiteral>() + { + }); + public static final Key> RenderBeforeScriptsKey = Key.get(new TypeLiteral>() + { + }); + public static final Key> RenderBeforeDynamicScriptsKey = Key.get(new TypeLiteral>() + { + }); + public static final Key> RenderBeforeLinksKey = Key.get(new TypeLiteral>() + { + }); + public static final Key> RenderAfterLinksKey = Key.get(new TypeLiteral>() + { + }); + + @Override + public void configure() + { + bind(Page.class).to(IPage.class); + + //noinspection unchecked + bind(JWebMPServicesBindings.IPageConfiguratorsKey) + .toProvider(() -> IGuiceContext.instance() + .getLoader(IPageConfigurator.class, ServiceLoader.load(IPageConfigurator.class))) + .in(Singleton.class); + bind(JWebMPServicesBindings.RenderAfterScriptsKey) + .toProvider(() -> IGuiceContext.instance() + .getLoader(RenderAfterScripts.class, ServiceLoader.load(RenderAfterScripts.class))) + .in(Singleton.class); + bind(JWebMPServicesBindings.RenderAfterDynamicScriptsKey) + .toProvider(() -> IGuiceContext.instance() + .getLoader(RenderAfterDynamicScripts.class, ServiceLoader.load(RenderAfterDynamicScripts.class))) + .in(Singleton.class); + bind(JWebMPServicesBindings.RenderBeforeScriptsKey) + .toProvider(() -> IGuiceContext.instance() + .getLoader(RenderBeforeScripts.class, ServiceLoader.load(RenderBeforeScripts.class))) + .in(Singleton.class); + bind(JWebMPServicesBindings.RenderBeforeDynamicScriptsKey) + .toProvider(() -> IGuiceContext.instance() + .getLoader(RenderBeforeDynamicScripts.class, ServiceLoader.load(RenderBeforeDynamicScripts.class))) + .in(Singleton.class); + bind(JWebMPServicesBindings.RenderBeforeLinksKey) + .toProvider(() -> IGuiceContext.instance() + .getLoader(RenderBeforeLinks.class, ServiceLoader.load(RenderBeforeLinks.class))) + .in(Singleton.class); + bind(JWebMPServicesBindings.RenderAfterLinksKey) + .toProvider(() -> IGuiceContext + .instance() + .getLoader(RenderAfterLinks.class, ServiceLoader.load(RenderAfterLinks.class))) + .in(Singleton.class); - @Override - public void configure() - { - //noinspection unchecked - bind(JWebMPServicesBindings.IPageConfiguratorsKey) - .toProvider(() -> IGuiceContext.instance() - .getLoader(IPageConfigurator.class, ServiceLoader.load(IPageConfigurator.class))) - .in(Singleton.class); - bind(JWebMPServicesBindings.RenderAfterScriptsKey) - .toProvider(() -> IGuiceContext.instance() - .getLoader(RenderAfterScripts.class, ServiceLoader.load(RenderAfterScripts.class))) - .in(Singleton.class); - bind(JWebMPServicesBindings.RenderAfterDynamicScriptsKey) - .toProvider(() -> IGuiceContext.instance() - .getLoader(RenderAfterDynamicScripts.class, ServiceLoader.load(RenderAfterDynamicScripts.class))) - .in(Singleton.class); - bind(JWebMPServicesBindings.RenderBeforeScriptsKey) - .toProvider(() -> IGuiceContext.instance() - .getLoader(RenderBeforeScripts.class, ServiceLoader.load(RenderBeforeScripts.class))) - .in(Singleton.class); - bind(JWebMPServicesBindings.RenderBeforeDynamicScriptsKey) - .toProvider(() -> IGuiceContext.instance() - .getLoader(RenderBeforeDynamicScripts.class, ServiceLoader.load(RenderBeforeDynamicScripts.class))) - .in(Singleton.class); - bind(JWebMPServicesBindings.RenderBeforeLinksKey) - .toProvider(() -> IGuiceContext.instance() - .getLoader(RenderBeforeLinks.class, ServiceLoader.load(RenderBeforeLinks.class))) - .in(Singleton.class); - bind(JWebMPServicesBindings.RenderAfterLinksKey) - .toProvider(() -> IGuiceContext - .instance() - .getLoader(RenderAfterLinks.class, ServiceLoader.load(RenderAfterLinks.class))) - .in(Singleton.class); - } + } } diff --git a/src/main/java/com/jwebmp/core/implementations/JWebMPSiteBinder.java b/src/main/java/com/jwebmp/core/implementations/JWebMPSiteBinder.java deleted file mode 100644 index fa7316ed2..000000000 --- a/src/main/java/com/jwebmp/core/implementations/JWebMPSiteBinder.java +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.core.implementations; - -import com.google.inject.TypeLiteral; -import com.google.inject.servlet.ServletModule; - -import com.guicedee.client.*; -import com.guicedee.guicedinjection.interfaces.IGuiceModule; -import com.guicedee.guicedservlets.services.GuiceSiteInjectorModule; -import com.guicedee.guicedservlets.servlets.services.scopes.CallScope; -import com.jwebmp.core.Page; -import com.jwebmp.core.annotations.PageConfiguration; -import com.jwebmp.core.base.ComponentBase; -import com.jwebmp.core.base.ComponentHierarchyBase; -import com.jwebmp.core.base.ajax.AjaxCall; -import com.jwebmp.core.base.ajax.AjaxResponse; -import com.jwebmp.core.base.servlets.*; -import com.jwebmp.core.services.IPage; -import com.jwebmp.core.utilities.StaticStrings; -import lombok.extern.java.Log; -import net.sf.uadetector.ReadableUserAgent; -import net.sf.uadetector.UserAgentStringParser; -import net.sf.uadetector.service.UADetectorServiceFactory; - -import java.util.HashMap; -import java.util.Map; -import java.util.ServiceLoader; -import java.util.Set; -import java.util.logging.Level; - -import static com.guicedee.services.jsonrepresentation.json.StaticStrings.STRING_EMPTY; -import static com.guicedee.services.jsonrepresentation.json.StaticStrings.STRING_FORWARD_SLASH; - -/** - * @author GedMarc - * @version 1.0 - * @since 20 Dec 2016 - */ -@SuppressWarnings("unused") -@Log -public class JWebMPSiteBinder - extends ServletModule - implements IGuiceModule -{ - /** - * The User Agent Parser - */ - private static final UserAgentStringParser userAgentParser = UADetectorServiceFactory.getResourceModuleParser(); - - /** - * Field localStorageTypeLiteral - */ - @SuppressWarnings("Convert2Diamond") - private static final TypeLiteral> localStorageTypeLiteral = new TypeLiteral>() - { - }; - - /** - * Field sessionStorageTypeLiteral - */ - @SuppressWarnings("Convert2Diamond") - private static final TypeLiteral> sessionStorageTypeLiteral = new TypeLiteral>() - { - }; - - /** - * The class to use to render loading parts - */ - public static Class> loadingPartClass; - - public static boolean bindSites = true; - - /** - * Constructs a new instance, mostly for injection - */ - public JWebMPSiteBinder() - { - //Nothing Needed - } - - /** - * gets the location of the JavaScript Servlet - * - * @return The set script location for javascripts - */ - public static String getJavaScriptLocation() - { - return StaticStrings.JAVASCRIPT_LOCATION; - } - - /** - * Gets the current Ajax location - * - * @return The ajax screipt location - */ - public static String getAjaxScriptLocation() - { - return StaticStrings.AJAX_SCRIPT_LOCATION; - } - - /** - * Gets the CSS Location - * - * @return The CSS Location - */ - public static String getCSSLocation() - { - return StaticStrings.CSS_LOCATION; - } - - /** - * The JW Script Location - * - * @return the site script location - */ - public static String getJWScriptLocation() - { - return StaticStrings.JW_SCRIPT_LOCATION; - } - - /** - * Returns the url to access the data binding search - * - * @param component the component to render for - * @return The rendered URL string - */ - public static String getDataBindUrl(ComponentBase component) - { - return JWebMPSiteBinder.getDataLocation() - .replace(STRING_FORWARD_SLASH, STRING_EMPTY) + "?component=" + component.getID(); - } - - /** - * Gets the data location - * - * @return The given data location - */ - public static String getDataLocation() - { - return StaticStrings.DATA_LOCATION; - } - - /** - * Method onBind ... - * - */ - @SuppressWarnings("unchecked") - @Override - public void configureServlets() - { - JWebMPSiteBinder.log.fine("Bound UserAgentStringParser.class"); - bind(UserAgentStringParser.class) - .toInstance(JWebMPSiteBinder.userAgentParser); - JWebMPSiteBinder.log.fine("Bound ReadableUserAgent.class"); - - bind(ReadableUserAgent.class) - .toProvider(new ReadableUserAgentProvider()) - .in(CallScope.class); - - JWebMPSiteBinder.log.fine("Bound AjaxResponse.class"); - bind(AjaxResponse.class) - .in(CallScope.class); - - JWebMPSiteBinder.log.fine("Bound AjaxCall.class"); - bind(AjaxCall.class) - .in(CallScope.class); - - bind(IPage.class) - .to(Page.class); - bind(Page.class) - .toProvider(new PageProvider()) - .in(CallScope.class); - - JWebMPSiteBinder.log.fine("Bound Page.class"); - - if (bindSites) - { - @SuppressWarnings("rawtypes") - Set notInjectedPages = getPages(); - for (Map.Entry> entry : getPageConfigurations().entrySet()) - { - PageConfiguration pc = entry.getKey(); - IPage page = entry.getValue(); - if (pc == null) - { - JWebMPSiteBinder.log.log(Level.SEVERE, "Couldn't Find Page Configuration on IPage Object {0}", new Object[]{page.getClass().getCanonicalName()}); - } - else if (!pc.ignore()) - { - StringBuilder url = new StringBuilder(pc.url()); - url.insert(0, "(") - .append(StaticStrings.QUERY_PARAMETERS_REGEX) - .append(")"); - - - serveRegex(url.toString()) - .with(JWebMPServlet.class); - PageProvider.getUrlToClass() - .put(pc.url(), (Class>) page.getClass()); - JWebMPSiteBinder.log.log(Level.CONFIG, "Serving Page URL [{0}] with [{1}]", new Object[]{pc.url(), page.getClass().getCanonicalName()}); - - - url = new StringBuilder(pc.url() - .substring(0, pc.url() - .length() - 1) + StaticStrings.JAVASCRIPT_LOCATION); - - url.insert(0, "(") - .append(StaticStrings.QUERY_PARAMETERS_REGEX) - .append(")"); - - serveRegex(url.toString()) - .with(JavaScriptServlet.class); - JWebMPSiteBinder.log.log(Level.FINE, "Serving JavaScripts at {0}", url); - - - url = new StringBuilder(pc.url() - .substring(0, pc.url() - .length() - 1) + StaticStrings.AJAX_SCRIPT_LOCATION); - - url.insert(0, "(") - .append(StaticStrings.QUERY_PARAMETERS_REGEX) - .append(")"); - - serveRegex(url.toString()) - .with(AjaxReceiverServlet.class); - JWebMPSiteBinder.log.log(Level.FINE, "Serving Ajax at {0}", url); - - - url = new StringBuilder(pc.url() - .substring(0, pc.url() - .length() - 1) + StaticStrings.CSS_LOCATION); - - url.insert(0, "(") - .append(StaticStrings.QUERY_PARAMETERS_REGEX) - .append(")"); - - serveRegex(url.toString()) - .with(CSSServlet.class); - JWebMPSiteBinder.log.log(Level.FINE, "Serving CSS at {0}", url); - - - url = new StringBuilder(pc.url() - .substring(0, pc.url() - .length() - 1) + StaticStrings.DATA_LOCATION); - - url.insert(0, "(") - .append(StaticStrings.QUERY_PARAMETERS_REGEX) - .append(")"); - - serveRegex(url.toString()) - .with(DataServlet.class); - JWebMPSiteBinder.log.log(Level.FINE, "Serving Data at {0}", url); - - url = new StringBuilder(pc.url() - .substring(0, pc.url() - .length() - 1) + StaticStrings.JW_SCRIPT_LOCATION); - - url.insert(0, "(") - .append(StaticStrings.QUERY_PARAMETERS_REGEX) - .append(")"); - - serveRegex(url.toString()) - .with(JWScriptServlet.class); - JWebMPSiteBinder.log.log(Level.FINE, "Serving Default Script at {0}", url); - } - } - - serveRegex("(" + StaticStrings.JAVASCRIPT_LOCATION + ")" + StaticStrings.QUERY_PARAMETERS_REGEX) - .with(JavaScriptServlet.class); - JWebMPSiteBinder.log.log(Level.FINE, "Serving JavaScripts at {0}", StaticStrings.JAVASCRIPT_LOCATION); - - - serveRegex("(" + StaticStrings.AJAX_SCRIPT_LOCATION + ")" + StaticStrings.QUERY_PARAMETERS_REGEX) - .with(AjaxReceiverServlet.class); - JWebMPSiteBinder.log.log(Level.FINE, "Serving Ajax at {0}", StaticStrings.AJAX_SCRIPT_LOCATION); - - serveRegex("(" + StaticStrings.CSS_LOCATION + ")" + StaticStrings.QUERY_PARAMETERS_REGEX) - .with(CSSServlet.class); - JWebMPSiteBinder.log.log(Level.FINE, "Serving CSS at {0}", StaticStrings.CSS_LOCATION); - - serveRegex("(" + StaticStrings.DATA_LOCATION + ")" + StaticStrings.QUERY_PARAMETERS_REGEX) - .with(DataServlet.class); - JWebMPSiteBinder.log.log(Level.FINE, "Serving Data at {0}", StaticStrings.DATA_LOCATION); - - serveRegex("(" + StaticStrings.JW_SCRIPT_LOCATION + ")" + StaticStrings.QUERY_PARAMETERS_REGEX) - .with(JWScriptServlet.class); - - JWebMPSiteBinder.log.log(Level.FINE, "Serving Default Script at {0}", StaticStrings.JW_SCRIPT_LOCATION); - } - } - - public static Set getPages() - { - return IGuiceContext.instance() - .getLoader(IPage.class, true, ServiceLoader.load(IPage.class)); - } - - public static Map> getPageConfigurations() - { - Map> pagesMap = new HashMap<>(); - - @SuppressWarnings("rawtypes") - Set pages = IGuiceContext - .instance() - .getLoader(IPage.class, true, ServiceLoader.load(IPage.class)); - for (IPage page : pages) - { - PageConfiguration pc = page.getClass() - .getAnnotation(PageConfiguration.class); - if (pc == null) - { - JWebMPSiteBinder.log.log(Level.SEVERE, "Couldn't Find Page Configuration on IPage Object {0}", new Object[]{page.getClass().getCanonicalName()}); - } - else if (!pc.ignore()) - { - pagesMap.put(pc, page); - } - } - - return pagesMap; - } - -} diff --git a/src/main/java/com/jwebmp/core/implementations/JacksonEventDeserializer.java b/src/main/java/com/jwebmp/core/implementations/JacksonEventDeserializer.java new file mode 100644 index 000000000..7c0e2bdda --- /dev/null +++ b/src/main/java/com/jwebmp/core/implementations/JacksonEventDeserializer.java @@ -0,0 +1,24 @@ +package com.jwebmp.core.implementations; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.jwebmp.core.Event; +import com.jwebmp.core.htmlbuilder.javascript.events.interfaces.IEvent; + +import java.io.IOException; + +public class JacksonEventDeserializer extends JsonDeserializer> +{ + @Override + public IEvent deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JacksonException + { + String valueAsString = p.getValueAsString(); + Event o = (Event) new Event("") + { + }.fromJson(valueAsString); + + return o; + } +} diff --git a/src/main/java/com/jwebmp/core/implementations/JacksonEventTypeDeserializer.java b/src/main/java/com/jwebmp/core/implementations/JacksonEventTypeDeserializer.java new file mode 100644 index 000000000..441cb4107 --- /dev/null +++ b/src/main/java/com/jwebmp/core/implementations/JacksonEventTypeDeserializer.java @@ -0,0 +1,33 @@ +package com.jwebmp.core.implementations; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.google.common.base.Strings; +import com.jwebmp.core.htmlbuilder.javascript.events.enumerations.EventTypes; +import com.jwebmp.core.services.IEventTypes; + +import java.io.IOException; + +public class JacksonEventTypeDeserializer extends JsonDeserializer> +{ + @Override + public IEventTypes deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JacksonException + { + String valueAsString = p.getValueAsString(); + if (Strings.isNullOrEmpty(valueAsString)) + { + return null; + } + try + { + EventTypes eventTypes = EventTypes.valueOf(valueAsString); + return eventTypes; + } + catch (IllegalArgumentException e) + { + return null; + } + } +} diff --git a/src/main/java/com/jwebmp/core/implementations/PageProvider.java b/src/main/java/com/jwebmp/core/implementations/PageProvider.java deleted file mode 100644 index d512bbb21..000000000 --- a/src/main/java/com/jwebmp/core/implementations/PageProvider.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.jwebmp.core.implementations; - -import com.google.common.base.*; -import com.google.inject.*; -import com.guicedee.client.*; -import com.guicedee.guicedservlets.*; -import com.guicedee.services.jsonrepresentation.json.*; -import com.jwebmp.core.*; -import com.jwebmp.core.base.ajax.*; -import com.jwebmp.core.services.*; -import jakarta.servlet.http.*; - -import java.util.*; - -@SuppressWarnings("rawtypes") -public class PageProvider - implements Provider -{ - private static final Map>> urlToClass = new HashMap<>(); - - @Override - public Page get() - { - try - { - AjaxCall call = IGuiceContext.get(AjaxCall.class); - if (call.getHeaders() - .getAppClassName() != null && !Strings.isNullOrEmpty(call.getHeaders() - .getAppClassName())) - { - String className = call.getHeaders() - .getAppClassName(); - Class pageClass = IGuiceContext.instance() - .getScanResult() - .loadClass(className, true); - return (Page) IGuiceContext.get(pageClass); - } - } - catch (ProvisionException | OutOfScopeException e) - { - - } - - HttpServletRequest request = IGuiceContext.get(GuicedServletKeys.getHttpServletRequestKey()); - String pathInfo = request.getRequestURI(); - if (pathInfo == null) - { - pathInfo = StaticStrings.STRING_FORWARD_SLASH; - } - pathInfo = pathInfo.toLowerCase(); - if (urlToClass.containsKey(pathInfo)) - { - return (Page) IGuiceContext.get(urlToClass.get(pathInfo)); - } - pathInfo = pathInfo.substring(0, pathInfo.lastIndexOf('/') + 1); - if (urlToClass.containsKey(pathInfo)) - { - return (Page) IGuiceContext.get(urlToClass.get(pathInfo)); - } - - - return new Page<>(); - } - - /** - * Method getPages returns the pages of this PageProvider object. - * - * @return the pages (type ServiceLoader IPage ) of this PageProvider object. - */ - @SuppressWarnings({"unchecked"}) - public static Set> getPages() - { - @SuppressWarnings("UnnecessaryLocalVariable") - Set pages = IGuiceContext.instance() - .getLoader(IPage.class, ServiceLoader.load(IPage.class)); - return pages; - } - - public static Map>> getUrlToClass() - { - return urlToClass; - } -} diff --git a/src/main/java/com/jwebmp/core/implementations/ReadableUserAgentProvider.java b/src/main/java/com/jwebmp/core/implementations/ReadableUserAgentProvider.java deleted file mode 100644 index aa765f4c0..000000000 --- a/src/main/java/com/jwebmp/core/implementations/ReadableUserAgentProvider.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.jwebmp.core.implementations; - -import com.google.common.base.*; -import com.google.inject.*; -import com.guicedee.client.*; -import com.jwebmp.core.base.ajax.*; -import jakarta.servlet.http.*; -import net.sf.uadetector.*; - -import static com.guicedee.services.jsonrepresentation.json.StaticStrings.STRING_EMPTY; - -public class ReadableUserAgentProvider implements Provider -{ - - @Inject - private UserAgentStringParser userAgentStringParser; - - @Override - public ReadableUserAgent get() - { - try - { - HttpServletRequest request = IGuiceContext.get(HttpServletRequest.class); - String headerInformation = request.getHeader("User-Agent"); - if (!Strings.isNullOrEmpty(headerInformation)) - { - ReadableUserAgent agent = userAgentStringParser.parse(headerInformation); - return agent; - } - return defaultAgent(); - } - catch (ProvisionException | OutOfScopeException e) - { - try - { - AjaxCall call = IGuiceContext.get(AjaxCall.class); - HeadersDTO headers = call.getHeaders(); - if (!Strings.isNullOrEmpty(headers.useragent)) - { - ReadableUserAgent agent = userAgentStringParser.parse(headers.useragent); - return agent; - } - } - catch (Throwable T) - { - return defaultAgent(); - } - return defaultAgent(); - } - } - - - - public static ReadableUserAgent defaultAgent() - { - return new UserAgent(DeviceCategory.EMPTY, UserAgentFamily.FIREFOX, STRING_EMPTY, STRING_EMPTY, OperatingSystem.EMPTY, - STRING_EMPTY, STRING_EMPTY, - UserAgentType.BROWSER, STRING_EMPTY, STRING_EMPTY, VersionNumber.UNKNOWN); - } -} diff --git a/src/main/java/com/jwebmp/core/utilities/StaticStrings.java b/src/main/java/com/jwebmp/core/utilities/StaticStrings.java deleted file mode 100644 index 1fc9c0ae2..000000000 --- a/src/main/java/com/jwebmp/core/utilities/StaticStrings.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.jwebmp.core.utilities; - -import java.io.Serializable; -import java.nio.charset.Charset; - -/** - * Default set of strings - */ -@SuppressWarnings("MissingFieldJavaDoc") -public interface StaticStrings - extends Serializable -{ - String REQUEST_SITE_HEADER_NAME = "jwsiteurl"; - - String HTML_HEADER_JSON = "text/json"; - String HTML_HEADER_JAVASCRIPT = "application/javascript"; - String HTML_HEADER_CSS = "text/css"; - String HTML_HEADER_DEFAULT_CONTENT_TYPE = "text/html"; - - String STRING_ANGULAR_EVENT_START = "jwCntrl.perform($event,"; - String STRING_ANGULAR_EVENT_START_SHORT = "perform($event,"; - - String JAVASCRIPT_LOCATION = "/jwjs"; - String AJAX_SCRIPT_LOCATION = "/jwajax"; - String CSS_LOCATION = "/jwcss"; - String ANGULAR_DATA_LOCATION = "/jwad"; - String ANGULAR_SCRIPT_LOCATION = "/jwas"; - String JW_SCRIPT_LOCATION = "/jwscr"; - String DATA_LOCATION = "/jwdata"; - - /** - * A default regex to identify query parameters - */ - String QUERY_PARAMETERS_REGEX = "(\\?.*)?"; - String NOT_WEB_SOCKETS = "(?!wssocket)"; - - String SESSION_STORAGE_TAB_KEY = "sessionkey"; - String SESSION_STORAGE_PARAMETER_KEY = "sessionid"; - String LOCAL_STORAGE_PARAMETER_KEY = "jwamsmk"; - String LOCAL_STORAGE_VARIABLE_KEY = "jwCntrl.jw.localstorage"; - String SESSION_STORAGE_VARIABLE_KEY = "jwCntrl.jw.sessionstorage"; - String LocalStorageSessionAttributeKey = "LocalStorage"; - String SessionStorageSessionAttributeKey = "SessionStorage"; - - String ACCESS_CONTROL_ALLOW_ORIGIN_HEADER_NAME = "Access-Control-Allow-Origin"; - String ACCESS_CONTROL_ALLOW_CREDENTIALS_HEADER_NAME = "Access-Control-Allow-Credentials"; - String ACCESS_CONTROL_ALLOW_METHODS_HEADER_NAME = "Access-Control-Allow-Methods"; - String ACCESS_CONTROL_ALLOW_HEADERS_HEADER_NAME = "Access-Control-Allow-Headers"; - - String DEFAULT_DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; - String STRING_SELECTED = "selected"; - /** - * The × string - */ - String HTML_TIMES = "×"; - /** - * The   string - */ - String HTML_TAB = " "; - String HTML_AMPERSAND = "&"; - /** - * Default text for Latin - */ - String ShortLatin = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eleifend..."; - /** - * Default Medium text for Latin - */ - String MediumLatin = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Libero laboriosam dolor perspiciatis omnis " + - "exercitationem. Beatae, officia pariatur? Est cum veniam excepturi. Maiores praesentium, porro voluptas" + - " dicta, " + - "debitis..."; -} diff --git a/src/main/java/com/jwebmp/interception/JWebMPInterceptionBinder.java b/src/main/java/com/jwebmp/interception/JWebMPInterceptionBinder.java deleted file mode 100644 index dec051c47..000000000 --- a/src/main/java/com/jwebmp/interception/JWebMPInterceptionBinder.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.jwebmp.interception; - -import com.google.inject.AbstractModule; -import com.google.inject.Key; -import com.google.inject.Singleton; -import com.google.inject.TypeLiteral; - -import com.guicedee.client.*; -import com.guicedee.guicedinjection.interfaces.IGuiceModule; -import com.jwebmp.interception.services.AjaxCallIntercepter; -import com.jwebmp.interception.services.DataCallIntercepter; -import com.jwebmp.interception.services.SiteCallIntercepter; - -import java.util.ServiceLoader; -import java.util.Set; - -@SuppressWarnings({"Convert2Diamond","unchecked", "rawtypes"}) -public class JWebMPInterceptionBinder - extends AbstractModule - implements IGuiceModule -{ - public static final Key> AjaxCallInterceptorKey = Key.get(new TypeLiteral>() {}); - public static final Key> DataCallInterceptorKey = Key.get(new TypeLiteral>() {}); - public static final Key> SiteCallInterceptorKey = Key.get(new TypeLiteral>() {}); - - @Override - public void configure() - { - bind(JWebMPInterceptionBinder.AjaxCallInterceptorKey) - .toProvider(() -> IGuiceContext - .instance() - .getLoader(AjaxCallIntercepter.class, ServiceLoader.load(AjaxCallIntercepter.class))) - .in(Singleton.class); - - bind(JWebMPInterceptionBinder.DataCallInterceptorKey) - .toProvider(() -> IGuiceContext.instance() - .getLoader(DataCallIntercepter.class, ServiceLoader.load(DataCallIntercepter.class))) - .in(Singleton.class); - - bind(JWebMPInterceptionBinder.SiteCallInterceptorKey) - .toProvider(() -> IGuiceContext.instance() - .getLoader(SiteCallIntercepter.class, ServiceLoader.load(SiteCallIntercepter.class))) - .in(Singleton.class); - } -} diff --git a/src/main/java/com/jwebmp/interception/services/AjaxCallIntercepter.java b/src/main/java/com/jwebmp/interception/services/AjaxCallIntercepter.java deleted file mode 100644 index aeea1f082..000000000 --- a/src/main/java/com/jwebmp/interception/services/AjaxCallIntercepter.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.interception.services; - -/** - * Intercepts a call specific to an AJAX event. - * - * @author GedMarc - * @since 10 Apr 2017 - */ -public interface AjaxCallIntercepter> - extends SiteCallIntercepter -{ - -} diff --git a/src/main/java/com/jwebmp/interception/services/DataCallIntercepter.java b/src/main/java/com/jwebmp/interception/services/DataCallIntercepter.java deleted file mode 100644 index b5e43e29b..000000000 --- a/src/main/java/com/jwebmp/interception/services/DataCallIntercepter.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.interception.services; - -/** - * Intercepts the Startup Data Call. Interception for directly after page - * delivered - * - * @author GedMarc - * @since 10 Apr 2017 - */ -public interface DataCallIntercepter> - extends SiteCallIntercepter -{ - -} diff --git a/src/main/java/com/jwebmp/interception/services/SiteCallIntercepter.java b/src/main/java/com/jwebmp/interception/services/SiteCallIntercepter.java deleted file mode 100644 index 2cdea84f6..000000000 --- a/src/main/java/com/jwebmp/interception/services/SiteCallIntercepter.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jwebmp.interception.services; - -import com.guicedee.guicedinjection.interfaces.IDefaultService; -import com.jwebmp.core.base.ajax.AjaxCall; -import com.jwebmp.core.base.ajax.AjaxResponse; - -/** - * Intercepts on the sites first call. Local Storage Session Storage and other items are not available - * - * @author GedMarc - * @since 10 Apr 2017 - */ -public interface SiteCallIntercepter> - extends IDefaultService -{ - void intercept(AjaxCall call, AjaxResponse response); -} diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 2938dad48..99c69079f 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,18 +1,18 @@ import com.guicedee.guicedinjection.interfaces.IGuiceModule; +import com.guicedee.guicedinjection.interfaces.IGuicePostStartup; import com.jwebmp.core.events.services.*; +import com.jwebmp.core.implementations.JWebMPPostStartup; import com.jwebmp.core.implementations.JWebMPServicesBindings; -import com.jwebmp.core.implementations.JWebMPSiteBinder; -import com.jwebmp.interception.JWebMPInterceptionBinder; module com.jwebmp.core { requires static lombok; requires transitive com.guicedee.client; - requires transitive com.guicedee.guicedservlets; + //requires transitive com.guicedee.guicedservlets; requires transitive jakarta.validation; - requires transitive jakarta.servlet; - requires transitive com.google.guice.extensions.servlet; + //requires transitive jakarta.servlet; + //requires transitive com.google.guice.extensions.servlet; requires net.sf.uadetector.core; requires net.sf.uadetector.resources; @@ -26,8 +26,11 @@ requires com.fasterxml.jackson.databind; requires com.fasterxml.jackson.core; - requires jakarta.websocket; - requires jakarta.websocket.client; + //requires guiced.vertx; + //requires guiced.vertx.sockets; + + //requires jakarta.websocket; + //requires jakarta.websocket.client; requires com.google.common; requires org.apache.commons.io; @@ -55,11 +58,11 @@ exports com.jwebmp.core.base.page; - exports com.jwebmp.core.base.servlets; + // exports com.jwebmp.core.base.servlets; // exports com.jwebmp.core.base.servlets.enumarations; // exports com.jwebmp.core.base.servlets.interfaces; - exports com.jwebmp.core.base.servlets.options; + //exports com.jwebmp.core.base.servlets.options; //exports com.jwebmp.core.databind; exports com.jwebmp.core.events.activate; @@ -115,8 +118,6 @@ exports com.jwebmp.core.events.unselected; exports com.jwebmp.core.events.update; - exports com.jwebmp.core.exceptions; - // exports com.jwebmp.core.generics; exports com.jwebmp.core.annotations; @@ -143,9 +144,6 @@ exports com.jwebmp.core.htmlbuilder.css.text; // exports com.jwebmp.core.htmlbuilder.css.themes; - exports com.jwebmp.interception.services; - exports com.jwebmp.interception; - // exports com.jwebmp.core.htmlbuilder.javascript; exports com.jwebmp.core.htmlbuilder.javascript.events.commandevent; exports com.jwebmp.core.htmlbuilder.javascript.events.enumerations; @@ -161,10 +159,10 @@ // exports com.jwebmp.core.base.references; - uses com.jwebmp.interception.services.AjaxCallIntercepter; + /* uses com.jwebmp.interception.services.AjaxCallIntercepter; uses com.jwebmp.interception.services.DataCallIntercepter; uses com.jwebmp.interception.services.SiteCallIntercepter; - +*/ uses com.jwebmp.core.services.IRegularExpressions; uses com.jwebmp.core.services.IPageConfigurator; @@ -239,18 +237,15 @@ uses com.jwebmp.core.databind.IOnComponentAdded; - provides IGuiceModule with JWebMPServicesBindings, JWebMPInterceptionBinder, JWebMPSiteBinder; + provides IGuiceModule with JWebMPServicesBindings; + provides IGuicePostStartup with JWebMPPostStartup; provides com.guicedee.guicedinjection.interfaces.IGuiceScanModuleInclusions with com.jwebmp.core.implementations.JWebMPModuleInclusions; - provides com.jwebmp.core.services.IDynamicRenderingServlet with com.jwebmp.core.implementations.JWebMPDynamicScriptRenderer, com.jwebmp.core.implementations.JWebMPJavaScriptDynamicScriptRenderer; - provides com.jwebmp.core.services.IRegularExpressions with com.jwebmp.core.utilities.regex.TextRegExPatterns, com.jwebmp.core.utilities.regex.EmailAddressRegExPatterns, com.jwebmp.core.utilities.regex.DateFormatRegExPatterns; provides com.jwebmp.core.services.IPageConfigurator with com.jwebmp.core.base.page.ScriptsDynamicPageConfigurator, com.jwebmp.core.base.page.CSSLinksInsertPageConfigurator, com.jwebmp.core.base.page.ScriptsInsertPageConfigurator, com.jwebmp.core.base.page.TopShelfScriptsInsertPageConfigurator; - opens com.jwebmp.core.base.servlets to com.google.guice, com.fasterxml.jackson.databind; - opens com.jwebmp.core.base.page to com.google.guice; // opens com.jwebmp.core.base.ajax to com.fasterxml.jackson.databind; opens com.jwebmp.core.base.html to com.fasterxml.jackson.databind; @@ -286,7 +281,6 @@ // opens com.jwebmp.core.base.client to com.fasterxml.jackson.databind; // opens com.jwebmp.core.base.servlets.interfaces to com.fasterxml.jackson.databind; - opens com.jwebmp.core.base.servlets.options to com.fasterxml.jackson.databind; opens com.jwebmp.core.utilities.regex to com.fasterxml.jackson.databind; diff --git a/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuiceDefaultBinder b/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuiceDefaultBinder index f4e879e6f..e49238ce9 100644 --- a/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuiceDefaultBinder +++ b/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuiceDefaultBinder @@ -1,2 +1,2 @@ com.jwebmp.core.implementations.JWebMPServicesBindings -com.jwebmp.interception.JWebMPInterceptionBinder +com.jwebmp.interception.services.JWebMPInterceptionBinder diff --git a/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuiceModule b/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuiceModule index 1d61d79ec..2ae551113 100644 --- a/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuiceModule +++ b/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuiceModule @@ -1,3 +1,2 @@ com.jwebmp.core.implementations.JWebMPServicesBindings -com.jwebmp.interception.JWebMPInterceptionBinder -com.jwebmp.core.implementations.JWebMPSiteBinder \ No newline at end of file +com.jwebmp.interception.services.JWebMPInterceptionBinder \ No newline at end of file diff --git a/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuicePostStartup b/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuicePostStartup new file mode 100644 index 000000000..b9966c5eb --- /dev/null +++ b/src/main/resources/META-INF/services/com.guicedee.guicedinjection.interfaces.IGuicePostStartup @@ -0,0 +1 @@ +com.jwebmp.core.implementations.JWebMPPostStartup \ No newline at end of file diff --git a/src/main/resources/META-INF/services/com.guicedee.guicedservlets.services.IGuiceSiteBinder b/src/main/resources/META-INF/services/com.guicedee.guicedservlets.services.IGuiceSiteBinder deleted file mode 100644 index a5a4367cc..000000000 --- a/src/main/resources/META-INF/services/com.guicedee.guicedservlets.services.IGuiceSiteBinder +++ /dev/null @@ -1 +0,0 @@ -com.jwebmp.core.implementations.JWebMPSiteBinder diff --git a/src/main/resources/META-INF/services/com.jwebmp.core.services.IDynamicRenderingServlet b/src/main/resources/META-INF/services/com.jwebmp.core.services.IDynamicRenderingServlet deleted file mode 100644 index a0004e93d..000000000 --- a/src/main/resources/META-INF/services/com.jwebmp.core.services.IDynamicRenderingServlet +++ /dev/null @@ -1,2 +0,0 @@ -com.jwebmp.core.implementations.JWebMPDynamicScriptRenderer -com.jwebmp.core.implementations.JWebMPJavaScriptDynamicScriptRenderer diff --git a/src/test/java/com/jwebmp/base/servlet/AjaxReceiverTest.java b/src/test/java/com/jwebmp/base/servlet/AjaxReceiverTest.java deleted file mode 100644 index af4a58c60..000000000 --- a/src/test/java/com/jwebmp/base/servlet/AjaxReceiverTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2017 GedMarc - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.jwebmp.core.base.servlet; - -import com.jwebmp.core.base.servlets.AjaxReceiverServlet; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -/** - * @author MMagon - */ -public class AjaxReceiverTest -{ - private AjaxReceiverServlet ar = new AjaxReceiverServlet(); - - - public AjaxReceiverTest() - { - } - - @BeforeEach - public void setUp() - { - } - - @Test - public void testGetServletInfo() - { - } - - @Test - public void testAddUpdatedComponentToResponse() - { - } - -}