Commit d2718a58 by Tuukka Kivilahti

Merge remote-tracking branch 'origin/master' into billExceptionFix

2 parents 2755e263 aca146b6
eclipse.preferences.version=1 eclipse.preferences.version=1
entitygen.DEFAULT_PACKAGE=model
org.eclipse.jpt.core.platform=eclipselink2_4 org.eclipse.jpt.core.platform=eclipselink2_4
org.eclipse.jpt.jpa.core.discoverAnnotatedClasses=true org.eclipse.jpt.jpa.core.discoverAnnotatedClasses=true
org.eclipse.jpt.jpa.core.metamodelSourceFolderName=target/generated-sources/annotations org.eclipse.jpt.jpa.core.metamodelSourceFolderName=target/generated-sources/annotations
...@@ -70,12 +70,13 @@ public class JsonUtils { ...@@ -70,12 +70,13 @@ public class JsonUtils {
* The value associate to the key * The value associate to the key
* @return JsonObject with the key:value pair added * @return JsonObject with the key:value pair added
*/ */
public static JsonObject assocJsonObject(JsonObject jsonObject, String key, JsonValue value) { public static JsonObject assocJsonObject(JsonObject jsonObject, String key,
JsonValue value) {
JsonObjectBuilder builder = Json.createObjectBuilder(); JsonObjectBuilder builder = Json.createObjectBuilder();
// Copy all non conflicting json entries // Copy all non conflicting json entries
for (Map.Entry<String, JsonValue> v : jsonObject.entrySet()) { for (Map.Entry<String, JsonValue> v : jsonObject.entrySet()) {
if (v.getKey().equals(key)) { if (v.getKey().equals(key) == false) {
builder = builder.add(v.getKey(), v.getValue()); builder = builder.add(v.getKey(), v.getValue());
} }
} }
...@@ -102,7 +103,7 @@ public class JsonUtils { ...@@ -102,7 +103,7 @@ public class JsonUtils {
// Recurse? // Recurse?
if (keys.size() > 1) { if (keys.size() > 1) {
String firstKey = keys.get(0); String firstKey = keys.get(0);
List<String> restKeys = keys.subList(0, keys.size()); List<String> restKeys = keys.subList(1, keys.size());
JsonObject subObj = jsonObject.getJsonObject(firstKey); JsonObject subObj = jsonObject.getJsonObject(firstKey);
return assocJsonObject(jsonObject, firstKey, return assocJsonObject(jsonObject, firstKey,
assocInJsonObject(subObj, restKeys, value)); assocInJsonObject(subObj, restKeys, value));
......
...@@ -50,7 +50,6 @@ public class JsonUtilsTest { ...@@ -50,7 +50,6 @@ public class JsonUtilsTest {
JsonValue expected = jsonObject("{\"quuz\":\"plop\"}"); JsonValue expected = jsonObject("{\"quuz\":\"plop\"}");
JsonValue actual = JsonUtils.getSubObject(meta, path); JsonValue actual = JsonUtils.getSubObject(meta, path);
Assert.assertEquals(expected.toString(), actual.toString()); Assert.assertEquals(expected.toString(), actual.toString());
} }
@Test @Test
...@@ -64,7 +63,21 @@ public class JsonUtilsTest { ...@@ -64,7 +63,21 @@ public class JsonUtilsTest {
JsonObject actual = JsonUtils.alterSubObject(meta, path, newData); JsonObject actual = JsonUtils.alterSubObject(meta, path, newData);
JsonObject expected = jsonObject("{\"foo\":\"bar\",\"baz\":{\"quux\":\"plop\"}}"); JsonObject expected = jsonObject("{\"foo\":\"bar\",\"baz\":{\"quux\":\"plop\"}}");
Assert.assertEquals(expected.toString(), actual.toString()); Assert.assertEquals(actual.toString(), expected.toString());
} }
@Test
public final void testAlterSubSubObject() {
JsonObject meta = jsonObject("{\"bystander1\":\"canary1\", \"module1\":{\"bystander2\":\"canary2\",\"submodule1\":{\"replacee1\":\"replacedvalue1\",\"r2\":\"rv2\"}}}");
JsonObject newData = jsonObject("{\"quux\":\"plop\"}");
ArrayList<String> path = new ArrayList<String>();
path.add("module1");
path.add("submodule1");
JsonObject actual = JsonUtils.alterSubObject(meta, path, newData);
JsonObject expected = jsonObject("{\"bystander1\":\"canary1\", \"module1\":{\"bystander2\":\"canary2\",\"submodule1\":{\"quux\":\"plop\"}}}");
Assert.assertEquals(actual.toString(), expected.toString());
}
} }
Manifest-Version: 1.0
Class-Path: lib/MoyaUtilities.jar
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
<p:tab id="basicinfo" title="#{i18n['foodwavetemplate.basicinfo']}"> --> <p:tab id="basicinfo" title="#{i18n['foodwavetemplate.basicinfo']}"> -->
<h:panelGrid columns="3"> <h:panelGrid columns="3">
<h:outputLabel for="name" value="#{i18n['foodwavetemplate.name']}" /> <h:outputLabel for="name" value="#{i18n['foodwavetemplate.name']}" />
<h:inputText id="name" value="#{foodWaveView.template.name}" <h:inputText id="name" value="#{foodWaveView.template.name}"
required="true" requiredMessage="Name required" /> required="true" requiredMessage="Name required" />
<h:message for="name" /> <h:message for="name" />
......
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
</p:panelGrid> </p:panelGrid>
</p:fieldset> </p:fieldset>
</h:form> </h:form>
<h:form> <h:form>
<p:fieldset legend="#{i18n['user.edit']}"> <p:fieldset legend="#{i18n['user.edit']}">
<p:panelGrid columns="3" styleClass="noBorders"> <p:panelGrid columns="3" styleClass="noBorders">
...@@ -154,6 +154,24 @@ ...@@ -154,6 +154,24 @@
<p:commandButton rendered="#{cc.attrs.creating or userView.canSave}" id="commitbtn" action="#{cc.attrs.commitaction}" ajax="false" value="#{cc.attrs.commitvalue}" onerror="location.reload(true);" /> <p:commandButton rendered="#{cc.attrs.creating or userView.canSave}" id="commitbtn" action="#{cc.attrs.commitaction}" ajax="false" value="#{cc.attrs.commitvalue}" onerror="location.reload(true);" />
</p:fieldset> </p:fieldset>
</h:form> </h:form>
<ui:fragment rendered="#{not empty userView.meta}">
<h:outputScript target="head" library="script" name="jsonview.js" />
<h:outputScript target="head">
window.onload = function() {
jsonView('#usermetaview');
}
</h:outputScript>
<h:form id="usermetaform" enctype="multipart/form-data">
<p:fieldset legend="#{i18n['user.meta.box.legend']}">
<p:panelGrid columns="1" cellpadding="1">
<div id="usermetaview">#{userView.meta}</div>
</p:panelGrid>
</p:fieldset>
</h:form>
</ui:fragment>
<h:form> <h:form>
<p:fieldset legend="#{i18n['user.userSelectableRoles']}" rendered="#{userView.showUserSelectableRoles and cc.attrs.showRoles}"> <p:fieldset legend="#{i18n['user.userSelectableRoles']}" rendered="#{userView.showUserSelectableRoles and cc.attrs.showRoles}">
<p:panelGrid columns="2" styleClass="noBorders"> <p:panelGrid columns="2" styleClass="noBorders">
......
/*
* ViewJSON
* Version 1.0
* A Google Chrome extension to display JSON in a user-friendly format
*
* This is a chromeified version of the JSONView Firefox extension by Ben Hollis:
* http://jsonview.com
* http://code.google.com/p/jsonview
*
* Also based on the XMLTree Chrome extension by Moonty & alan.stroop
* https://chrome.google.com/extensions/detail/gbammbheopgpmaagmckhpjbfgdfkpadb
*
* port by Jamie Wilkinson (@jamiew) | http://jamiedubs.com | http://github.com/jamiew
* MIT license / copyfree (f) F.A.T. Lab http://fffff.at
* Speed Project Approved: 2h
*/
function collapse(evt) {
var collapser = evt.target;
var target = collapser.parentNode.getElementsByClassName('collapsible');
if (!target.length) {
return;
}
target = target[0];
if (target.style.display == 'none') {
var ellipsis = target.parentNode.getElementsByClassName('ellipsis')[0];
target.parentNode.removeChild(ellipsis);
target.style.display = '';
} else {
target.style.display = 'none';
var ellipsis = document.createElement('span');
ellipsis.className = 'ellipsis';
ellipsis.innerHTML = ' &hellip; ';
target.parentNode.insertBefore(ellipsis, target);
}
collapser.innerHTML = (collapser.innerHTML == '-') ? '+' : '-';
}
function addCollapser(item) {
// This mainly filters out the root object (which shouldn't be collapsible)
if (item.nodeName != 'LI') {
return;
}
var collapser = document.createElement('div');
collapser.className = 'collapser';
collapser.innerHTML = '-';
collapser.addEventListener('click', collapse, false);
item.insertBefore(collapser, item.firstChild);
}
function jsonView(id) {
this.debug = false;
if (id.indexOf("#") != -1) {
this.idType = "id";
this.id = id.replace('#', '');
} else if (id.indexOf(".") != -1) {
this.idType = "class";
this.id = id.replace('.', '');
} else {
if (this.debug)
console.log("Can't find that element");
return;
}
this.data = document.getElementById(this.id).innerHTML;
// Note: now using "*.json*" URI matching rather than these page regexes -- save CPU cycles!
// var is_json = /^\s*(\{.*\})\s*$/.test(this.data);
// var is_jsonp = /^.*\(\s*(\{.*\})\s*\)$/.test(this.data);
// if(is_json || is_jsonp){
// Our manifest specifies that we only do URLs matching '.json', so attempt to sanitize any HTML
// added by Chrome's "text/plain" or "text/html" handlers
if (/^\<pre.*\>(.*)\<\/pre\>$/.test(this.data)) {
if (this.debug)
console.log("JSONView: data is wrapped in <pre>...</pre>, stripping HTML...");
this.data = this.data.replace(/<(?:.|\s)*?>/g, ''); //Aggressively strip HTML.
}
// Test if what remains is JSON or JSONp
var json_regex = /^\s*([\[\{].*[\}\]])\s*$/; // Ghetto, but it works
var jsonp_regex = /^[\s\u200B\uFEFF]*([\w$\[\]\.]+)[\s\u200B\uFEFF]*\([\s\u200B\uFEFF]*([\[{][\s\S]*[\]}])[\s\u200B\uFEFF]*\);?[\s\u200B\uFEFF]*$/;
var jsonp_regex2 = /([\[\{][\s\S]*[\]\}])\);/ // more liberal support... this allows us to pass the jsonp.json & jsonp2.json tests
var is_json = json_regex.test(this.data);
var is_jsonp = jsonp_regex.test(this.data);
if (this.debug)
console.log("JSONView: is_json=" + is_json + " is_jsonp=" + is_jsonp);
if (is_json || is_jsonp) {
if (this.debug)
console.log("JSONView: sexytime!");
// JSONFormatter json->HTML prototype straight from Firefox JSONView
// For reference: http://code.google.com/p/jsonview
function JSONFormatter() {
// No magic required.
}
JSONFormatter.prototype = {
htmlEncode: function(t) {
return t != null ? t.toString().replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;") : '';
},
decorateWithSpan: function(value, className) {
return '<span class="' + className + '">' + this.htmlEncode(value) + '</span>';
},
// Convert a basic JSON datatype (number, string, boolean, null, object, array) into an HTML fragment.
valueToHTML: function(value) {
var valueType = typeof value;
var output = "";
if (value == null) {
output += this.decorateWithSpan('null', 'null');
} else if (value && value.constructor == Array) {
output += this.arrayToHTML(value);
} else if (valueType == 'object') {
output += this.objectToHTML(value);
} else if (valueType == 'number') {
output += this.decorateWithSpan(value, 'num');
} else if (valueType == 'string') {
if (/^(http|https):\/\/[^\s]+$/.test(value)) {
output += '<a href="' + value + '">' + this.htmlEncode(value) + '</a>';
} else {
output += this.decorateWithSpan('"' + value + '"', 'string');
}
} else if (valueType == 'boolean') {
output += this.decorateWithSpan(value, 'bool');
}
return output;
},
// Convert an array into an HTML fragment
arrayToHTML: function(json) {
var output = '[<ul class="array collapsible">';
var hasContents = false;
for (var prop in json) {
hasContents = true;
output += '<li>';
output += this.valueToHTML(json[prop]);
output += '</li>';
}
output += '</ul>]';
if (!hasContents) {
output = "[ ]";
}
return output;
},
// Convert a JSON object to an HTML fragment
objectToHTML: function(json) {
var output = '{<ul class="obj collapsible">';
var hasContents = false;
for (var prop in json) {
hasContents = true;
output += '<li>';
output += '<span class="prop">' + this.htmlEncode(prop) + '</span>: ';
output += this.valueToHTML(json[prop]);
output += '</li>';
}
output += '</ul>}';
if (!hasContents) {
output = "{ }";
}
return output;
},
// Convert a whole JSON object into a formatted HTML document.
jsonToHTML: function(json, callback, uri) {
var output = '';
if (callback) {
output += '<div class="callback">' + callback + ' (</div>';
output += '<div id="json">';
} else {
output += '<div id="json">';
}
output += this.valueToHTML(json);
output += '</div>';
if (callback) {
output += '<div class="callback">)</div>';
}
return this.toHTML(output, uri);
},
// Produce an error document for when parsing fails.
errorPage: function(error, data, uri) {
// var output = '<div id="error">' + this.stringbundle.GetStringFromName('errorParsing') + '</div>';
// output += '<h1>' + this.stringbundle.GetStringFromName('docContents') + ':</h1>';
var output = '<div id="error">Error parsing JSON: ' + error.message + '</div>';
output += '<h1>' + error.stack + ':</h1>';
output += '<div id="json">' + this.htmlEncode(data) + '</div>';
return this.toHTML(output, uri + ' - Error');
},
// Wrap the HTML fragment in a full document. Used by jsonToHTML and errorPage.
toHTML: function(content, title) {
return content;
}
};
// Sanitize & output -- all magic from JSONView Firefox
this.jsonFormatter = new JSONFormatter();
// This regex attempts to match a JSONP structure:
// * Any amount of whitespace (including unicode nonbreaking spaces) between the start of the file and the callback name
// * Callback name (any valid JavaScript function name according to ECMA-262 Edition 3 spec)
// * Any amount of whitespace (including unicode nonbreaking spaces)
// * Open parentheses
// * Any amount of whitespace (including unicode nonbreaking spaces)
// * Either { or [, the only two valid characters to start a JSON string.
// * Any character, any number of times
// * Either } or ], the only two valid closing characters of a JSON string.
// * Any amount of whitespace (including unicode nonbreaking spaces)
// * A closing parenthesis, an optional semicolon, and any amount of whitespace (including unicode nonbreaking spaces) until the end of the file.
// This will miss anything that has comments, or more than one callback, or requires modification before use.
var outputDoc = '';
// text = text.match(jsonp_regex)[1];
var cleanData = '',
callback = '';
var callback_results = jsonp_regex.exec(this.data);
if (callback_results && callback_results.length == 3) {
if (this.debug)
console.log("THIS IS JSONp");
callback = callback_results[1];
cleanData = callback_results[2];
} else {
if (this.debug)
console.log("Vanilla JSON");
cleanData = this.data;
}
if (this.debug)
console.log(cleanData);
// Covert, and catch exceptions on failure
try {
// var jsonObj = this.nativeJSON.decode(cleanData);
var jsonObj = JSON.parse(cleanData);
if (jsonObj) {
outputDoc = this.jsonFormatter.jsonToHTML(jsonObj, callback);
} else {
throw "There was no object!";
}
} catch (e) {
if (this.debug)
console.log(e);
outputDoc = this.jsonFormatter.errorPage(e, this.data);
}
var links = '<style type="text/css">body{font-family:sans-serif;}.prop{font-weight:700;}.null{color:red;}.string{color:green;}.collapser{position:absolute;left:-1em;cursor:pointer;}li{position:relative;}li:after{content:\',\';}li:last-child:after{content:\'\';}#error{-moz-border-radius:8px;border:1px solid #970000;background-color:#F7E8E8;margin:.5em;padding:.5em;}.errormessage{font-family:monospace;}#json{font-family:monospace;font-size:1.1em;}ul{list-style:none;margin:0 0 0 2em;padding:0;}h1{font-size:1.2em;}.callback + #json{padding-left:1em;}.callback{font-family:monospace;color:#A52A2A;}.bool,.num{color:blue;}</style>';
if (this.idType == "class") {
document.getElementsByClassName(this.id).innerHTML = links + outputDoc;
} else if (this.idType == "id") {
document.getElementById(this.id).innerHTML = links + outputDoc;
}
var items = document.getElementsByClassName('collapsible');
for (var i = 0; i < items.length; i++) {
addCollapser(items[i].parentNode);
}
} else {
// console.log("JSONView: this is not json, not formatting.");
}
}
\ No newline at end of file
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<packaging>war</packaging> <packaging>war</packaging>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>
<version>2.4</version> <version>2.4</version>
...@@ -15,25 +16,15 @@ ...@@ -15,25 +16,15 @@
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
</build> </build>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>fi.codecrew.moya</groupId> <groupId>fi.codecrew.moya</groupId>
<artifactId>moya-beans-client</artifactId> <artifactId>moya-beans-client</artifactId>
<version>${moya.version}</version> <version>${moya.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.bull.javamelody</groupId> <groupId>net.bull.javamelody</groupId>
<artifactId>javamelody-core</artifactId> <artifactId>javamelody-core</artifactId>
<version>1.52.0</version> <version>1.52.0</version>
...@@ -43,17 +34,17 @@ ...@@ -43,17 +34,17 @@
<artifactId>primefaces</artifactId> <artifactId>primefaces</artifactId>
<version>5.1</version> <version>5.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.primefaces.extensions</groupId> <groupId>org.primefaces.extensions</groupId>
<artifactId>all-themes</artifactId> <artifactId>all-themes</artifactId>
<version>1.0.8</version> <version>1.0.8</version>
<type>pom</type> <type>pom</type>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.matlux</groupId> <groupId>net.matlux</groupId>
<artifactId>jvm-breakglass</artifactId> <artifactId>jvm-breakglass</artifactId>
<version>0.0.7</version> <version>0.0.7</version>
</dependency> </dependency>
</dependencies> </dependencies>
<parent> <parent>
<groupId>fi.codecrew.moya</groupId> <groupId>fi.codecrew.moya</groupId>
......
...@@ -20,6 +20,7 @@ package fi.codecrew.moya; ...@@ -20,6 +20,7 @@ package fi.codecrew.moya;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.security.Principal;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.faces.application.ProjectStage; import javax.faces.application.ProjectStage;
...@@ -35,6 +36,7 @@ import javax.servlet.http.HttpServletResponse; ...@@ -35,6 +36,7 @@ import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import fi.codecrew.moya.beans.RestBeanLocal; import fi.codecrew.moya.beans.RestBeanLocal;
import fi.codecrew.moya.beans.SessionMgmtBeanLocal; import fi.codecrew.moya.beans.SessionMgmtBeanLocal;
...@@ -88,6 +90,33 @@ public class HostnameFilter implements Filter { ...@@ -88,6 +90,33 @@ public class HostnameFilter implements Filter {
UNKNOWN, ANON, REST, USER UNKNOWN, ANON, REST, USER
} }
/**
* Add user information to SLF4J MDC context, so current user can be shown
* in logs.
*
* @param request
* @param authType
*/
void insertLoggingContext(HttpServletRequest request, AuthType authType) {
Principal userPrincipal = request.getUserPrincipal();
if (userPrincipal != null) {
String userString = userPrincipal.getName();
MDC.put("user", userString);
MDC.put("authtype", authType != null ? authType.name() : "null");
} else {
MDC.put("user", "null");
MDC.put("authtype", "null");
}
}
/**
* Remove user info from SLF4J MDC context.
*/
void removeLoggingContext() {
MDC.remove("user");
}
/** /**
* @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain) * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
*/ */
...@@ -131,6 +160,7 @@ public class HostnameFilter implements Filter { ...@@ -131,6 +160,7 @@ public class HostnameFilter implements Filter {
} }
// pass the request along the filter chain // pass the request along the filter chain
try { try {
insertLoggingContext((HttpServletRequest) request, authtype);
chain.doFilter(request, response); chain.doFilter(request, response);
} catch (Throwable t) { } catch (Throwable t) {
if (AuthType.REST == authtype) { if (AuthType.REST == authtype) {
...@@ -139,6 +169,7 @@ public class HostnameFilter implements Filter { ...@@ -139,6 +169,7 @@ public class HostnameFilter implements Filter {
throw t; throw t;
} finally { } finally {
BortalLocalContextHolder.cleanupThread(); BortalLocalContextHolder.cleanupThread();
removeLoggingContext();
} }
} }
...@@ -192,9 +223,9 @@ public class HostnameFilter implements Filter { ...@@ -192,9 +223,9 @@ public class HostnameFilter implements Filter {
protected void parseHostname(HttpServletRequest httpRequest) protected void parseHostname(HttpServletRequest httpRequest)
{ {
// logger.info("Path info {}", httpRequest.getPathInfo()); // null // logger.info("Path info {}", httpRequest.getPathInfo()); // null
// logger.info("querystring {}", httpRequest.getQueryString()); // ln=primefaces&amp;v=4.0 // logger.info("querystring {}", httpRequest.getQueryString()); // ln=primefaces&amp;v=4.0
// logger.info("ctxpath {}", httpRequest.getContextPath()); // /MoyaWeb // logger.info("ctxpath {}", httpRequest.getContextPath()); // /MoyaWeb
// logger.info("pathTranslated {}", httpRequest.getPathTranslated()); // null // logger.info("pathTranslated {}", httpRequest.getPathTranslated()); // null
// logger.info("requestUri {}", httpRequest.getRequestURI()); // /MoyaWeb/javax.faces.resource/jquery/jquery.js.jsf // logger.info("requestUri {}", httpRequest.getRequestURI()); // /MoyaWeb/javax.faces.resource/jquery/jquery.js.jsf
// logger.info("URL {}", httpRequest.getRequestURL().toString()); // http://localhost:8080/MoyaWeb/javax.faces.resource/jquery/jquery.js.jsf // logger.info("URL {}", httpRequest.getRequestURL().toString()); // http://localhost:8080/MoyaWeb/javax.faces.resource/jquery/jquery.js.jsf
......
...@@ -54,6 +54,9 @@ public class ReplServlet implements Servlet { ...@@ -54,6 +54,9 @@ public class ReplServlet implements Servlet {
public void destroy() { public void destroy() {
if (nreplServer != null) { if (nreplServer != null) {
nreplServer.stop(); nreplServer.stop();
nreplServer.unregisterMBean();
nreplServer.clear();
nreplServer = null;
} }
} }
} }
...@@ -31,7 +31,7 @@ import javax.faces.application.FacesMessage; ...@@ -31,7 +31,7 @@ import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.management.RuntimeErrorException; import javax.json.JsonObject;
import org.primefaces.event.CaptureEvent; import org.primefaces.event.CaptureEvent;
import org.primefaces.event.FileUploadEvent; import org.primefaces.event.FileUploadEvent;
...@@ -244,8 +244,8 @@ public class UserView extends GenericCDIView { ...@@ -244,8 +244,8 @@ public class UserView extends GenericCDIView {
try { try {
UserImage newImage = UserImage newImage =
userbean.saveCroppedImage(user.getUser().getCurrentImage(), userbean.saveCroppedImage(user.getUser().getCurrentImage(),
croppedImage.getLeft(), croppedImage.getTop(), croppedImage.getLeft(), croppedImage.getTop(),
croppedImage.getWidth(), croppedImage.getHeight()); croppedImage.getWidth(), croppedImage.getHeight());
user = userbean.getEventUser(newImage.getUser(), false); user = userbean.getEventUser(newImage.getUser(), false);
} catch (IOException e) { } catch (IOException e) {
...@@ -423,7 +423,7 @@ public class UserView extends GenericCDIView { ...@@ -423,7 +423,7 @@ public class UserView extends GenericCDIView {
event = readerbean.assocCodeToCard(event, card); event = readerbean.assocCodeToCard(event, card);
user = event.getUser(); user = event.getUser();
return null; return null;
} }
...@@ -444,7 +444,7 @@ public class UserView extends GenericCDIView { ...@@ -444,7 +444,7 @@ public class UserView extends GenericCDIView {
return "/useradmin/edit"; return "/useradmin/edit";
} }
// /admin/adduser/index // /admin/adduser/index
public String incomingPhotoReady() { public String incomingPhotoReady() {
authView.executeLogoutNoRedirect(); authView.executeLogoutNoRedirect();
...@@ -597,4 +597,25 @@ public class UserView extends GenericCDIView { ...@@ -597,4 +597,25 @@ public class UserView extends GenericCDIView {
return shirtEnabled; return shirtEnabled;
} }
/**
* Get metadata from the User (not EventUser). The data is shown in ui.
*
* @return
*/
public String getMeta() {
EventUser eventUser = getSelectedUser();
if (eventUser != null) {
User user = eventUser.getUser();
if (user != null) {
JsonObject meta = user.getMeta();
if (meta != null) {
if (meta.keySet().size() > 0) {
return meta.toString();
}
}
}
}
return "";
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!