Skip to content

Commit

Permalink
PLUTO-763 Avoid the necessity of having a default serialVersionUID in…
Browse files Browse the repository at this point in the history
… the image selector portlet demos
  • Loading branch information
stiemannkj1 authored and ngriffin7a committed Mar 27, 2019
1 parent 5a7991b commit e13c1f8
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 26 deletions.
19 changes: 11 additions & 8 deletions PortletHubDemo/src/main/java/basic/portlet/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@

package basic.portlet;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class Constants {

// maps the names of the images to the paths to the images -
public final static Map<String, String> imgMap = new HashMap<String, String>() {
private static final long serialVersionUID = 1L;
{
put("baseball", "/resources/images/baseball-trans.gif");
put("golfball", "/resources/images/golfball-trans.gif");
put("fussball", "/resources/images/fussball-trans.gif");
}};
public final static Map<String, String> IMG_MAP;

static {
Map<String, String> imgMap = new HashMap<String, String>();
imgMap.put("baseball", "/resources/images/baseball-trans.gif");
imgMap.put("golfball", "/resources/images/golfball-trans.gif");
imgMap.put("fussball", "/resources/images/fussball-trans.gif");
IMG_MAP = Collections.unmodifiableMap(imgMap);
}

public final static String DEFAULT_IMAGE = "/resources/images/FullMoon.gif";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import static basic.portlet.Constants.PARAM_IMGNAME;
import static basic.portlet.Constants.PARAM_SELTYPE;
import static basic.portlet.Constants.PARAM_SELTYPE_RADIO;
import static basic.portlet.Constants.imgMap;

import java.io.IOException;
import java.io.PrintWriter;
Expand All @@ -42,6 +41,7 @@
import javax.portlet.annotations.Dependency;
import javax.portlet.annotations.LocaleString;
import javax.portlet.annotations.PortletConfiguration;
import static basic.portlet.Constants.IMG_MAP;


/**
Expand Down Expand Up @@ -81,7 +81,7 @@ public void serveResource(ResourceRequest req, ResourceResponse resp)
PrintWriter writer = resp.getWriter();

String pid = resp.getNamespace();
Set<String> names = imgMap.keySet();
Set<String> names = IMG_MAP.keySet();
String selType = req.getRenderParameters().getValue(PARAM_SELTYPE);
selType = (selType == null) ? PARAM_SELTYPE_RADIO : selType;
String imgName = req.getRenderParameters().getValue(PARAM_IMGNAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import static basic.portlet.Constants.PARAM_BORDER_COLOR;
import static basic.portlet.Constants.PARAM_COLOR;
import static basic.portlet.Constants.PARAM_IMGNAME;
import static basic.portlet.Constants.imgMap;
import static basic.portlet.Constants.DEFAULT_IMAGE;

import java.io.IOException;
Expand All @@ -48,6 +47,7 @@
import javax.portlet.annotations.PortletQName;
import javax.portlet.annotations.PublicRenderParameterDefinition;
import javax.portlet.annotations.Supports;
import static basic.portlet.Constants.IMG_MAP;


/**
Expand Down Expand Up @@ -111,8 +111,8 @@ public void serveResource(ResourceRequest req, ResourceResponse resp)

String key = req.getRenderParameters().getValue(PARAM_IMGNAME);
String imgDir = DEFAULT_IMAGE;
if ((key != null) && imgMap.containsKey(key)) {
imgDir = imgMap.get(key);
if ((key != null) && IMG_MAP.containsKey(key)) {
imgDir = IMG_MAP.get(key);
}

String bc = req.getResourceParameters().getValue(PARAM_BORDER_COLOR);
Expand Down
19 changes: 11 additions & 8 deletions PortletV3Demo/src/main/java/basic/portlet/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@

package basic.portlet;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class Constants {

// maps the names of the images to the paths to the images -
public final static Map<String, String> imgMap = new HashMap<String, String>() {
private static final long serialVersionUID = 1L;
{
put("baseball", "/resources/images/baseball-trans.gif");
put("golfball", "/resources/images/golfball-trans.gif");
put("fussball", "/resources/images/fussball-trans.gif");
}};
public final static Map<String, String> IMG_MAP;

static {
Map<String, String> imgMap = new HashMap<String, String>();
imgMap.put("baseball", "/resources/images/baseball-trans.gif");
imgMap.put("golfball", "/resources/images/golfball-trans.gif");
imgMap.put("fussball", "/resources/images/fussball-trans.gif");
IMG_MAP = Collections.unmodifiableMap(imgMap);
}

public final static String DEFAULT_IMAGE = "/resources/images/FullMoon.gif";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import static basic.portlet.Constants.PARAM_IMGNAME;
import static basic.portlet.Constants.PARAM_SELTYPE;
import static basic.portlet.Constants.PARAM_SELTYPE_RADIO;
import static basic.portlet.Constants.imgMap;

import java.io.IOException;
import java.io.PrintWriter;
Expand All @@ -39,6 +38,7 @@
import javax.portlet.RenderResponse;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import static basic.portlet.Constants.IMG_MAP;


/**
Expand Down Expand Up @@ -76,7 +76,7 @@ public void serveResource(ResourceRequest req, ResourceResponse resp)
PrintWriter writer = resp.getWriter();

String pid = resp.getNamespace();
Set<String> names = imgMap.keySet();
Set<String> names = IMG_MAP.keySet();
String selType = req.getParameter(PARAM_SELTYPE);
selType = (selType == null) ? PARAM_SELTYPE_RADIO : selType;
String imgName = req.getParameter(PARAM_IMGNAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import static basic.portlet.Constants.PARAM_BORDER_COLOR;
import static basic.portlet.Constants.PARAM_COLOR;
import static basic.portlet.Constants.PARAM_IMGNAME;
import static basic.portlet.Constants.imgMap;
import static basic.portlet.Constants.DEFAULT_IMAGE;

import java.io.IOException;
Expand All @@ -40,6 +39,7 @@
import javax.portlet.RenderResponse;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import static basic.portlet.Constants.IMG_MAP;


/**
Expand Down Expand Up @@ -77,8 +77,8 @@ public void serveResource(ResourceRequest req, ResourceResponse resp)

String key = req.getParameter(PARAM_IMGNAME);
String imgDir = DEFAULT_IMAGE;
if ((key != null) && imgMap.containsKey(key)) {
imgDir = imgMap.get(key);
if ((key != null) && IMG_MAP.containsKey(key)) {
imgDir = IMG_MAP.get(key);
}

String bc = req.getParameter(PARAM_BORDER_COLOR);
Expand Down

0 comments on commit e13c1f8

Please sign in to comment.