From b487a4960ea27aa5651f17c6b4563eb4529b2af2 Mon Sep 17 00:00:00 2001 From: GedMarc Date: Fri, 26 Apr 2024 21:30:50 +0200 Subject: [PATCH] Base Servlet support for JWebMP --- pom.xml | 13 +- .../core/annotations/PageConfiguration.java | 53 ++++ .../jwebmp/core/annotations/PageTypes.java | 58 ++++ .../com/jwebmp/core/base/ajax/AjaxCall.java | 95 +----- .../core/base/ajax/AjaxComponentUpdates.java | 14 +- .../jwebmp/core/base/ajax/AjaxResponse.java | 15 +- .../com/jwebmp/core/base/ajax/IAjaxCall.java | 16 +- .../base/html/interfaces/InputChoiceType.java | 4 +- .../core/base/interfaces/IComponentBase.java | 9 +- .../interfaces/IComponentFeatureBase.java | 15 +- .../IComponentHTMLAttributeBase.java | 3 +- .../base/interfaces/IComponentHTMLBase.java | 8 +- .../interfaces/IComponentHierarchyBase.java | 17 +- .../base/interfaces/IComponentStyleBase.java | 7 +- .../base/references/JavascriptReference.java | 10 +- .../enumarations/DevelopmentEnvironments.java | 7 +- .../servlets/interfaces/IDataComponent.java | 3 +- .../core/databind/ClientVariableWatcher.java | 10 +- .../core/databind/IClientVariableWatcher.java | 4 +- .../com/jwebmp/core/databind/IOnDataBind.java | 4 +- .../core/databind/IOnDataBindCloak.java | 4 +- .../exceptions/InvalidRequestException.java | 52 ++++ .../exceptions/MissingComponentException.java | 52 ++++ .../exceptions/NoServletFoundException.java | 52 ++++ .../exceptions/NullComponentException.java | 89 ++++++ .../exceptions/UserSecurityException.java | 52 ++++ .../jwebmp/core/generics/FileTemplates.java | 285 ++++++++++++++++++ .../jwebmp/core/generics/WebReference.java | 44 +-- .../java/com/jwebmp/core/services/IPage.java | 4 +- .../core/services/IPageConfigurator.java | 7 +- .../services/AjaxCallIntercepter.java | 29 ++ .../services/DataCallIntercepter.java | 30 ++ .../services/JWebMPInterceptionBinder.java | 13 + .../interception/services/ScriptProvider.java | 8 + .../services/SiteCallIntercepter.java | 33 ++ .../interception/services/StaticStrings.java | 88 ++++++ src/main/java/module-info.java | 12 +- src/test/java/com/jwebmp/BaseTestClass.java | 3 - 38 files changed, 1008 insertions(+), 214 deletions(-) create mode 100644 src/main/java/com/jwebmp/core/annotations/PageConfiguration.java create mode 100644 src/main/java/com/jwebmp/core/annotations/PageTypes.java create mode 100644 src/main/java/com/jwebmp/core/exceptions/InvalidRequestException.java create mode 100644 src/main/java/com/jwebmp/core/exceptions/MissingComponentException.java create mode 100644 src/main/java/com/jwebmp/core/exceptions/NoServletFoundException.java create mode 100644 src/main/java/com/jwebmp/core/exceptions/NullComponentException.java create mode 100644 src/main/java/com/jwebmp/core/exceptions/UserSecurityException.java create mode 100644 src/main/java/com/jwebmp/core/generics/FileTemplates.java create mode 100644 src/main/java/com/jwebmp/interception/services/AjaxCallIntercepter.java create mode 100644 src/main/java/com/jwebmp/interception/services/DataCallIntercepter.java create mode 100644 src/main/java/com/jwebmp/interception/services/JWebMPInterceptionBinder.java create mode 100644 src/main/java/com/jwebmp/interception/services/ScriptProvider.java create mode 100644 src/main/java/com/jwebmp/interception/services/SiteCallIntercepter.java create mode 100644 src/main/java/com/jwebmp/interception/services/StaticStrings.java diff --git a/pom.xml b/pom.xml index 6650954..fd538be 100644 --- a/pom.xml +++ b/pom.xml @@ -34,17 +34,10 @@ - jakarta.websocket - jakarta.websocket-client-api - - - jakarta.websocket - jakarta.websocket-api - - - com.jwebmp.core - jwebmp-testlib + commons-io + commons-io + diff --git a/src/main/java/com/jwebmp/core/annotations/PageConfiguration.java b/src/main/java/com/jwebmp/core/annotations/PageConfiguration.java new file mode 100644 index 0000000..310eab5 --- /dev/null +++ b/src/main/java/com/jwebmp/core/annotations/PageConfiguration.java @@ -0,0 +1,53 @@ +/* + * 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 new file mode 100644 index 0000000..288d0a6 --- /dev/null +++ b/src/main/java/com/jwebmp/core/annotations/PageTypes.java @@ -0,0 +1,58 @@ +/* + * 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/ajax/AjaxCall.java b/src/main/java/com/jwebmp/core/base/ajax/AjaxCall.java index 781f801..955e72e 100644 --- a/src/main/java/com/jwebmp/core/base/ajax/AjaxCall.java +++ b/src/main/java/com/jwebmp/core/base/ajax/AjaxCall.java @@ -20,20 +20,12 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.google.common.base.Strings; -import com.google.inject.Inject; -import com.google.inject.Key; -import com.google.inject.OutOfScopeException; -import com.google.inject.ProvisionException; -import com.google.inject.name.Names; import com.guicedee.client.IGuiceContext; import com.guicedee.guicedinjection.interfaces.ObjectBinderKeys; import com.guicedee.guicedservlets.servlets.services.scopes.CallScope; import com.jwebmp.core.base.interfaces.IComponentHierarchyBase; import com.jwebmp.core.htmlbuilder.javascript.JavaScriptPart; import com.jwebmp.core.services.IEventTypes; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.validation.constraints.NotNull; -import jakarta.websocket.Session; import java.util.Date; import java.util.HashMap; @@ -110,16 +102,6 @@ public class AjaxCall> * The given path route for the application */ private String route; - /** - * If this call originates through a web socket (so there is no request or session scope), - * or if it is a direct page call - */ - private boolean isWebSocketCall; - /** - * The web socket session for this call - */ - @JsonIgnore - private Session websocketSession; /** * If this is a page or a supporting servlet call @@ -137,28 +119,6 @@ public AjaxCall() //set nothing } - @Inject - void configure() - { - try - { - //@see guiced-servlets, this is a default key - HttpServletRequest request = IGuiceContext.get(Key.get(HttpServletRequest.class, Names.named("Servlet"))); - for (Map.Entry entry : request.getParameterMap() - .entrySet()) - { - String key = entry.getKey(); - String[] value = entry.getValue(); - getParameters() - .put(key, value[0]); - } - } - catch (OutOfScopeException | ProvisionException e) - { - //ignore - } - } - public String getAttribute(String attribute) { if (getAttributes() != null && getAttributes() @@ -239,8 +199,6 @@ public J fromCall(AjaxCall incoming) setLocalStorage(incoming.getLocalStorage()); setSessionStorage(incoming.getSessionStorage()); setHashBang(incoming.getHashBang()); - setWebsocketSession(incoming.getWebsocketSession()); - setWebSocketCall(incoming.isWebSocketCall()); unknownFields = Map.copyOf(incoming.unknownFields); return (J) this; @@ -296,55 +254,8 @@ public J setEventType(IEventTypes eventType) return (J) this; } - /** - * If this call originates through a web socket (so there is no request or session scope), - * * or if it is a direct page call - * - * @return - */ - public boolean isWebSocketCall() - { - return isWebSocketCall; - } - - /** - * If this call originates through a web socket (so there is no request or session scope), - * * or if it is a direct page call - * - * @param webSocketCall - */ - @SuppressWarnings("unchecked") - public J setWebSocketCall(boolean webSocketCall) - { - isWebSocketCall = webSocketCall; - return (J) this; - } - - /** - * The web socket session for this call - * - * @return - */ - public Session getWebsocketSession() - { - return websocketSession; - } - - /** - * The web socket session for this call - * - * @param websocketSession - * @return - */ - @SuppressWarnings("unchecked") - public J setWebsocketSession(Session websocketSession) - { - this.websocketSession = websocketSession; - return (J) this; - } - @Override - @NotNull + public Map getParameters() { if (parameters == null) @@ -363,14 +274,14 @@ public J setParameters(Map parameters) } @Override - @NotNull + public String getClassName() { return className; } @Override - @NotNull + @SuppressWarnings("unchecked") public J setClassName(String className) { diff --git a/src/main/java/com/jwebmp/core/base/ajax/AjaxComponentUpdates.java b/src/main/java/com/jwebmp/core/base/ajax/AjaxComponentUpdates.java index 7f533df..87e0866 100644 --- a/src/main/java/com/jwebmp/core/base/ajax/AjaxComponentUpdates.java +++ b/src/main/java/com/jwebmp/core/base/ajax/AjaxComponentUpdates.java @@ -16,10 +16,10 @@ */ package com.jwebmp.core.base.ajax; -import com.fasterxml.jackson.annotation.*; -import com.jwebmp.core.base.interfaces.*; -import com.jwebmp.core.htmlbuilder.javascript.*; -import jakarta.validation.constraints.*; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.jwebmp.core.base.interfaces.IComponentHierarchyBase; +import com.jwebmp.core.htmlbuilder.javascript.JavaScriptPart; + /** * A JSON Class for component updates @@ -72,7 +72,7 @@ public String getHtml() * @param html */ @SuppressWarnings("unchecked") - @NotNull + public J setHtml(String html) { this.html = html; @@ -95,7 +95,7 @@ public String getId() * @param id */ @SuppressWarnings("unchecked") - @NotNull + public J setId(String id) { this.id = id; @@ -118,7 +118,7 @@ public AjaxComponentInsertType getInsertType() * @param insertType */ @SuppressWarnings("unchecked") - @NotNull + public J setInsertType(AjaxComponentInsertType insertType) { this.insertType = insertType; diff --git a/src/main/java/com/jwebmp/core/base/ajax/AjaxResponse.java b/src/main/java/com/jwebmp/core/base/ajax/AjaxResponse.java index b9b3745..22ce8da 100644 --- a/src/main/java/com/jwebmp/core/base/ajax/AjaxResponse.java +++ b/src/main/java/com/jwebmp/core/base/ajax/AjaxResponse.java @@ -16,12 +16,13 @@ */ package com.jwebmp.core.base.ajax; -import com.fasterxml.jackson.annotation.*; -import com.guicedee.guicedservlets.servlets.services.scopes.*; -import com.guicedee.services.jsonrepresentation.*; -import com.jwebmp.core.base.servlets.interfaces.*; -import com.jwebmp.core.htmlbuilder.javascript.*; -import jakarta.validation.constraints.*; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.guicedee.guicedservlets.servlets.services.scopes.CallScope; +import com.guicedee.services.jsonrepresentation.IJsonRepresentation; +import com.jwebmp.core.base.servlets.interfaces.IFeature; +import com.jwebmp.core.htmlbuilder.javascript.JavaScriptPart; import java.util.*; @@ -175,7 +176,7 @@ public J addFeature(IFeature feature) { * @param reaction */ @SuppressWarnings("unchecked") - @NotNull + public J addReaction(AjaxResponseReaction reaction) { getReactions().add(reaction); return (J) this; diff --git a/src/main/java/com/jwebmp/core/base/ajax/IAjaxCall.java b/src/main/java/com/jwebmp/core/base/ajax/IAjaxCall.java index fb55d1a..1c2641e 100644 --- a/src/main/java/com/jwebmp/core/base/ajax/IAjaxCall.java +++ b/src/main/java/com/jwebmp/core/base/ajax/IAjaxCall.java @@ -17,12 +17,12 @@ package com.jwebmp.core.base.ajax; -import com.guicedee.services.jsonrepresentation.*; -import com.jwebmp.core.base.interfaces.*; -import com.jwebmp.core.services.*; -import jakarta.validation.constraints.*; +import com.guicedee.services.jsonrepresentation.IJsonRepresentation; +import com.jwebmp.core.base.interfaces.IComponentHierarchyBase; +import com.jwebmp.core.services.IEventTypes; -import java.util.*; +import java.util.Date; +import java.util.Map; public interface IAjaxCall> extends IJsonRepresentation { @@ -99,7 +99,7 @@ public interface IAjaxCall> extends IJsonRepresentation * * @return */ - @NotNull + Map getParameters(); /** @@ -115,7 +115,7 @@ public interface IAjaxCall> extends IJsonRepresentation * * @return */ - @NotNull + String getClassName(); /** @@ -123,7 +123,7 @@ public interface IAjaxCall> extends IJsonRepresentation * * @param className */ - @NotNull + J setClassName(String className); } diff --git a/src/main/java/com/jwebmp/core/base/html/interfaces/InputChoiceType.java b/src/main/java/com/jwebmp/core/base/html/interfaces/InputChoiceType.java index 20e38bb..9db5bc1 100644 --- a/src/main/java/com/jwebmp/core/base/html/interfaces/InputChoiceType.java +++ b/src/main/java/com/jwebmp/core/base/html/interfaces/InputChoiceType.java @@ -17,7 +17,7 @@ package com.jwebmp.core.base.html.interfaces; -import jakarta.validation.constraints.*; + /** * An input type that designates a choice - checkbox/radio @@ -26,6 +26,6 @@ public interface InputChoiceType { @SuppressWarnings("unchecked") - @NotNull + J setChecked(boolean checked); } diff --git a/src/main/java/com/jwebmp/core/base/interfaces/IComponentBase.java b/src/main/java/com/jwebmp/core/base/interfaces/IComponentBase.java index ac12093..227977d 100644 --- a/src/main/java/com/jwebmp/core/base/interfaces/IComponentBase.java +++ b/src/main/java/com/jwebmp/core/base/interfaces/IComponentBase.java @@ -16,11 +16,10 @@ */ package com.jwebmp.core.base.interfaces; -import com.jwebmp.core.base.servlets.enumarations.*; -import jakarta.validation.constraints.*; +import com.jwebmp.core.base.servlets.enumarations.ComponentTypes; -import java.io.*; -import java.util.*; +import java.io.Serializable; +import java.util.Map; /** * Neater way of accessing the component methods @@ -192,5 +191,5 @@ default J appendText(String text) */ J setTouched(boolean touched); - @NotNull ComponentTypes getComponentType(); + ComponentTypes getComponentType(); } diff --git a/src/main/java/com/jwebmp/core/base/interfaces/IComponentFeatureBase.java b/src/main/java/com/jwebmp/core/base/interfaces/IComponentFeatureBase.java index 2d99b12..fa62de6 100644 --- a/src/main/java/com/jwebmp/core/base/interfaces/IComponentFeatureBase.java +++ b/src/main/java/com/jwebmp/core/base/interfaces/IComponentFeatureBase.java @@ -16,13 +16,14 @@ */ package com.jwebmp.core.base.interfaces; -import com.jwebmp.core.base.html.interfaces.*; -import com.jwebmp.core.base.references.*; -import com.jwebmp.core.base.servlets.enumarations.*; -import com.jwebmp.core.htmlbuilder.javascript.*; -import jakarta.validation.constraints.*; +import com.jwebmp.core.base.html.interfaces.GlobalFeatures; +import com.jwebmp.core.base.html.interfaces.LifeCycle; +import com.jwebmp.core.base.references.CSSReference; +import com.jwebmp.core.base.references.JavascriptReference; +import com.jwebmp.core.base.servlets.enumarations.RequirementsPriority; +import com.jwebmp.core.htmlbuilder.javascript.JavaScriptPart; -import java.util.*; +import java.util.Set; /** * @param @@ -149,7 +150,7 @@ public interface IComponentFeatureBase getFeatures(); /** diff --git a/src/main/java/com/jwebmp/core/base/interfaces/IComponentHTMLAttributeBase.java b/src/main/java/com/jwebmp/core/base/interfaces/IComponentHTMLAttributeBase.java index 18b7e9b..a72252d 100644 --- a/src/main/java/com/jwebmp/core/base/interfaces/IComponentHTMLAttributeBase.java +++ b/src/main/java/com/jwebmp/core/base/interfaces/IComponentHTMLAttributeBase.java @@ -18,7 +18,6 @@ import com.jwebmp.core.base.html.attributes.GlobalAttributes; import com.jwebmp.core.base.html.interfaces.AttributeDefinitions; -import jakarta.validation.constraints.NotNull; import java.util.Map; @@ -42,7 +41,7 @@ public interface IComponentHTMLAttributeBase & AttributeDefini J addAttribute(GlobalAttributes attribute, String value); @SuppressWarnings("unchecked") - J addAttribute(@NotNull GlobalAttributes attribute, @NotNull Object value); + J addAttribute( GlobalAttributes attribute, Object value); /** * Adds an attribute value to the attribute collection, and marks it with a GlobalAttribute Enumeration. diff --git a/src/main/java/com/jwebmp/core/base/interfaces/IComponentHTMLBase.java b/src/main/java/com/jwebmp/core/base/interfaces/IComponentHTMLBase.java index 002355c..661862c 100644 --- a/src/main/java/com/jwebmp/core/base/interfaces/IComponentHTMLBase.java +++ b/src/main/java/com/jwebmp/core/base/interfaces/IComponentHTMLBase.java @@ -16,8 +16,8 @@ */ package com.jwebmp.core.base.interfaces; -import com.jwebmp.core.base.servlets.enumarations.*; -import jakarta.validation.constraints.*; +import com.jwebmp.core.base.servlets.enumarations.ComponentTypes; + /** * @param This Type @@ -78,7 +78,7 @@ public interface IComponentHTMLBase> * * @return A string of the html tag */ - @NotNull + String toTinyString(); /** @@ -95,7 +95,7 @@ public interface IComponentHTMLBase> * @param newLineForRawText If there should be a new line for raw text * @return Always this object */ - @NotNull + J setNewLineForRawText(boolean newLineForRawText); /** diff --git a/src/main/java/com/jwebmp/core/base/interfaces/IComponentHierarchyBase.java b/src/main/java/com/jwebmp/core/base/interfaces/IComponentHierarchyBase.java index 37eda31..d701518 100644 --- a/src/main/java/com/jwebmp/core/base/interfaces/IComponentHierarchyBase.java +++ b/src/main/java/com/jwebmp/core/base/interfaces/IComponentHierarchyBase.java @@ -24,7 +24,6 @@ import com.jwebmp.core.htmlbuilder.css.themes.Theme; import com.jwebmp.core.htmlbuilder.javascript.events.interfaces.IEvent; import com.jwebmp.core.services.IPage; -import jakarta.validation.constraints.NotNull; import java.util.Map; import java.util.Set; @@ -47,8 +46,8 @@ public interface IComponentHierarchyBase> T wrap(@NotNull T component); + + > T wrap( T component); /** * Takes all children and embeds them into the current children hierarchy @@ -59,8 +58,8 @@ public interface IComponentHierarchyBase> T embed(@NotNull T component); + + > T embed( T component); /** * Add a new child to this component @@ -79,7 +78,7 @@ public interface IComponentHierarchyBase className, Enum... classNames); + J removeClass( Enum className, Enum... classNames); /** * Enumeration to remove @@ -294,7 +293,7 @@ public interface IComponentHierarchyBase className); + boolean removeClass( Enum className); /** * Sets the ID and adds the attribute to the global set @@ -359,7 +358,7 @@ public interface IComponentHierarchyBase> T findChild(@NotNull Class childType); + > T findChild( Class childType); /** * Returns a property of the first child in the current child chain diff --git a/src/main/java/com/jwebmp/core/base/interfaces/IComponentStyleBase.java b/src/main/java/com/jwebmp/core/base/interfaces/IComponentStyleBase.java index e48e95b..3c76d15 100644 --- a/src/main/java/com/jwebmp/core/base/interfaces/IComponentStyleBase.java +++ b/src/main/java/com/jwebmp/core/base/interfaces/IComponentStyleBase.java @@ -16,10 +16,9 @@ */ package com.jwebmp.core.base.interfaces; -import com.jwebmp.core.htmlbuilder.css.enumarations.*; -import jakarta.validation.constraints.*; +import com.jwebmp.core.htmlbuilder.css.enumarations.CSSTypes; -import java.util.*; +import java.util.Map; @SuppressWarnings("unused") /** @@ -110,6 +109,6 @@ public interface IComponentStyleBase> *

* @return The Component CSS */ - @NotNull + StringBuilder renderCss(int tabCount, boolean renderOpening, boolean renderInQuotations, boolean isAjaxCall); } diff --git a/src/main/java/com/jwebmp/core/base/references/JavascriptReference.java b/src/main/java/com/jwebmp/core/base/references/JavascriptReference.java index 72ab535..4bb57c5 100644 --- a/src/main/java/com/jwebmp/core/base/references/JavascriptReference.java +++ b/src/main/java/com/jwebmp/core/base/references/JavascriptReference.java @@ -16,9 +16,9 @@ */ package com.jwebmp.core.base.references; -import com.jwebmp.core.base.servlets.enumarations.*; -import com.jwebmp.core.generics.*; -import jakarta.validation.constraints.*; +import com.jwebmp.core.base.servlets.enumarations.RequirementsPriority; +import com.jwebmp.core.generics.WebReference; + /** * This class is a Java Reference @@ -160,7 +160,7 @@ public boolean isDefer() * If defer is enabled */ @SuppressWarnings("unchecked") - @NotNull + public JavascriptReference setDefer(boolean defer) { this.defer = defer; @@ -194,7 +194,7 @@ public boolean isAsync() * @return This */ @SuppressWarnings("unchecked") - @NotNull + public JavascriptReference setAsync(boolean async) { this.async = async; diff --git a/src/main/java/com/jwebmp/core/base/servlets/enumarations/DevelopmentEnvironments.java b/src/main/java/com/jwebmp/core/base/servlets/enumarations/DevelopmentEnvironments.java index 28038e0..7525ecb 100644 --- a/src/main/java/com/jwebmp/core/base/servlets/enumarations/DevelopmentEnvironments.java +++ b/src/main/java/com/jwebmp/core/base/servlets/enumarations/DevelopmentEnvironments.java @@ -16,9 +16,8 @@ */ package com.jwebmp.core.base.servlets.enumarations; -import jakarta.validation.constraints.*; -import java.util.*; +import java.util.Properties; /** * Configures the global generation type @@ -80,7 +79,7 @@ public enum DevelopmentEnvironments * * @return */ - @NotNull + public Properties getEnvironmentProperties() { if (environmentProperties == null) @@ -96,7 +95,7 @@ public Properties getEnvironmentProperties() * @param environmentProperties */ @SuppressWarnings("unused") - public void setEnvironmentProperties(@NotNull Properties environmentProperties) + public void setEnvironmentProperties( Properties environmentProperties) { this.environmentProperties = environmentProperties; } diff --git a/src/main/java/com/jwebmp/core/base/servlets/interfaces/IDataComponent.java b/src/main/java/com/jwebmp/core/base/servlets/interfaces/IDataComponent.java index 619918a..a191c7b 100644 --- a/src/main/java/com/jwebmp/core/base/servlets/interfaces/IDataComponent.java +++ b/src/main/java/com/jwebmp/core/base/servlets/interfaces/IDataComponent.java @@ -16,7 +16,6 @@ */ package com.jwebmp.core.base.servlets.interfaces; -import jakarta.validation.constraints.*; /** * Marks a component as one with Data that is available as either AJAX or direct @@ -30,5 +29,5 @@ public interface IDataComponent /** * Renders the physical data on call */ - @NotNull StringBuilder renderData(); + StringBuilder renderData(); } diff --git a/src/main/java/com/jwebmp/core/databind/ClientVariableWatcher.java b/src/main/java/com/jwebmp/core/databind/ClientVariableWatcher.java index 852b5da..7654112 100644 --- a/src/main/java/com/jwebmp/core/databind/ClientVariableWatcher.java +++ b/src/main/java/com/jwebmp/core/databind/ClientVariableWatcher.java @@ -1,7 +1,7 @@ package com.jwebmp.core.databind; import com.jwebmp.core.htmlbuilder.javascript.events.interfaces.IEvent; -import jakarta.validation.constraints.NotNull; + /** * A specification for notifications of client variable changes (on client data change) @@ -29,7 +29,7 @@ public abstract class ClientVariableWatcher * @param variableName of type String * @param eventClass of type Class ? extends ChangeAdapter */ - public ClientVariableWatcher(@NotNull String watchName, @NotNull String variableName, @NotNull Class> eventClass) + public ClientVariableWatcher( String watchName, String variableName, Class> eventClass) { this.watchName = watchName; this.variableName = variableName; @@ -55,7 +55,7 @@ public String getVariableName() * * @param variableName the variableName of this ClientVariableWatcher object. */ - public void setVariableName(@NotNull String variableName) + public void setVariableName( String variableName) { this.variableName = variableName; } @@ -79,7 +79,7 @@ public void setVariableName(@NotNull String variableName) * * @param eventClass the eventClass of this ClientVariableWatcher object. */ - public void setEventClass(@NotNull Class> eventClass) + public void setEventClass( Class> eventClass) { this.eventClass = eventClass; } @@ -114,7 +114,7 @@ public String getWatchName() * * @param watchName the watchName of this ClientVariableWatcher object. */ - public void setWatchName(@NotNull String watchName) + public void setWatchName( String watchName) { this.watchName = watchName; } diff --git a/src/main/java/com/jwebmp/core/databind/IClientVariableWatcher.java b/src/main/java/com/jwebmp/core/databind/IClientVariableWatcher.java index ef5167c..a89048e 100644 --- a/src/main/java/com/jwebmp/core/databind/IClientVariableWatcher.java +++ b/src/main/java/com/jwebmp/core/databind/IClientVariableWatcher.java @@ -1,7 +1,7 @@ package com.jwebmp.core.databind; import com.jwebmp.core.htmlbuilder.javascript.events.interfaces.IEvent; -import jakarta.validation.constraints.NotNull; + /** * SPI for handling variable watchers. The returned string must be JavaScript that will watch the given variable @@ -17,5 +17,5 @@ public interface IClientVariableWatcher * @param eventClass The event class * @return The java script to render */ - String onClientVariableRequest(@NotNull String watchName, @NotNull String variableName, @NotNull Class> eventClass); + String onClientVariableRequest( String watchName, String variableName, Class> eventClass); } diff --git a/src/main/java/com/jwebmp/core/databind/IOnDataBind.java b/src/main/java/com/jwebmp/core/databind/IOnDataBind.java index fd3fee0..dd1a787 100644 --- a/src/main/java/com/jwebmp/core/databind/IOnDataBind.java +++ b/src/main/java/com/jwebmp/core/databind/IOnDataBind.java @@ -2,7 +2,7 @@ import com.guicedee.guicedinjection.interfaces.IDefaultService; import com.jwebmp.core.base.interfaces.IComponentDataBindingBase; -import jakarta.validation.constraints.NotNull; + /** * SPI to do something when on bind is called @@ -16,5 +16,5 @@ public interface IOnDataBind> * @param component The component to bind * @param bindingValue The binding value to adhere to */ - void onBind(@NotNull IComponentDataBindingBase component, String bindingValue); + void onBind( IComponentDataBindingBase component, String bindingValue); } diff --git a/src/main/java/com/jwebmp/core/databind/IOnDataBindCloak.java b/src/main/java/com/jwebmp/core/databind/IOnDataBindCloak.java index 0b5c625..e69f62c 100644 --- a/src/main/java/com/jwebmp/core/databind/IOnDataBindCloak.java +++ b/src/main/java/com/jwebmp/core/databind/IOnDataBindCloak.java @@ -2,7 +2,7 @@ import com.guicedee.guicedinjection.interfaces.IDefaultService; import com.jwebmp.core.base.interfaces.IComponentDataBindingBase; -import jakarta.validation.constraints.NotNull; + /** * SPI to do something when on bind is called @@ -15,5 +15,5 @@ public interface IOnDataBindCloak extends IDefaultService * * @param component The component to bind */ - void onCloak(@NotNull IComponentDataBindingBase component); + void onCloak( IComponentDataBindingBase component); } diff --git a/src/main/java/com/jwebmp/core/exceptions/InvalidRequestException.java b/src/main/java/com/jwebmp/core/exceptions/InvalidRequestException.java new file mode 100644 index 0000000..881fd01 --- /dev/null +++ b/src/main/java/com/jwebmp/core/exceptions/InvalidRequestException.java @@ -0,0 +1,52 @@ +/* + * 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 new file mode 100644 index 0000000..e06957c --- /dev/null +++ b/src/main/java/com/jwebmp/core/exceptions/MissingComponentException.java @@ -0,0 +1,52 @@ +/* + * 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 new file mode 100644 index 0000000..b182e55 --- /dev/null +++ b/src/main/java/com/jwebmp/core/exceptions/NoServletFoundException.java @@ -0,0 +1,52 @@ +/* + * 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 new file mode 100644 index 0000000..ad197aa --- /dev/null +++ b/src/main/java/com/jwebmp/core/exceptions/NullComponentException.java @@ -0,0 +1,89 @@ +/* + * 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 new file mode 100644 index 0000000..0e5f4ef --- /dev/null +++ b/src/main/java/com/jwebmp/core/exceptions/UserSecurityException.java @@ -0,0 +1,52 @@ +/* + * 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/generics/FileTemplates.java b/src/main/java/com/jwebmp/core/generics/FileTemplates.java new file mode 100644 index 0000000..7dbbded --- /dev/null +++ b/src/main/java/com/jwebmp/core/generics/FileTemplates.java @@ -0,0 +1,285 @@ +/* + * 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.generics; + +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.format; + +/** + * 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/generics/WebReference.java b/src/main/java/com/jwebmp/core/generics/WebReference.java index 0d24694..1dda9cf 100644 --- a/src/main/java/com/jwebmp/core/generics/WebReference.java +++ b/src/main/java/com/jwebmp/core/generics/WebReference.java @@ -16,16 +16,16 @@ */ package com.jwebmp.core.generics; -import com.fasterxml.jackson.annotation.*; -import com.guicedee.services.jsonrepresentation.json.*; -import com.jwebmp.core.base.html.interfaces.*; -import com.jwebmp.core.base.servlets.enumarations.*; -import jakarta.validation.constraints.*; -import lombok.extern.java.*; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.guicedee.services.jsonrepresentation.json.StaticStrings; +import com.jwebmp.core.base.html.interfaces.NamedPair; +import com.jwebmp.core.base.servlets.enumarations.RequirementsPriority; +import lombok.extern.java.Log; -import java.io.*; +import java.io.Serializable; import java.util.*; -import java.util.logging.*; +import java.util.logging.Level; /** * Denotes a specific Web Reference, either remotely or locally @@ -203,7 +203,7 @@ public String getLeft() * @param left Left side, local reference * @return Always this */ - @NotNull + @SuppressWarnings("unchecked") public J setLeft(String left) { @@ -229,7 +229,7 @@ public String getRight() * @param right The remote reference * @return Always this */ - @NotNull + @SuppressWarnings("unchecked") public J setRight(String right) { @@ -254,7 +254,7 @@ public boolean isLeftOnly() * @param leftOnly if local only * @return always this */ - @NotNull + @SuppressWarnings("unchecked") public J setLeftOnly(boolean leftOnly) { @@ -278,7 +278,7 @@ public Double getVersion() * @param version the version of the reference * @return Always this */ - @NotNull + @SuppressWarnings("unchecked") public J setVersion(Double version) { @@ -334,7 +334,7 @@ public Integer getSortOrder() * @param sortOrder The sort order to apply * @return Always this */ - @NotNull + @SuppressWarnings("unchecked") public final J setSortOrder(Integer sortOrder) { @@ -436,7 +436,7 @@ public String getLocalReference() * @param localReference The local reference * @return Always this */ - @NotNull + @SuppressWarnings({"unchecked", "UnusedReturnValue"}) public J setLocalReference(String localReference) { @@ -490,7 +490,7 @@ public String getRemoteReference() * @param remoteReference The remote reference * @return Always this */ - @NotNull + @SuppressWarnings({"unchecked", "UnusedReturnValue"}) public J setRemoteReference(String remoteReference) { @@ -537,7 +537,7 @@ public static void setUseVersionIdentifier(boolean useVersionIdentifier) * @param canMinifyAtRemote If verifying on remote is allowed * @return Always this */ - @NotNull + @SuppressWarnings({"unchecked", "UnusedReturnValue"}) public J setCanMinifyAtRemote(boolean canMinifyAtRemote) { @@ -561,7 +561,7 @@ public RequirementsPriority getPriority() * @param priority The given priority to apply * @return Always this */ - @NotNull + @SuppressWarnings("unchecked") public J setPriority(RequirementsPriority priority) { @@ -585,7 +585,7 @@ public boolean isCordovaRequired() * @param cordovaRequired If cordova is requierd * @return Always this */ - @NotNull + @SuppressWarnings("unchecked") public J setCordovaRequired(boolean cordovaRequired) { @@ -609,7 +609,7 @@ public String getSpecifiedClassName() * @param specifiedClassName A class string to add */ @SuppressWarnings("unchecked") - @NotNull + public J setSpecifiedClassName(String specifiedClassName) { this.specifiedClassName = specifiedClassName; @@ -647,7 +647,7 @@ public String getName() * @param name The name of this reference * @return Always this */ - @NotNull + @SuppressWarnings("unchecked") public J setName(String name) { @@ -660,7 +660,7 @@ public J setName(String name) * * @return The set */ - @NotNull + public Set getAdditionalOptions() { if (additionalOptions == null) @@ -676,7 +676,7 @@ public Set getAdditionalOptions() * @param additionalOptions The options to add to the tag * @return The tag */ - @NotNull + public WebReference setAdditionalOptions(Set additionalOptions) { this.additionalOptions = additionalOptions; diff --git a/src/main/java/com/jwebmp/core/services/IPage.java b/src/main/java/com/jwebmp/core/services/IPage.java index ee8bfe5..bca0119 100644 --- a/src/main/java/com/jwebmp/core/services/IPage.java +++ b/src/main/java/com/jwebmp/core/services/IPage.java @@ -28,7 +28,7 @@ import com.jwebmp.core.base.interfaces.IComponentHierarchyBase; import com.jwebmp.core.base.interfaces.IComponentStyleBase; import com.jwebmp.core.base.servlets.enumarations.DevelopmentEnvironments; -import jakarta.validation.constraints.NotNull; + /** * Defines a page for use with IPage @@ -51,7 +51,7 @@ public interface IPage> extends IDefaultService, IComponen IComponentHTMLBase getDocumentType(); @SuppressWarnings("unused") - @NotNull + AjaxResponse onConnect(AjaxCall call, AjaxResponse response); /** diff --git a/src/main/java/com/jwebmp/core/services/IPageConfigurator.java b/src/main/java/com/jwebmp/core/services/IPageConfigurator.java index d3586a5..8abc0e8 100644 --- a/src/main/java/com/jwebmp/core/services/IPageConfigurator.java +++ b/src/main/java/com/jwebmp/core/services/IPageConfigurator.java @@ -1,7 +1,8 @@ package com.jwebmp.core.services; -import com.guicedee.guicedinjection.interfaces.*; -import jakarta.validation.constraints.*; +import com.guicedee.guicedinjection.interfaces.IDefaultService; +import com.guicedee.guicedinjection.interfaces.IServiceEnablement; + /** * A service for configuration built pages @@ -17,6 +18,6 @@ public interface IPageConfigurator> * * @return The original page incoming or a new page, never null */ - @NotNull + IPage configure(IPage page); } diff --git a/src/main/java/com/jwebmp/interception/services/AjaxCallIntercepter.java b/src/main/java/com/jwebmp/interception/services/AjaxCallIntercepter.java new file mode 100644 index 0000000..aeea1f0 --- /dev/null +++ b/src/main/java/com/jwebmp/interception/services/AjaxCallIntercepter.java @@ -0,0 +1,29 @@ +/* + * 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 new file mode 100644 index 0000000..b5e43e2 --- /dev/null +++ b/src/main/java/com/jwebmp/interception/services/DataCallIntercepter.java @@ -0,0 +1,30 @@ +/* + * 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/JWebMPInterceptionBinder.java b/src/main/java/com/jwebmp/interception/services/JWebMPInterceptionBinder.java new file mode 100644 index 0000000..14358ad --- /dev/null +++ b/src/main/java/com/jwebmp/interception/services/JWebMPInterceptionBinder.java @@ -0,0 +1,13 @@ +package com.jwebmp.interception.services; + +import com.google.inject.Key; +import com.google.inject.TypeLiteral; + +import java.util.Set; + +public interface JWebMPInterceptionBinder +{ + Key> AjaxCallInterceptorKey = Key.get(new TypeLiteral>() {}); + Key> DataCallInterceptorKey = Key.get(new TypeLiteral>() {}); + Key> SiteCallInterceptorKey = Key.get(new TypeLiteral>() {}); +} diff --git a/src/main/java/com/jwebmp/interception/services/ScriptProvider.java b/src/main/java/com/jwebmp/interception/services/ScriptProvider.java new file mode 100644 index 0000000..45a5afb --- /dev/null +++ b/src/main/java/com/jwebmp/interception/services/ScriptProvider.java @@ -0,0 +1,8 @@ +package com.jwebmp.interception.services; + +import com.jwebmp.core.base.interfaces.IComponentHierarchyBase; + +public interface ScriptProvider +{ + IComponentHierarchyBase produceScript(); +} diff --git a/src/main/java/com/jwebmp/interception/services/SiteCallIntercepter.java b/src/main/java/com/jwebmp/interception/services/SiteCallIntercepter.java new file mode 100644 index 0000000..2cdea84 --- /dev/null +++ b/src/main/java/com/jwebmp/interception/services/SiteCallIntercepter.java @@ -0,0 +1,33 @@ +/* + * 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/com/jwebmp/interception/services/StaticStrings.java b/src/main/java/com/jwebmp/interception/services/StaticStrings.java new file mode 100644 index 0000000..f2d4294 --- /dev/null +++ b/src/main/java/com/jwebmp/interception/services/StaticStrings.java @@ -0,0 +1,88 @@ +/* + * 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 java.io.Serializable; + +/** + * 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/module-info.java b/src/main/java/module-info.java index 7f9628a..fdea5bb 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -16,23 +16,25 @@ exports com.jwebmp.core.htmlbuilder.javascript.events.interfaces; exports com.jwebmp.core.services; + exports com.jwebmp.core.annotations; + exports com.jwebmp.core.events.services; exports com.jwebmp.core.databind; + exports com.jwebmp.interception.services; exports com.jwebmp.core.base.html.interfaces.children.generics; exports com.jwebmp.core.plugins; + exports com.jwebmp.core.exceptions; + requires transitive com.guicedee.client; - requires com.guicedee.jsonrepresentation; + requires transitive com.guicedee.jsonrepresentation; + requires org.apache.commons.io; requires static lombok; requires static org.apache.commons.lang3; - requires jakarta.servlet; - requires jakarta.websocket; - requires jakarta.websocket.client; - opens com.jwebmp.core.base.ajax to com.fasterxml.jackson.databind; opens com.jwebmp.core.base.client to com.fasterxml.jackson.databind; opens com.jwebmp.core.base.html.attributes to com.fasterxml.jackson.databind; diff --git a/src/test/java/com/jwebmp/BaseTestClass.java b/src/test/java/com/jwebmp/BaseTestClass.java index d8eda4b..0c7f34d 100644 --- a/src/test/java/com/jwebmp/BaseTestClass.java +++ b/src/test/java/com/jwebmp/BaseTestClass.java @@ -16,8 +16,6 @@ */ package com.jwebmp; -import com.jwebmp.testing.BaseTest; - /** * This Class * @@ -25,7 +23,6 @@ * @since 13 Jan 2016 */ public class BaseTestClass - extends BaseTest { public BaseTestClass() {