Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Riina Antikainen
/
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 e7c57c72
authored
Jan 29, 2015
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
blaah, moar stuff
1 parent
f5f56775
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
7 deletions
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BarcodeBean.java
code/moya-web/src/main/java/fi/codecrew/moya/web/TestDataView.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BarcodeBean.java
View file @
e7c57c7
...
...
@@ -144,7 +144,21 @@ public class BarcodeBean implements BarcodeBeanLocal {
}
/**
* TODO: change user code to be totally random, and to be saved into database
*
* This is nice, but this can be broken too easy
*
* @param user
* @param lenght
* @param bytecount
* @return
*/
private
String
getUserTextCode
(
EventUser
user
,
int
lenght
,
int
bytecount
)
{
return
getUserTextCode
(
user
,
lenght
,
bytecount
,
0
);
}
private
String
getUserTextCode
(
EventUser
user
,
int
lenght
,
int
bytecount
,
int
loopcount
)
{
int
barcodeLenght
=
12
;
...
...
@@ -156,10 +170,9 @@ public class BarcodeBean implements BarcodeBeanLocal {
// add some random -stuff to start of string
for
(
int
i
=
lenght
-
barcode
.
length
();
i
>
0
;
--
i
)
{
barcode
=
((
int
)
(
Math
.
random
()
*
10.0
))
+
barcode
;
barcode
=
((
int
)
(
(
Math
.
random
()
*
8.9
)
+
1
))
+
barcode
;
}
logger
.
debug
(
barcode
);
BigInteger
intCode
;
...
...
@@ -176,8 +189,12 @@ public class BarcodeBean implements BarcodeBeanLocal {
if
(
checkCode
.
compareTo
(
intCode
)
!=
0
)
{
logger
.
error
(
"CheckCode {} : Original {}"
,
checkCode
,
intCode
);
return
"GenError"
;
// different error messages, so we can tell where the error was
logger
.
error
(
"CheckCode {} : Original {}, text: {} "
,
checkCode
,
intCode
,
textCode
);
if
(
loopcount
>
10
)
return
"GenError"
;
// different error messages, so we can tell where the error was
return
getUserTextCode
(
user
,
lenght
,
bytecount
,
(
loopcount
+
1
));
}
// logger.debug("Geneating hexcode for place {} : {}", place.getId(), textCode);
...
...
@@ -444,7 +461,9 @@ public class BarcodeBean implements BarcodeBeanLocal {
BigInteger
numbersLeft
=
new
BigInteger
(
linearFeedbackShiftRegister
(
original
.
toByteArray
(),
bytecount
,
TEXTCODE_ROTATE_COUNT
));
// logger.debug("numbers afther random {}", numbersLeft);
String
converted
=
""
;
BigInteger
divnumber
=
BigInteger
.
valueOf
(
TEXTCODE_CHARACTER_MAP
.
length
());
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/TestDataView.java
View file @
e7c57c7
...
...
@@ -31,7 +31,10 @@ import javax.inject.Inject;
import
javax.inject.Named
;
import
fi.codecrew.moya.beans.*
;
import
fi.codecrew.moya.enums.apps.EventPermission
;
import
fi.codecrew.moya.enums.apps.UserPermission
;
import
fi.codecrew.moya.model.*
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
import
fi.codecrew.moya.web.cdiview.eticket.EticketView
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -42,7 +45,7 @@ import org.slf4j.LoggerFactory;
*/
@Named
(
"testView"
)
@RequestScoped
public
class
TestDataView
{
public
class
TestDataView
extends
GenericCDIView
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
TestDataView
.
class
);
...
...
@@ -86,7 +89,9 @@ public class TestDataView {
}
public
void
sendMultibuggageSpam
()
{
ticketBean
.
sendTicketEmailToAll
(
eticketView
.
getTicketUrl
());
if
(
super
.
requirePermissions
(
EventPermission
.
MANAGE_PRIVATE_PROPERTIES
))
{
ticketBean
.
sendTicketEmailToAll
(
eticketView
.
getTicketUrl
());
}
}
public
String
makeTestData
()
{
...
...
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