Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 734f9f72
authored
Aug 27, 2017
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Findbugs fixes. No functional changes
1 parent
1f03debb
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
28 additions
and
37 deletions
code/moya-beans/ejbModule/fi/codecrew/moya/beans/RestBean.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/PojoUtils.java
code/moya-web/src/main/java/fi/codecrew/moya/servlet/GenericImageServlet.java
code/moya-web/src/main/java/fi/codecrew/moya/web/ErrorPageView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/user/ImportView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/user/UserCartView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/flow/flowShopView.java → code/moya-web/src/main/java/fi/codecrew/moya/web/flow/FlowShopView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/helpers/ProductShopItem.java
code/moya-web/src/main/java/fi/codecrew/moya/web/helpers/UserOverviewItem.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/RestBean.java
View file @
734f9f7
...
...
@@ -23,6 +23,7 @@ import java.util.HashMap;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Random
;
import
java.util.concurrent.ConcurrentHashMap
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.Resource
;
...
...
@@ -92,25 +93,17 @@ public class RestBean implements RestBeanLocal {
}
// Username -> Nonce -> expiration
private
Map
<
String
,
Map
<
String
,
Long
>>
userRestAuths
=
Collections
.
synchronizedMap
(
new
HashMap
<
String
,
Map
<
String
,
Long
>>()
);
private
ConcurrentHashMap
<
String
,
ConcurrentHashMap
<
String
,
Long
>>
userRestAuths
=
new
ConcurrentHashMap
<>(
);
@Override
public
String
getLoggedinUserRestNonce
()
{
public
String
getLoggedinUserRestNonce
()
{
String
username
=
context
.
getCallerPrincipal
().
getName
();
if
(
username
==
null
)
{
return
null
;
}
Map
<
String
,
Long
>
userAuthMap
=
userRestAuths
.
get
(
username
);
ConcurrentHash
Map
<
String
,
Long
>
userAuthMap
=
userRestAuths
.
get
(
username
);
if
(
userAuthMap
==
null
)
{
synchronized
(
userRestAuths
)
{
if
(!
userRestAuths
.
containsKey
(
username
))
{
userAuthMap
=
Collections
.
synchronizedMap
(
new
HashMap
<
String
,
Long
>());
userRestAuths
.
put
(
username
,
userAuthMap
);
}
else
{
userRestAuths
.
get
(
username
);
}
}
userAuthMap
=
userRestAuths
.
putIfAbsent
(
username
,
new
ConcurrentHashMap
<>());
}
Random
random
=
new
Random
();
...
...
code/moya-web/src/main/java/fi/codecrew/moya/rest/PojoUtils.java
View file @
734f9f7
...
...
@@ -156,11 +156,11 @@ public class PojoUtils {
public
static
ReaderEventRestPojo
initReaderEventRestPojo
(
ReaderEvent
event
)
{
ReaderEventRestPojo
ret
=
new
ReaderEventRestPojo
();
if
(
event
!=
null
&&
event
.
getPrintedCard
()
!=
null
)
{
if
(
event
.
getPrintedCard
()
!=
null
)
{
if
(
event
.
getPrintedCard
().
getUser
()
!=
null
)
{
ret
.
setEventUser
(
PojoUtils
.
initEventUserRestPojo
(
event
.
getPrintedCard
().
getUser
()));
}
}
else
if
(
event
!=
null
&&
event
.
getUser
()
!=
null
)
{
}
else
if
(
event
.
getUser
()
!=
null
)
{
ret
.
setEventUser
(
PojoUtils
.
initEventUserRestPojo
(
event
.
getUser
()));
}
...
...
@@ -168,10 +168,10 @@ public class PojoUtils {
ret
.
setReaderEventTime
(
event
.
getUpdatetime
());
ret
.
setReaderId
(
event
.
getReader
().
getId
());
if
(
event
!=
null
&&
event
.
getPrintedCard
()
!=
null
)
{
if
(
event
.
getPrintedCard
()
!=
null
)
{
ret
.
setPrintedCardId
(
event
.
getPrintedCard
().
getId
());
}
if
(
event
!=
null
&&
event
.
getPrintedCard
()
!=
null
)
{
if
(
event
.
getPrintedCard
()
!=
null
)
{
ret
.
setPrintedCardState
(
event
.
getPrintedCard
().
getCardState
().
name
());
}
return
ret
;
...
...
code/moya-web/src/main/java/fi/codecrew/moya/servlet/GenericImageServlet.java
View file @
734f9f7
...
...
@@ -112,7 +112,7 @@ public abstract class GenericImageServlet extends HttpServlet {
}
else
{
response
.
setStatus
(
HttpServletResponse
.
SC_NOT_FOUND
);
}
response
.
getWriter
().
append
(
"Error "
+
data
.
getResponse
(
)
+
" while fetching data"
);
response
.
getWriter
().
append
(
"Error "
+
(
data
==
null
?
"null-data"
:
data
.
getResponse
()
)
+
" while fetching data"
);
}
else
{
response
.
setContentLength
(
data
.
getData
().
length
);
if
(
request
.
getParameter
(
"download"
)
!=
null
)
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/ErrorPageView.java
View file @
734f9f7
...
...
@@ -22,6 +22,7 @@ import java.io.PrintWriter;
import
java.io.Serializable
;
import
java.io.StringWriter
;
import
java.nio.ByteBuffer
;
import
java.nio.charset.Charset
;
import
java.util.Arrays
;
import
java.util.Base64
;
import
java.util.Map
;
...
...
@@ -81,7 +82,7 @@ public class ErrorPageView implements Serializable {
Map
<?,
?>
requestMap
=
context
.
getExternalContext
().
getRequestMap
();
Throwable
ex
=
(
Throwable
)
requestMap
.
get
(
"javax.servlet.error.exception"
);
CRC32
stackHash
=
new
CRC32
();
stackHash
.
update
(
Arrays
.
toString
(
ex
.
getStackTrace
()).
getBytes
());
stackHash
.
update
(
Arrays
.
toString
(
ex
.
getStackTrace
()).
getBytes
(
Charset
.
forName
(
"UTF-8"
)
));
return
"0x"
+
Long
.
toHexString
(
stackHash
.
getValue
());
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/user/ImportView.java
View file @
734f9f7
...
...
@@ -94,6 +94,10 @@ public class ImportView extends GenericCDIView {
}
}
if
(
bytes
==
null
)
{
return
null
;
}
String
content
=
new
String
(
bytes
,
UTF8
);
String
[]
splittedIds
=
content
.
split
(
";"
);
for
(
String
idstr
:
splittedIds
)
{
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/user/UserCartView.java
View file @
734f9f7
...
...
@@ -99,7 +99,7 @@ public class UserCartView extends GenericCDIView {
sb
.
append
(
"Added to event"
).
append
(
CSV_SEPARATOR
);
LanEvent
event
=
null
;
if
(
usercart
!=
null
&&
!
usercart
.
isEmpty
())
{
if
(!
usercart
.
isEmpty
())
{
event
=
usercart
.
get
(
0
).
getEvent
();
}
sb
.
append
(
"\n"
);
...
...
@@ -132,12 +132,12 @@ public class UserCartView extends GenericCDIView {
if
(
uc
.
getCreated
()
!=
null
)
{
ul
.
append
(
createtimeFormat
.
format
(
uc
.
getCreated
().
getTime
()));
}
ul
.
append
(
CSV_SEPARATOR
);
if
(
uc
.
getEventuserCreated
()
!=
null
)
{
ul
.
append
(
createtimeFormat
.
format
(
uc
.
getEventuserCreated
()));
}
ul
.
append
(
CSV_SEPARATOR
);
sb
.
append
(
ul
.
toString
()
...
...
@@ -146,9 +146,6 @@ public class UserCartView extends GenericCDIView {
.
replaceAll
(
" "
,
" "
)
);
sb
.
append
(
"\n"
);
}
DefaultStreamedContent
ret
=
new
DefaultStreamedContent
(
new
ByteArrayInputStream
(
sb
.
toString
().
getBytes
(
UTF8
)));
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/flow/
f
lowShopView.java
→
code/moya-web/src/main/java/fi/codecrew/moya/web/flow/
F
lowShopView.java
View file @
734f9f7
...
...
@@ -36,7 +36,7 @@ import javax.inject.Named;
@Named
@ConversationScoped
public
class
f
lowShopView
extends
GenericCDIView
{
public
class
F
lowShopView
extends
GenericCDIView
{
private
static
final
long
serialVersionUID
=
802344850073689859L
;
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/helpers/ProductShopItem.java
View file @
734f9f7
...
...
@@ -47,13 +47,9 @@ public class ProductShopItem implements Serializable {
private
Map
<
ProductOptionGroup
,
ProductOption
>
selectedOptions
=
new
HashMap
<>();
private
BigDecimal
overriddenUnitPrice
=
BigDecimal
.
ZERO
;
private
boolean
overrideUnitPrice
=
false
;
public
BigDecimal
getCreditPrice
()
{
if
(
BigDecimal
.
ZERO
.
compareTo
(
price
)
<
0
)
...
...
@@ -300,19 +296,19 @@ public class ProductShopItem implements Serializable {
public
String
getSelectedProductOptionString
()
{
String
retString
=
""
;
String
Builder
retString
=
new
StringBuilder
()
;
for
(
ProductOption
option
:
this
.
selectedOptions
.
values
())
{
if
(
option
==
null
)
continue
;
if
(
!
retString
.
isEmpty
()
)
{
retString
+=
", "
;
if
(
retString
.
length
()
==
0
)
{
retString
.
append
(
", "
)
;
}
retString
+=
option
.
getName
(
);
retString
.
append
(
option
.
getName
()
);
}
return
retString
;
return
retString
.
toString
()
;
}
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/helpers/UserOverviewItem.java
View file @
734f9f7
...
...
@@ -60,11 +60,11 @@ public class UserOverviewItem {
this
.
rejectionMsgBody
=
mailBody
;
else
this
.
rejectionMsgBody
=
""
;
if
(
this
.
rejectionMsgSubject
.
contains
(
"{0}"
)
&&
eventUser
!=
null
&&
eventUser
.
getEvent
()
!=
null
)
if
(
this
.
rejectionMsgSubject
.
contains
(
"{0}"
)
&&
eventUser
.
getEvent
()
!=
null
)
this
.
rejectionMsgSubject
=
this
.
rejectionMsgSubject
.
replace
(
"{0}"
,
eventUser
.
getEvent
().
getName
());
if
(
this
.
rejectionMsgBody
.
contains
(
"{0}"
)
&&
eventUser
!=
null
&&
eventUser
.
getEvent
()
!=
null
)
if
(
this
.
rejectionMsgBody
.
contains
(
"{0}"
)
&&
eventUser
.
getEvent
()
!=
null
)
this
.
rejectionMsgBody
=
this
.
rejectionMsgBody
.
replace
(
"{0}"
,
eventUser
.
getEvent
().
getName
());
this
.
rejectionMsgToAddr
=
eventUser
.
getEmail
();
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment