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 c354f590
authored
Dec 09, 2014
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
2 parents
33ce6414
af3f4f0f
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
187 additions
and
61 deletions
code/moya-beans/ejbModule/fi/codecrew/moya/beans/JaasBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/moyamessage/IrcBotMoyaEventTopicListener.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/moyamessage/MoyaEventSender.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/moyamessage/MoyaEventTopicLoggingBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/facade/LanEventFacade.java
code/moya-beans/ejbModule/fi/codecrew/moya/facade/LogEntryTypeFacade.java
code/moya-parent/pom.xml
code/moya-utils/src/main/java/fi/codecrew/moya/utilities/SystemProperty.java
code/moya-utils/src/main/java/fi/codecrew/moya/utilities/moyamessage/MoyaEventMessage.java
code/moya-web/src/main/java/fi/codecrew/moya/servlet/IrcServlet.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/JaasBean.java
View file @
c354f59
...
@@ -139,6 +139,9 @@ public class JaasBean implements MoyaRealmBeanRemote {
...
@@ -139,6 +139,9 @@ public class JaasBean implements MoyaRealmBeanRemote {
eventUserFacade
.
flush
();
eventUserFacade
.
flush
();
eventUser
.
setCreator
(
eventUser
);
eventUser
.
setCreator
(
eventUser
);
}
}
// jos logitetaan anomuumi, niin uuden tapahtuman luominen hajoaa jännästi.
if
(!
user
.
isAnonymous
())
secubean
.
sendMessage
(
MoyaEventType
.
LOGIN_SUCCESSFULL
,
eventUser
,
"User logged in with username: '"
,
username
,
"' eventuser: "
,
eventUser
);
secubean
.
sendMessage
(
MoyaEventType
.
LOGIN_SUCCESSFULL
,
eventUser
,
"User logged in with username: '"
,
username
,
"' eventuser: "
,
eventUser
);
}
else
{
}
else
{
secubean
.
sendMessage
(
MoyaEventType
.
LOGIN_FAILED
,
eventUserFacade
.
findByLogin
(
User
.
ANONYMOUS_LOGINNAME
),
"Login failed: Username not found: "
,
username
);
secubean
.
sendMessage
(
MoyaEventType
.
LOGIN_FAILED
,
eventUserFacade
.
findByLogin
(
User
.
ANONYMOUS_LOGINNAME
),
"Login failed: Username not found: "
,
username
);
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/moyamessage/IrcBotMoyaEventTopicListener.java
View file @
c354f59
package
fi
.
codecrew
.
moya
.
beans
.
moyamessage
;
package
fi
.
codecrew
.
moya
.
beans
.
moyamessage
;
import
javax.ejb.ActivationConfigProperty
;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.ejb.MessageDriven
;
import
javax.ejb.MessageDriven
;
import
javax.jms.JMSException
;
import
javax.jms.JMSException
;
import
javax.jms.Message
;
import
javax.jms.Message
;
import
javax.jms.MessageListener
;
import
javax.jms.MessageListener
;
import
javax.jms.ObjectMessage
;
import
javax.jms.TextMessage
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.beans.BotBean
;
import
fi.codecrew.moya.beans.BotBean
;
import
fi.codecrew.moya.facade.EventFacade
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.utilities.moyamessage.MoyaEventMessage
;
import
fi.codecrew.moya.utilities.moyamessage.MoyaEventMessage
;
/**
/**
...
@@ -26,13 +25,22 @@ public class IrcBotMoyaEventTopicListener implements MessageListener {
...
@@ -26,13 +25,22 @@ public class IrcBotMoyaEventTopicListener implements MessageListener {
@EJB
@EJB
private
BotBean
botbean
;
private
BotBean
botbean
;
@EJB
private
EventFacade
eventfacade
;
/**
/**
* @see MessageListener#onMessage(Message)
* @see MessageListener#onMessage(Message)
*/
*/
public
void
onMessage
(
Message
message
)
{
public
void
onMessage
(
Message
message
)
{
try
{
try
{
MoyaEventMessage
msg
=
message
.
getBody
(
MoyaEventMessage
.
class
);
MoyaEventMessage
msg
=
message
.
getBody
(
MoyaEventMessage
.
class
);
botbean
.
getBot
().
say
(
toString
(
"Got Message "
,
msg
.
getEventtype
(),
" msg: "
,
msg
.
getDescription
()));
String
event
=
"unknown event"
;
if
(
msg
.
getEventId
()
!=
null
)
{
LanEvent
e
=
eventfacade
.
find
(
msg
.
getEventId
());
if
(
e
!=
null
)
event
=
e
.
getName
();
}
botbean
.
getBot
().
say
(
toString
(
event
,
" "
,
msg
.
getEventtype
(),
" msg: "
,
msg
.
getDescription
()));
logger
.
warn
(
"Received moya event message for irc bot {}"
,
message
);
logger
.
warn
(
"Received moya event message for irc bot {}"
,
message
);
}
catch
(
JMSException
e
)
{
}
catch
(
JMSException
e
)
{
logger
.
warn
(
"Exception while getting jms message for IRCbot"
);
logger
.
warn
(
"Exception while getting jms message for IRCbot"
);
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/moyamessage/MoyaEventSender.java
View file @
c354f59
...
@@ -63,7 +63,7 @@ public class MoyaEventSender implements LoggingBeanLocal {
...
@@ -63,7 +63,7 @@ public class MoyaEventSender implements LoggingBeanLocal {
MoyaEventMessage
msg
=
new
MoyaEventMessage
();
MoyaEventMessage
msg
=
new
MoyaEventMessage
();
msg
.
setEventtype
(
type
);
msg
.
setEventtype
(
type
);
msg
.
setTime
(
Calendar
.
getInstance
());
msg
.
setTime
(
Calendar
.
getInstance
());
msg
.
setUserId
(
user
.
getId
());
msg
.
set
Event
UserId
(
user
.
getId
());
msg
.
setCurrentUserId
(
permbean
.
getCurrentUser
().
getUser
().
getId
());
msg
.
setCurrentUserId
(
permbean
.
getCurrentUser
().
getUser
().
getId
());
msg
.
setEventId
(
eventbean
.
getCurrentEvent
().
getId
());
msg
.
setEventId
(
eventbean
.
getCurrentEvent
().
getId
());
msg
.
setDescription
(
message
);
msg
.
setDescription
(
message
);
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/moyamessage/MoyaEventTopicLoggingBean.java
View file @
c354f59
...
@@ -20,31 +20,26 @@ package fi.codecrew.moya.beans.moyamessage;
...
@@ -20,31 +20,26 @@ package fi.codecrew.moya.beans.moyamessage;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
javax.annotation.Resource
;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.ejb.MessageDriven
;
import
javax.ejb.MessageDriven
;
import
javax.ejb.Stateless
;
import
javax.ejb.TransactionManagement
;
import
javax.ejb.TransactionManagementType
;
import
javax.jms.JMSException
;
import
javax.jms.JMSException
;
import
javax.jms.Message
;
import
javax.jms.Message
;
import
javax.jms.MessageListener
;
import
javax.jms.MessageListener
;
import
javax.jms.ObjectMessage
;
import
javax.transaction.UserTransaction
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.facade.EventUserFacade
;
import
fi.codecrew.moya.facade.LanEventFacade
;
import
fi.codecrew.moya.facade.LogEntryFacade
;
import
fi.codecrew.moya.facade.LogEntryFacade
;
import
fi.codecrew.moya.facade.LogEntryTypeFacade
;
import
fi.codecrew.moya.facade.LogEntryTypeFacade
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.LoggingBeanLocal
;
import
fi.codecrew.moya.beans.SecurityLogType
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.LogEntry
;
import
fi.codecrew.moya.model.LogEntry
;
import
fi.codecrew.moya.model.LogEntryType
;
import
fi.codecrew.moya.model.LogEntryType
;
import
fi.codecrew.moya.model.User
;
import
fi.codecrew.moya.model.User
;
import
fi.codecrew.moya.utilities.moyamessage.MoyaEventMessage
;
import
fi.codecrew.moya.utilities.moyamessage.MoyaEventMessage
;
import
fi.codecrew.moya.utilities.moyamessage.MoyaEventType
;
/**
/**
* Session Bean implementation class SercurityBean
* Session Bean implementation class SercurityBean
...
@@ -55,13 +50,26 @@ public class MoyaEventTopicLoggingBean implements MessageListener {
...
@@ -55,13 +50,26 @@ public class MoyaEventTopicLoggingBean implements MessageListener {
private
static
final
boolean
DEBUG
=
true
;
private
static
final
boolean
DEBUG
=
true
;
private
final
Logger
logger
=
org
.
slf4j
.
LoggerFactory
.
getLogger
(
MoyaEventTopicLoggingBean
.
class
);
private
final
Logger
logger
=
org
.
slf4j
.
LoggerFactory
.
getLogger
(
MoyaEventTopicLoggingBean
.
class
);
@EJB
private
LanEventFacade
eventfacade
;
@Override
public
void
onMessage
(
Message
message
)
{
public
void
onMessage
(
Message
message
)
{
if
(
message
!=
null
)
{
if
(
message
!=
null
)
{
try
{
try
{
MoyaEventMessage
msg
=
message
.
getBody
(
MoyaEventMessage
.
class
);
MoyaEventMessage
msg
=
message
.
getBody
(
MoyaEventMessage
.
class
);
logger
.
warn
(
"Got message at TopicLogging {}, {}"
,
msg
.
getEventtype
(),
msg
.
getDescription
());
logger
.
warn
(
"Got message at TopicLogging {}, {}"
,
msg
.
getEventtype
(),
msg
.
getDescription
());
LanEvent
event
=
null
;
if
(
msg
.
getEventId
()
!=
null
)
event
=
eventfacade
.
find
(
msg
.
getEventId
());
User
user
=
null
;
if
(
msg
.
getEventUserId
()
!=
null
)
{
EventUser
euser
=
eventUserfacade
.
find
(
msg
.
getEventUserId
());
if
(
euser
!=
null
)
user
=
euser
.
getUser
();
}
logMessage
(
msg
.
getEventtype
(),
event
,
user
,
msg
.
getDescription
());
}
catch
(
JMSException
e
)
{
}
catch
(
JMSException
e
)
{
logger
.
warn
(
"Exception whie receiving Moya EventTopic"
,
e
);
logger
.
warn
(
"Exception whie receiving Moya EventTopic"
,
e
);
}
}
...
@@ -69,27 +77,34 @@ public class MoyaEventTopicLoggingBean implements MessageListener {
...
@@ -69,27 +77,34 @@ public class MoyaEventTopicLoggingBean implements MessageListener {
}
}
@EJB
@EJB
private
EventUserFacade
eventUserfacade
;
@EJB
private
EventBeanLocal
eventbean
;
private
EventBeanLocal
eventbean
;
public
LogEntry
logMessage
(
SecurityLogType
paramType
,
LanEvent
event
,
User
user
,
Object
...
description
)
{
@EJB
private
LogEntryFacade
entryFacade
;
@EJB
private
LogEntryTypeFacade
typeFacade
;
private
LogEntry
logMessage
(
MoyaEventType
moyaEventType
,
LanEvent
event
,
User
user
,
String
desc
)
{
LogEntry
entry
=
null
;
LogEntry
entry
=
null
;
if
(
event
==
null
)
{
if
(
event
==
null
)
{
event
=
eventbean
.
getCurrentEvent
();
event
=
eventbean
.
getCurrentEvent
();
}
}
try
{
try
{
String
desc
=
toString
(
description
);
logger
.
warn
(
"Sending logmsg {}"
,
desc
);
logger
.
warn
(
"Sending logmsg {}"
,
desc
);
//LogEntryType type = typeFacade.findOrCreate(param
Type);
LogEntryType
type
=
typeFacade
.
findOrCreate
(
moyaEvent
Type
);
//
entry = new LogEntry(Calendar.getInstance());
entry
=
new
LogEntry
(
Calendar
.
getInstance
());
//
entry.setParentEvent(event);
entry
.
setParentEvent
(
event
);
//
entry.setType(type);
entry
.
setType
(
type
);
//
entry.setDescription(desc);
entry
.
setDescription
(
desc
);
//
entry.setUser(user);
entry
.
setUser
(
user
);
//
entryFacade.create(entry);
entryFacade
.
create
(
entry
);
String
msg
=
"SECURITY DEBUG: Type: \""
+
param
Type
.
name
()
+
// String msg = "SECURITY DEBUG: Type: \"" + moyaEvent
Type.name() +
"\" user \""
+
param
Type
.
name
()
+
// "\" user \"" + moyaEvent
Type.name() +
"\", description \""
+
((
user
==
null
)
?
"null"
:
user
.
getLogin
())
+
"\""
+
desc
;
//
"\", description \"" + ((user == null) ? "null" : user.getLogin()) + "\"" + desc;
// sender.sendMessage(msg);
// sender.sendMessage(msg);
// utx.commit();
// utx.commit();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -98,23 +113,12 @@ public class MoyaEventTopicLoggingBean implements MessageListener {
...
@@ -98,23 +113,12 @@ public class MoyaEventTopicLoggingBean implements MessageListener {
return
entry
;
return
entry
;
}
}
public
LogEntry
logMessage
(
SecurityLogType
paramType
,
EventUser
user
,
Object
...
description
)
{
// private static final String toString(Object... desc) {
LanEvent
event
=
null
;
// StringBuilder msg = new StringBuilder();
User
usr
=
null
;
// for (Object msgpart : desc) {
if
(
user
!=
null
)
// msg.append(msgpart);
{
// }
event
=
user
.
getEvent
();
// return msg.toString();
usr
=
user
.
getUser
();
// }
}
return
logMessage
(
paramType
,
event
,
usr
,
description
);
}
private
static
final
String
toString
(
Object
...
desc
)
{
StringBuilder
msg
=
new
StringBuilder
();
for
(
Object
msgpart
:
desc
)
{
msg
.
append
(
msgpart
);
}
return
msg
.
toString
();
}
}
}
code/moya-beans/ejbModule/fi/codecrew/moya/facade/LanEventFacade.java
0 → 100644
View file @
c354f59
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package
fi
.
codecrew
.
moya
.
facade
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
javax.persistence.TypedQuery
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Path
;
import
javax.persistence.criteria.Root
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.LanEventDomain_
;
import
fi.codecrew.moya.model.LanEvent_
;
import
fi.codecrew.moya.model.LanEventDomain
;
@Stateless
@LocalBean
public
class
LanEventFacade
extends
IntegerPkGenericFacade
<
LanEvent
>
{
public
LanEventFacade
()
{
super
(
LanEvent
.
class
);
}
}
code/moya-beans/ejbModule/fi/codecrew/moya/facade/LogEntryTypeFacade.java
View file @
c354f59
...
@@ -24,6 +24,7 @@ import javax.persistence.TypedQuery;
...
@@ -24,6 +24,7 @@ import javax.persistence.TypedQuery;
import
fi.codecrew.moya.beans.SecurityLogType
;
import
fi.codecrew.moya.beans.SecurityLogType
;
import
fi.codecrew.moya.model.LogEntryType
;
import
fi.codecrew.moya.model.LogEntryType
;
import
fi.codecrew.moya.utilities.moyamessage.MoyaEventType
;
@Stateless
@Stateless
@LocalBean
@LocalBean
...
@@ -34,18 +35,18 @@ public class LogEntryTypeFacade extends IntegerPkGenericFacade<LogEntryType> {
...
@@ -34,18 +35,18 @@ public class LogEntryTypeFacade extends IntegerPkGenericFacade<LogEntryType> {
super
(
LogEntryType
.
class
);
super
(
LogEntryType
.
class
);
}
}
public
LogEntryType
findOrCreate
(
SecurityLogType
t
ype
)
{
public
LogEntryType
findOrCreate
(
MoyaEventType
moyaEventT
ype
)
{
// Fetch log entry type
// Fetch log entry type
TypedQuery
<
LogEntryType
>
q
=
getEm
().
createNamedQuery
(
"LogEntryType.findByName"
,
LogEntryType
.
class
);
TypedQuery
<
LogEntryType
>
q
=
getEm
().
createNamedQuery
(
"LogEntryType.findByName"
,
LogEntryType
.
class
);
q
.
setParameter
(
"name"
,
t
ype
.
name
());
q
.
setParameter
(
"name"
,
moyaEventT
ype
.
name
());
LogEntryType
logEntryType
=
getSingleNullableResult
(
q
);
LogEntryType
logEntryType
=
getSingleNullableResult
(
q
);
// Might not exist yet
// Might not exist yet
if
(
logEntryType
==
null
)
{
if
(
logEntryType
==
null
)
{
logEntryType
=
new
LogEntryType
();
logEntryType
=
new
LogEntryType
();
logEntryType
.
setName
(
t
ype
.
name
());
logEntryType
.
setName
(
moyaEventT
ype
.
name
());
getEm
().
persist
(
logEntryType
);
getEm
().
persist
(
logEntryType
);
}
}
...
...
code/moya-parent/pom.xml
View file @
c354f59
...
@@ -66,7 +66,7 @@
...
@@ -66,7 +66,7 @@
<dependency>
<dependency>
<groupId>
fi.iudex
</groupId>
<groupId>
fi.iudex
</groupId>
<artifactId>
utils-standalone
</artifactId>
<artifactId>
utils-standalone
</artifactId>
<version>
1.0.
9
</version>
<version>
1.0.
10
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
net.sf.barcode4j
</groupId>
<groupId>
net.sf.barcode4j
</groupId>
...
@@ -118,7 +118,7 @@
...
@@ -118,7 +118,7 @@
<dependency>
<dependency>
<groupId>
fi.iudex
</groupId>
<groupId>
fi.iudex
</groupId>
<artifactId>
jerklib
</artifactId>
<artifactId>
jerklib
</artifactId>
<version>
1.0.
1
</version>
<version>
1.0.
2
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
net.matlux
</groupId>
<groupId>
net.matlux
</groupId>
...
...
code/moya-utils/src/main/java/fi/codecrew/moya/utilities/SystemProperty.java
0 → 100644
View file @
c354f59
package
fi
.
codecrew
.
moya
.
utilities
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* Gather all system properties in here as enums, so we have some kind of
* understanding what kind of properties there are.
*
* @author tuomari
*
*/
public
enum
SystemProperty
{
MOYA_IRC_SERVER
,
MOYA_IRC_CHANNEL
(
"#moya-debug"
)
;
private
final
String
defaultValue
;
private
final
Integer
defaultIntegerValue
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SystemProperty
.
class
);
private
SystemProperty
()
{
defaultValue
=
null
;
defaultIntegerValue
=
null
;
}
private
SystemProperty
(
String
value
)
{
defaultValue
=
value
;
defaultIntegerValue
=
null
;
}
private
SystemProperty
(
Integer
value
)
{
defaultIntegerValue
=
value
;
defaultValue
=
null
;
}
public
String
getDefaultValue
()
{
return
defaultValue
;
}
public
String
getValueOrDefault
()
{
String
val
=
System
.
getProperty
(
this
.
name
());
if
(
val
==
null
)
{
val
=
defaultValue
;
}
return
val
;
}
public
Integer
getIntvalueOrDefault
()
{
String
val
=
System
.
getProperty
(
this
.
name
());
Integer
intval
=
null
;
try
{
intval
=
Integer
.
parseInt
(
val
);
}
catch
(
Throwable
t
)
{
intval
=
null
;
logger
.
warn
(
"Unable to parse system property '{}' value '{}' as integer. Defaulting to {}"
,
name
(),
val
,
defaultIntegerValue
);
}
if
(
val
==
null
)
{
intval
=
defaultIntegerValue
;
}
return
intval
;
}
}
code/moya-utils/src/main/java/fi/codecrew/moya/utilities/moyamessage/MoyaEventMessage.java
View file @
c354f59
...
@@ -11,7 +11,7 @@ public class MoyaEventMessage implements Serializable {
...
@@ -11,7 +11,7 @@ public class MoyaEventMessage implements Serializable {
private
Calendar
time
;
private
Calendar
time
;
private
MoyaEventType
eventtype
;
private
MoyaEventType
eventtype
;
private
String
description
;
private
String
description
;
private
Integer
u
serId
;
private
Integer
eventU
serId
;
private
Integer
eventId
;
private
Integer
eventId
;
private
Integer
currentUserId
;
private
Integer
currentUserId
;
...
@@ -27,8 +27,8 @@ public class MoyaEventMessage implements Serializable {
...
@@ -27,8 +27,8 @@ public class MoyaEventMessage implements Serializable {
this
.
description
=
description
;
this
.
description
=
description
;
}
}
public
void
set
UserId
(
Integer
u
serId
)
{
public
void
set
EventUserId
(
Integer
eventU
serId
)
{
this
.
userId
=
u
serId
;
this
.
eventUserId
=
eventU
serId
;
}
}
public
void
setEventId
(
Integer
eventId
)
{
public
void
setEventId
(
Integer
eventId
)
{
...
@@ -47,8 +47,8 @@ public class MoyaEventMessage implements Serializable {
...
@@ -47,8 +47,8 @@ public class MoyaEventMessage implements Serializable {
return
description
;
return
description
;
}
}
public
Integer
getUserId
()
{
public
Integer
get
Event
UserId
()
{
return
u
serId
;
return
eventU
serId
;
}
}
public
Integer
getEventId
()
{
public
Integer
getEventId
()
{
...
...
code/moya-web/src/main/java/fi/codecrew/moya/servlet/IrcServlet.java
View file @
c354f59
...
@@ -49,7 +49,6 @@ import javax.servlet.http.HttpServlet;
...
@@ -49,7 +49,6 @@ import javax.servlet.http.HttpServlet;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
fi.codecrew.moya.clientutils.BortalLocalContextHolder
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -57,6 +56,7 @@ import fi.codecrew.moya.beans.BotBeanLocal;
...
@@ -57,6 +56,7 @@ import fi.codecrew.moya.beans.BotBeanLocal;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.beans.PlaceBeanLocal
;
import
fi.codecrew.moya.beans.PlaceBeanLocal
;
import
fi.codecrew.moya.utilities.SystemProperty
;
import
fi.iudex.utils.irc.IrcBot
;
import
fi.iudex.utils.irc.IrcBot
;
import
fi.iudex.utils.irc.IrcBotListener
;
import
fi.iudex.utils.irc.IrcBotListener
;
...
@@ -94,14 +94,17 @@ public class IrcServlet extends HttpServlet {
...
@@ -94,14 +94,17 @@ public class IrcServlet extends HttpServlet {
*/
*/
public
void
init
(
ServletConfig
config
)
throws
ServletException
{
public
void
init
(
ServletConfig
config
)
throws
ServletException
{
// tuotannossa rakastan tätä, devauspuolella en.
String
ircserver
=
SystemProperty
.
MOYA_IRC_SERVER
.
getValueOrDefault
();
if
(!
BortalLocalContextHolder
.
isInDevelopmentMode
())
{
logger
.
info
(
"Got irc server system property {}"
,
ircserver
);
IrcBot
bot
=
new
IrcBot
(
"irc.cc.tut.fi"
,
"#moya-debug"
,
"moya-bot"
);
if
(
ircserver
!=
null
)
{
logger
.
info
(
"Starting IRC client with server {}"
,
ircserver
);
IrcBot
bot
=
new
IrcBot
(
ircserver
,
SystemProperty
.
MOYA_IRC_CHANNEL
.
getValueOrDefault
(),
"moya-bot"
);
botbean
.
add
(
bot
);
botbean
.
add
(
bot
);
bots
.
add
(
bot
);
bots
.
add
(
bot
);
bot
.
start
();
bot
.
start
();
}
}
}
}
/**
/**
...
...
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