Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
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
Pipeline
#10
passed
in 0 seconds
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
25 additions
and
34 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;
...
@@ -23,6 +23,7 @@ import java.util.HashMap;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Map.Entry
;
import
java.util.Random
;
import
java.util.Random
;
import
java.util.concurrent.ConcurrentHashMap
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
@@ -92,25 +93,17 @@ public class RestBean implements RestBeanLocal {
...
@@ -92,25 +93,17 @@ public class RestBean implements RestBeanLocal {
}
}
// Username -> Nonce -> expiration
// 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
@Override
public
String
getLoggedinUserRestNonce
()
public
String
getLoggedinUserRestNonce
()
{
{
String
username
=
context
.
getCallerPrincipal
().
getName
();
String
username
=
context
.
getCallerPrincipal
().
getName
();
if
(
username
==
null
)
{
if
(
username
==
null
)
{
return
null
;
return
null
;
}
}
Map
<
String
,
Long
>
userAuthMap
=
userRestAuths
.
get
(
username
);
ConcurrentHash
Map
<
String
,
Long
>
userAuthMap
=
userRestAuths
.
get
(
username
);
if
(
userAuthMap
==
null
)
{
if
(
userAuthMap
==
null
)
{
synchronized
(
userRestAuths
)
{
userAuthMap
=
userRestAuths
.
putIfAbsent
(
username
,
new
ConcurrentHashMap
<>());
if
(!
userRestAuths
.
containsKey
(
username
))
{
userAuthMap
=
Collections
.
synchronizedMap
(
new
HashMap
<
String
,
Long
>());
userRestAuths
.
put
(
username
,
userAuthMap
);
}
else
{
userRestAuths
.
get
(
username
);
}
}
}
}
Random
random
=
new
Random
();
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 {
...
@@ -156,11 +156,11 @@ public class PojoUtils {
public
static
ReaderEventRestPojo
initReaderEventRestPojo
(
ReaderEvent
event
)
{
public
static
ReaderEventRestPojo
initReaderEventRestPojo
(
ReaderEvent
event
)
{
ReaderEventRestPojo
ret
=
new
ReaderEventRestPojo
();
ReaderEventRestPojo
ret
=
new
ReaderEventRestPojo
();
if
(
event
!=
null
&&
event
.
getPrintedCard
()
!=
null
)
{
if
(
event
.
getPrintedCard
()
!=
null
)
{
if
(
event
.
getPrintedCard
().
getUser
()
!=
null
)
{
if
(
event
.
getPrintedCard
().
getUser
()
!=
null
)
{
ret
.
setEventUser
(
PojoUtils
.
initEventUserRestPojo
(
event
.
getPrintedCard
().
getUser
()));
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
()));
ret
.
setEventUser
(
PojoUtils
.
initEventUserRestPojo
(
event
.
getUser
()));
}
}
...
@@ -168,10 +168,10 @@ public class PojoUtils {
...
@@ -168,10 +168,10 @@ public class PojoUtils {
ret
.
setReaderEventTime
(
event
.
getUpdatetime
());
ret
.
setReaderEventTime
(
event
.
getUpdatetime
());
ret
.
setReaderId
(
event
.
getReader
().
getId
());
ret
.
setReaderId
(
event
.
getReader
().
getId
());
if
(
event
!=
null
&&
event
.
getPrintedCard
()
!=
null
)
{
if
(
event
.
getPrintedCard
()
!=
null
)
{
ret
.
setPrintedCardId
(
event
.
getPrintedCard
().
getId
());
ret
.
setPrintedCardId
(
event
.
getPrintedCard
().
getId
());
}
}
if
(
event
!=
null
&&
event
.
getPrintedCard
()
!=
null
)
{
if
(
event
.
getPrintedCard
()
!=
null
)
{
ret
.
setPrintedCardState
(
event
.
getPrintedCard
().
getCardState
().
name
());
ret
.
setPrintedCardState
(
event
.
getPrintedCard
().
getCardState
().
name
());
}
}
return
ret
;
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 {
...
@@ -112,7 +112,7 @@ public abstract class GenericImageServlet extends HttpServlet {
}
else
{
}
else
{
response
.
setStatus
(
HttpServletResponse
.
SC_NOT_FOUND
);
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
{
}
else
{
response
.
setContentLength
(
data
.
getData
().
length
);
response
.
setContentLength
(
data
.
getData
().
length
);
if
(
request
.
getParameter
(
"download"
)
!=
null
)
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;
...
@@ -22,6 +22,7 @@ import java.io.PrintWriter;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.io.StringWriter
;
import
java.io.StringWriter
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
import
java.nio.charset.Charset
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Base64
;
import
java.util.Base64
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -81,7 +82,7 @@ public class ErrorPageView implements Serializable {
...
@@ -81,7 +82,7 @@ public class ErrorPageView implements Serializable {
Map
<?,
?>
requestMap
=
context
.
getExternalContext
().
getRequestMap
();
Map
<?,
?>
requestMap
=
context
.
getExternalContext
().
getRequestMap
();
Throwable
ex
=
(
Throwable
)
requestMap
.
get
(
"javax.servlet.error.exception"
);
Throwable
ex
=
(
Throwable
)
requestMap
.
get
(
"javax.servlet.error.exception"
);
CRC32
stackHash
=
new
CRC32
();
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
());
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 {
...
@@ -94,6 +94,10 @@ public class ImportView extends GenericCDIView {
}
}
}
}
if
(
bytes
==
null
)
{
return
null
;
}
String
content
=
new
String
(
bytes
,
UTF8
);
String
content
=
new
String
(
bytes
,
UTF8
);
String
[]
splittedIds
=
content
.
split
(
";"
);
String
[]
splittedIds
=
content
.
split
(
";"
);
for
(
String
idstr
:
splittedIds
)
{
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 {
...
@@ -99,7 +99,7 @@ public class UserCartView extends GenericCDIView {
sb
.
append
(
"Added to event"
).
append
(
CSV_SEPARATOR
);
sb
.
append
(
"Added to event"
).
append
(
CSV_SEPARATOR
);
LanEvent
event
=
null
;
LanEvent
event
=
null
;
if
(
usercart
!=
null
&&
!
usercart
.
isEmpty
())
{
if
(!
usercart
.
isEmpty
())
{
event
=
usercart
.
get
(
0
).
getEvent
();
event
=
usercart
.
get
(
0
).
getEvent
();
}
}
sb
.
append
(
"\n"
);
sb
.
append
(
"\n"
);
...
@@ -146,9 +146,6 @@ public class UserCartView extends GenericCDIView {
...
@@ -146,9 +146,6 @@ public class UserCartView extends GenericCDIView {
.
replaceAll
(
" "
,
" "
)
.
replaceAll
(
" "
,
" "
)
);
);
sb
.
append
(
"\n"
);
sb
.
append
(
"\n"
);
}
}
DefaultStreamedContent
ret
=
new
DefaultStreamedContent
(
new
ByteArrayInputStream
(
sb
.
toString
().
getBytes
(
UTF8
)));
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;
...
@@ -36,7 +36,7 @@ import javax.inject.Named;
@Named
@Named
@ConversationScoped
@ConversationScoped
public
class
f
lowShopView
extends
GenericCDIView
{
public
class
F
lowShopView
extends
GenericCDIView
{
private
static
final
long
serialVersionUID
=
802344850073689859L
;
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 {
...
@@ -47,13 +47,9 @@ public class ProductShopItem implements Serializable {
private
Map
<
ProductOptionGroup
,
ProductOption
>
selectedOptions
=
new
HashMap
<>();
private
Map
<
ProductOptionGroup
,
ProductOption
>
selectedOptions
=
new
HashMap
<>();
private
BigDecimal
overriddenUnitPrice
=
BigDecimal
.
ZERO
;
private
BigDecimal
overriddenUnitPrice
=
BigDecimal
.
ZERO
;
private
boolean
overrideUnitPrice
=
false
;
private
boolean
overrideUnitPrice
=
false
;
public
BigDecimal
getCreditPrice
()
public
BigDecimal
getCreditPrice
()
{
{
if
(
BigDecimal
.
ZERO
.
compareTo
(
price
)
<
0
)
if
(
BigDecimal
.
ZERO
.
compareTo
(
price
)
<
0
)
...
@@ -300,19 +296,19 @@ public class ProductShopItem implements Serializable {
...
@@ -300,19 +296,19 @@ public class ProductShopItem implements Serializable {
public
String
getSelectedProductOptionString
()
{
public
String
getSelectedProductOptionString
()
{
String
retString
=
""
;
String
Builder
retString
=
new
StringBuilder
()
;
for
(
ProductOption
option
:
this
.
selectedOptions
.
values
())
{
for
(
ProductOption
option
:
this
.
selectedOptions
.
values
())
{
if
(
option
==
null
)
if
(
option
==
null
)
continue
;
continue
;
if
(
!
retString
.
isEmpty
()
)
{
if
(
retString
.
length
()
==
0
)
{
retString
+=
", "
;
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
...
@@ -61,10 +61,10 @@ public class UserOverviewItem {
...
@@ -61,10 +61,10 @@ public class UserOverviewItem {
else
else
this
.
rejectionMsgBody
=
""
;
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
());
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
.
rejectionMsgBody
=
this
.
rejectionMsgBody
.
replace
(
"{0}"
,
eventUser
.
getEvent
().
getName
());
this
.
rejectionMsgToAddr
=
eventUser
.
getEmail
();
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