Skip to content

Commit 2b465f8

Browse files
committed
Making changes to support new footer
1 parent 45209db commit 2b465f8

18 files changed

Lines changed: 279 additions & 101 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package goc.webtemplate;
2+
3+
public class BannerLink {
4+
private String href;
5+
private String text;
6+
private boolean newWindow;
7+
8+
public BannerLink() {}
9+
10+
public BannerLink(String href)
11+
{
12+
this(href, "");
13+
}
14+
15+
public BannerLink(String href, String text)
16+
{
17+
this(href, text, false);
18+
}
19+
20+
public BannerLink(String href, String text, boolean newWindow)
21+
{
22+
this.href = href;
23+
this.text = text;
24+
this.newWindow = newWindow;
25+
}
26+
27+
public String getHref() {
28+
return href;
29+
}
30+
31+
public void setHref(String href) {
32+
this.href = href;
33+
}
34+
35+
public String getText() {
36+
return text;
37+
}
38+
39+
public void setText(String text) {
40+
this.text = text;
41+
}
42+
43+
public boolean isNewWindow() {
44+
return newWindow;
45+
}
46+
47+
public void setNewWindow(boolean newWindow) {
48+
this.newWindow = newWindow;
49+
}
50+
}

gocwebtemplate-core/gocwebtemplate-core-base/src/main/java/goc/webtemplate/ContextualFooter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
public class ContextualFooter {
66

77
private String title;
8-
private List<Link> links;
8+
private List<FooterLink> links;
99

1010
public ContextualFooter() {}
1111

12-
public ContextualFooter(String title, List<Link> links)
12+
public ContextualFooter(String title, List<FooterLink> links)
1313
{
1414
this.title = title;
1515
this.links = links;
@@ -23,11 +23,11 @@ public void setTitle(String title) {
2323
this.title = title;
2424
}
2525

26-
public List<Link> getLinks() {
26+
public List<FooterLink> getLinks() {
2727
return links;
2828
}
2929

30-
public void setLinks(List<Link> links) {
30+
public void setLinks(List<FooterLink> links) {
3131
this.links = links;
3232
}
3333
}

gocwebtemplate-core/gocwebtemplate-core-base/src/main/java/goc/webtemplate/InfoBanner.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
public class InfoBanner {
44
private String mainHTML;
5-
private Link link;
6-
private Link button;
5+
private BannerLink link;
6+
private BannerLink button;
77

88
public InfoBanner() {}
99

10-
public InfoBanner(String mainHTML, Link link, Link button)
10+
public InfoBanner(String mainHTML, BannerLink link, BannerLink button)
1111
{
1212
this.mainHTML = mainHTML;
1313
this.link = link;
@@ -22,19 +22,19 @@ public void setMainHTML(String mainHTML) {
2222
this.mainHTML = mainHTML;
2323
}
2424

25-
public Link getLink() {
25+
public BannerLink getLink() {
2626
return link;
2727
}
2828

29-
public void setLink(Link link) {
29+
public void setLink(BannerLink link) {
3030
this.link = link;
3131
}
3232

33-
public Link getButton() {
33+
public BannerLink getButton() {
3434
return button;
3535
}
3636

37-
public void setButton(Link button) {
37+
public void setButton(BannerLink button) {
3838
this.button = button;
3939
}
4040
}

gocwebtemplate-core/gocwebtemplate-core-base/src/main/java/goc/webtemplate/Link.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
public class Link implements Serializable, Cloneable {
77
private String href = "";
88
private String text = "";
9-
private boolean newWindow;
109

1110
public Link() {}
1211

@@ -16,15 +15,9 @@ public Link(String href)
1615
}
1716

1817
public Link(String href, String text)
19-
{
20-
this(href, text, false);
21-
}
22-
23-
public Link(String href, String text, boolean newWindow)
2418
{
2519
this.href = href;
2620
this.text = text;
27-
this.newWindow = newWindow;
2821
}
2922

3023
public void setHref(String href) { this.href = href; }
@@ -33,9 +26,6 @@ public Link(String href, String text, boolean newWindow)
3326
public void setText(String text) { this.text = text; }
3427
public String getText() { return this.text; }
3528

36-
public void setNewWindow(boolean value) { this.newWindow = value; }
37-
public boolean getNewWindow() {return this.newWindow; }
38-
3929
public Link clone() {
4030
try {
4131
return (Link)super.clone();

gocwebtemplate-core/gocwebtemplate-core-base/src/main/java/goc/webtemplate/component/AbstractCoreBean.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import goc.webtemplate.Utility;
3434
import goc.webtemplate.WebAnalyticsInfo;
3535

36+
import static goc.webtemplate.component.JsonRenderer.gson;
37+
3638
import goc.webtemplate.component.jsonentities.AppFooter;
3739
import goc.webtemplate.component.jsonentities.AppTop;
3840
import goc.webtemplate.component.jsonentities.CDTSEnvironment;
@@ -61,19 +63,6 @@
6163
*
6264
*/
6365
public abstract class AbstractCoreBean {
64-
/**
65-
* Object used for JSON serialization. (https://github.com/google/gson)
66-
*
67-
* According to documentation (http://www.javadoc.io/doc/com.google.code.gson/gson/2.8.0)
68-
* and source code, Gson objects are thread-safe.
69-
*/
70-
//NOTE: Doesn't render null values by default, which is what we want
71-
//NOTE: Escapes HTML by default, which is what we want (though URLs still need to be encoded)
72-
//NOTE: Indented output can be obtained by chaining a call to setPrettyPrinting()
73-
private static Gson gson = new com.google.gson.GsonBuilder()
74-
.setFieldNamingPolicy(com.google.gson.FieldNamingPolicy.IDENTITY)
75-
.create();
76-
7766
/**
7867
* Hold the table of CDTS environment configuration objects (loaded the first time it is accessed).
7968
*/
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package goc.webtemplate.component;
2+
3+
import com.google.gson.Gson;
4+
5+
public final class JsonRenderer {
6+
/**
7+
* Object used for JSON serialization. (https://github.com/google/gson)
8+
*
9+
* According to documentation (http://www.javadoc.io/doc/com.google.code.gson/gson/2.8.0)
10+
* and source code, Gson objects are thread-safe.
11+
*/
12+
//NOTE: Doesn't render null values by default, which is what we want
13+
//NOTE: Escapes HTML by default, which is what we want (though URLs still need to be encoded)
14+
//NOTE: Indented output can be obtained by chaining a call to setPrettyPrinting()
15+
public static Gson gson = new com.google.gson.GsonBuilder()
16+
.setFieldNamingPolicy(com.google.gson.FieldNamingPolicy.IDENTITY)
17+
.create();
18+
}

gocwebtemplate-core/gocwebtemplate-core-base/src/main/java/goc/webtemplate/component/JsonValueUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
import java.util.List;
66

77
import goc.webtemplate.FooterLink;
8-
import goc.webtemplate.FooterLinkContext;
98
import goc.webtemplate.Link;
109
import goc.webtemplate.Utility;
1110

11+
import goc.webtemplate.component.jsonentities.FooterLinkContext;
12+
1213
public final class JsonValueUtils {
1314

1415
/**

gocwebtemplate-core/gocwebtemplate-core-base/src/main/java/goc/webtemplate/component/jsonentities/Footer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import goc.webtemplate.ContextualFooter;
1010
import goc.webtemplate.FooterLink;
11-
import goc.webtemplate.FooterLinkContext;
1211
import goc.webtemplate.Link;
1312

1413
/**

gocwebtemplate-core/gocwebtemplate-core-base/src/main/java/goc/webtemplate/FooterLinkContext.java renamed to gocwebtemplate-core/gocwebtemplate-core-base/src/main/java/goc/webtemplate/component/jsonentities/FooterLinkContext.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
package goc.webtemplate;
1+
package goc.webtemplate.component.jsonentities;
2+
3+
import goc.webtemplate.FooterLink;
24

35
public class FooterLinkContext {
46

gocwebtemplate-core/gocwebtemplate-core-base/src/main/java/goc/webtemplate/component/jsonentities/adapters/FooterLinkAdapter.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import com.google.gson.stream.JsonReader;
66
import com.google.gson.stream.JsonWriter;
77

8-
import goc.webtemplate.FooterLinkContext;
8+
import static goc.webtemplate.component.JsonRenderer.gson;
9+
10+
import goc.webtemplate.component.jsonentities.FooterLinkContext;
911

1012
/**
1113
* GSON type adapter for serializing the "privacyLink" or "termsLink" parameter to the WET
@@ -23,18 +25,12 @@ public void write(JsonWriter jw, FooterLinkContext obj) throws IOException {
2325

2426
//If showFooter is false, render footer link as an array
2527
if (!obj.isShowFooter()) jw.beginArray();
26-
jw.beginObject();
27-
jw.name("href");
28-
jw.value(obj.getFooterLink().getHref());
29-
jw.name("newWindow");
30-
jw.value(obj.getFooterLink().getNewWindow());
31-
jw.endObject();
28+
gson.toJson(obj.getFooterLink(), obj.getFooterLink().getClass(), jw);
3229
if (!obj.isShowFooter()) jw.endArray();
3330
}
3431

3532
@Override
3633
public FooterLinkContext read(JsonReader jr) throws IOException {
3734
throw new UnsupportedOperationException("JSON deserialization not supported for type FooterLinkContext.");
3835
}
39-
40-
}
36+
}

0 commit comments

Comments
 (0)