Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Linnea Samila
/
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 cb3e883a
authored
Sep 20, 2016
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'vipapi2' into 'master'
Silppufiksejä assyille ks. commit See merge request !337
2 parents
e466ff51
720c5169
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
130 additions
and
46 deletions
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/BotBeanLocal.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BotBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/VipBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/facade/SitePageFacade.java
code/moya-web/WebContent/vip/viplist.xhtml
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/VipRestView.java
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/pojo/VipRestPojo.java
code/moya-web/src/main/java/fi/codecrew/moya/servlet/IrcServlet.java
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/BotBeanLocal.java
View file @
cb3e883
...
@@ -4,6 +4,7 @@ import java.util.Set;
...
@@ -4,6 +4,7 @@ import java.util.Set;
import
javax.ejb.Local
;
import
javax.ejb.Local
;
import
fi.codecrew.moya.utilities.moyamessage.MoyaEventType
;
import
fi.iudex.utils.irc.IrcBot
;
import
fi.iudex.utils.irc.IrcBot
;
@Local
@Local
...
@@ -11,6 +12,6 @@ public interface BotBeanLocal {
...
@@ -11,6 +12,6 @@ public interface BotBeanLocal {
public
void
addBot
(
IrcBot
bot
);
public
void
addBot
(
IrcBot
bot
);
Set
<
String
>
getIgnoreTypes
();
Set
<
MoyaEventType
>
getIgnoreTypes
();
}
}
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BotBean.java
View file @
cb3e883
...
@@ -21,6 +21,7 @@ import fi.codecrew.moya.model.EventUser;
...
@@ -21,6 +21,7 @@ import fi.codecrew.moya.model.EventUser;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.LanEvent
;
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
;
import
fi.iudex.utils.irc.IrcBot
;
import
fi.iudex.utils.irc.IrcBot
;
/**
/**
...
@@ -47,7 +48,7 @@ public class BotBean implements BotBeanLocal {
...
@@ -47,7 +48,7 @@ public class BotBean implements BotBeanLocal {
private
UserFacade
userfacade
;
private
UserFacade
userfacade
;
@EJB
@EJB
private
EventUserFacade
eventuserfacade
;
private
EventUserFacade
eventuserfacade
;
private
final
Set
<
String
>
ignoreTypes
=
ConcurrentHashMap
.
newKeySet
();
private
final
Set
<
MoyaEventType
>
ignoreTypes
=
ConcurrentHashMap
.
newKeySet
();
public
void
message
(
Message
message
)
{
public
void
message
(
Message
message
)
{
...
@@ -90,7 +91,7 @@ public class BotBean implements BotBeanLocal {
...
@@ -90,7 +91,7 @@ public class BotBean implements BotBeanLocal {
}
}
@Override
@Override
public
Set
<
String
>
getIgnoreTypes
()
{
public
Set
<
MoyaEventType
>
getIgnoreTypes
()
{
return
ignoreTypes
;
return
ignoreTypes
;
}
}
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/VipBean.java
View file @
cb3e883
...
@@ -27,17 +27,13 @@ import fi.codecrew.moya.utilities.SearchResult;
...
@@ -27,17 +27,13 @@ import fi.codecrew.moya.utilities.SearchResult;
@Stateless
@Stateless
@LocalBean
@LocalBean
@DeclareRoles
({
@DeclareRoles
({
VipPermission
.
S_VIEW
,
VipPermission
.
S_USAGE
,
VipPermission
.
S_EDIT
})
VipPermission
.
S_VIEW
,
VipPermission
.
S_USAGE
,
VipPermission
.
S_EDIT
})
public
class
VipBean
implements
VipBeanLocal
{
public
class
VipBean
implements
VipBeanLocal
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
VipBean
.
class
);
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
VipBean
.
class
);
//@EJB
//
@EJB
//private PermissionBeanLocal permissionBean;
//
private PermissionBeanLocal permissionBean;
@EJB
@EJB
private
VipFacade
vipFacade
;
private
VipFacade
vipFacade
;
...
@@ -89,10 +85,10 @@ public class VipBean implements VipBeanLocal {
...
@@ -89,10 +85,10 @@ public class VipBean implements VipBeanLocal {
}
}
private
void
checkEvent
(
Vip
vip
)
{
private
void
checkEvent
(
Vip
vip
)
{
if
(!
eventbean
.
getCurrentEvent
().
equals
(
vip
.
getEvent
()))
{
if
(!
eventbean
.
getCurrentEvent
().
equals
(
vip
.
getEvent
()))
{
throw
new
EJBAccessException
(
"VIP entry from wrong event!"
);
throw
new
EJBAccessException
(
"VIP entry from wrong event!"
);
}
}
}
}
@Override
@Override
...
@@ -104,11 +100,11 @@ public class VipBean implements VipBeanLocal {
...
@@ -104,11 +100,11 @@ public class VipBean implements VipBeanLocal {
return
ret
;
return
ret
;
}
}
//
@Override
//
@Override
//
public SearchResult<Vip> search(SearchQuery sq) {
//
public SearchResult<Vip> search(SearchQuery sq) {
//
// TODO Auto-generated method stub
//
// TODO Auto-generated method stub
//
return null;
//
return null;
//
}
//
}
@Override
@Override
@RolesAllowed
({
VipPermission
.
S_EDIT
})
@RolesAllowed
({
VipPermission
.
S_EDIT
})
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/facade/SitePageFacade.java
View file @
cb3e883
...
@@ -134,7 +134,6 @@ public class SitePageFacade extends IntegerPkGenericFacade<SitePage> {
...
@@ -134,7 +134,6 @@ public class SitePageFacade extends IntegerPkGenericFacade<SitePage> {
public
List
<
PageContent
>
findContents
(
SitePage
page
,
Date
now
,
Locale
locale
)
{
public
List
<
PageContent
>
findContents
(
SitePage
page
,
Date
now
,
Locale
locale
)
{
logger
.
info
(
"Getting pageContents for locale {}"
,
locale
);
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
PageContent
>
cq
=
cb
.
createQuery
(
PageContent
.
class
);
CriteriaQuery
<
PageContent
>
cq
=
cb
.
createQuery
(
PageContent
.
class
);
...
@@ -160,7 +159,6 @@ public class SitePageFacade extends IntegerPkGenericFacade<SitePage> {
...
@@ -160,7 +159,6 @@ public class SitePageFacade extends IntegerPkGenericFacade<SitePage> {
// Show only if language equals or is null
// Show only if language equals or is null
Locale
contLocale
=
content
.
getLocaleObject
();
Locale
contLocale
=
content
.
getLocaleObject
();
if
(
contLocale
!=
null
&&
!
localeLang
.
equals
(
contLocale
.
getLanguage
()))
{
if
(
contLocale
!=
null
&&
!
localeLang
.
equals
(
contLocale
.
getLanguage
()))
{
logger
.
info
(
"Removing content with lang {} (comparing to {}) "
,
contLocale
,
locale
);
contIter
.
remove
();
contIter
.
remove
();
}
}
}
}
...
...
code/moya-web/WebContent/vip/viplist.xhtml
View file @
cb3e883
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
<br
/><br
/>
<br
/><br
/>
<p:dataTable
id=
"vipList"
value=
"#{vipListView.viplist}"
widgetVar=
"viplist"
styleClass=
"moya_datatable4"
var=
"vip"
>
<p:dataTable
paginator=
"true"
rows=
"100"
id=
"vipList"
value=
"#{vipListView.viplist}"
widgetVar=
"viplist"
styleClass=
"moya_datatable4"
var=
"vip"
>
<f:facet
name=
"header"
>
<f:facet
name=
"header"
>
<p:outputPanel>
<p:outputPanel>
...
@@ -29,8 +29,10 @@
...
@@ -29,8 +29,10 @@
<p:column
headerText=
"#{i18n['vip.hostsName']}"
filterBy=
"#{vip.host.wholeName}"
filterMatchMode=
"contains"
style=
"width: 140px;"
>
<p:column
headerText=
"#{i18n['vip.hostsName']}"
filterBy=
"#{vip.host.wholeName}"
filterMatchMode=
"contains"
style=
"width: 140px;"
>
<!-- p:column headerText="#{i18n['vip.hostsName']}" style="width: 140px;" -->
<!-- p:column headerText="#{i18n['vip.hostsName']}" style="width: 140px;" -->
<h:outputText
id=
"viphostsname"
value=
"#{vip.host.wholeName}"
/>
<h:link
outcome=
"/useradmin/edit"
value=
"#{vip.host.wholeName}"
>
<p:tooltip
id=
"viphostsnamephone"
for=
"viphostsname"
value=
"#{vip.host.phone}"
/>
<f:param
name=
"id"
value=
"#{vip.host.id}"
/>
</h:link>
<p:tooltip
id=
"viphostsnamephone"
for=
"viphostsname"
value=
"#{vip.host.phone}"
/>
</p:column>
</p:column>
<p:column
headerText=
"#{i18n['vip.description']}"
filterBy=
"#{vip.shortDisplayDescr}"
filterMatchMode=
"contains"
>
<p:column
headerText=
"#{i18n['vip.description']}"
filterBy=
"#{vip.shortDisplayDescr}"
filterMatchMode=
"contains"
>
...
...
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/VipRestView.java
View file @
cb3e883
package
fi
.
codecrew
.
moya
.
rest
.
v2
;
package
fi
.
codecrew
.
moya
.
rest
.
v2
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.enterprise.context.RequestScoped
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.DELETE
;
import
javax.ws.rs.FormParam
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.POST
;
import
javax.ws.rs.PUT
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.Produces
;
...
@@ -16,10 +22,16 @@ import javax.ws.rs.core.Response;
...
@@ -16,10 +22,16 @@ import javax.ws.rs.core.Response;
import
com.wordnik.swagger.annotations.Api
;
import
com.wordnik.swagger.annotations.Api
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.beans.ProductBeanLocal
;
import
fi.codecrew.moya.beans.ProductBeanLocal
;
import
fi.codecrew.moya.beans.UserBeanLocal
;
import
fi.codecrew.moya.beans.VipBeanLocal
;
import
fi.codecrew.moya.beans.VipBeanLocal
;
import
fi.codecrew.moya.model.AccountEvent
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.Vip
;
import
fi.codecrew.moya.model.Vip
;
import
fi.codecrew.moya.model.VipProduct
;
import
fi.codecrew.moya.rest.v2.pojo.ProductPojo
;
import
fi.codecrew.moya.rest.v2.pojo.ProductPojo
;
import
fi.codecrew.moya.rest.v2.pojo.VipProductPojo
;
import
fi.codecrew.moya.rest.v2.pojo.VipRestPojo
;
import
fi.codecrew.moya.rest.v2.pojo.VipRestPojo
;
import
fi.codecrew.moya.utilities.SearchQuery
;
import
fi.codecrew.moya.utilities.SearchQuery
;
import
fi.codecrew.moya.utilities.SearchResult
;
import
fi.codecrew.moya.utilities.SearchResult
;
...
@@ -34,6 +46,14 @@ public class VipRestView {
...
@@ -34,6 +46,14 @@ public class VipRestView {
@EJB
@EJB
private
VipBeanLocal
vipbean
;
private
VipBeanLocal
vipbean
;
@EJB
private
PermissionBeanLocal
permbean
;
@EJB
private
UserBeanLocal
userbean
;
@EJB
private
ProductBeanLocal
prodbean
;
@GET
@GET
@Path
(
"/all"
)
@Path
(
"/all"
)
public
Response
getAllVips
()
{
public
Response
getAllVips
()
{
...
@@ -52,4 +72,61 @@ public class VipRestView {
...
@@ -52,4 +72,61 @@ public class VipRestView {
return
Response
.
ok
(
ret
).
build
();
return
Response
.
ok
(
ret
).
build
();
}
}
@DELETE
@Path
(
"/{id}"
)
public
Response
deleteEntry
(
@PathParam
(
"id"
)
Integer
id
)
{
Vip
vip
=
vipbean
.
find
(
id
);
vipbean
.
delete
(
vip
);
return
Response
.
ok
(
VipRestPojo
.
create
(
vip
)).
build
();
}
@GET
@Path
(
"/{id}"
)
public
Response
findEntry
(
@PathParam
(
"id"
)
Integer
id
)
{
Vip
vip
=
vipbean
.
find
(
id
);
return
Response
.
ok
(
VipRestPojo
.
create
(
vip
)).
build
();
}
@POST
@Path
(
"/create"
)
@Produces
({
MediaType
.
APPLICATION_JSON
})
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
Response
createEntry
(
VipRestPojo
create
)
{
Vip
vip
=
new
Vip
();
EventUser
curruser
=
permbean
.
getCurrentUser
();
EventUser
eventuser
=
null
;
if
(
create
.
eventuserId
!=
null
)
{
eventuser
=
userbean
.
findByEventUserId
(
create
.
eventuserId
);
}
EventUser
host
=
curruser
;
if
(
create
.
hostId
!=
null
)
{
host
=
userbean
.
findByEventUserId
(
create
.
hostId
);
}
vip
.
setDescription
(
create
.
description
);
vip
.
setShortdescr
(
create
.
shortdescr
);
vip
.
setCreated
(
new
Date
());
vip
.
setEvent
(
curruser
.
getEvent
());
vip
.
setEventUser
(
eventuser
);
vip
.
setCreator
(
curruser
);
vip
.
setHost
(
host
);
for
(
VipProductPojo
p
:
create
.
products
)
{
VipProduct
prod
=
new
VipProduct
(
vip
);
vip
.
getProducts
().
add
(
prod
);
if
(
p
.
productId
!=
null
)
{
prod
.
setProduct
(
prodbean
.
findById
(
p
.
productId
));
}
else
{
prod
.
setName
(
p
.
name
);
}
prod
.
setQuantity
(
p
.
quantity
);
prod
.
setNotes
(
p
.
notes
);
}
vipbean
.
create
(
vip
);
return
Response
.
ok
(
VipRestPojo
.
create
(
vip
)).
build
();
}
}
}
code/moya-web/src/main/java/fi/codecrew/moya/rest/v2/pojo/VipRestPojo.java
View file @
cb3e883
...
@@ -12,7 +12,7 @@ import fi.codecrew.moya.model.Vip;
...
@@ -12,7 +12,7 @@ import fi.codecrew.moya.model.Vip;
import
fi.codecrew.moya.model.VipProduct
;
import
fi.codecrew.moya.model.VipProduct
;
@XmlRootElement
()
@XmlRootElement
()
@ApiModel
(
description
=
"
Product
"
)
@ApiModel
(
description
=
"
vip
"
)
public
class
VipRestPojo
{
public
class
VipRestPojo
{
public
Integer
id
;
public
Integer
id
;
...
@@ -27,27 +27,30 @@ public class VipRestPojo {
...
@@ -27,27 +27,30 @@ public class VipRestPojo {
public
static
ArrayList
<
VipRestPojo
>
create
(
List
<
Vip
>
vips
)
{
public
static
ArrayList
<
VipRestPojo
>
create
(
List
<
Vip
>
vips
)
{
ArrayList
<
VipRestPojo
>
ret
=
new
ArrayList
<>();
ArrayList
<
VipRestPojo
>
ret
=
new
ArrayList
<>();
for
(
Vip
v
:
vips
)
{
for
(
Vip
v
:
vips
)
{
VipRestPojo
r
=
new
VipRestPojo
();
ret
.
add
(
create
(
v
));
ret
.
add
(
r
);
r
.
id
=
v
.
getId
();
r
.
description
=
v
.
getDescription
();
r
.
shortdescr
=
v
.
getShortdescr
();
r
.
created
=
v
.
getCreated
();
if
(
v
.
getEventUser
()
!=
null
)
{
r
.
eventuserId
=
v
.
getEventUser
().
getId
();
}
if
(
v
.
getCreator
()
!=
null
)
{
r
.
creatorId
=
v
.
getCreator
().
getId
();
}
if
(
v
.
getHost
()
!=
null
)
{
r
.
hostId
=
v
.
getHost
().
getId
();
}
for
(
VipProduct
prod
:
v
.
getProducts
())
{
r
.
products
.
add
(
VipProductPojo
.
create
(
prod
));
}
}
}
return
ret
;
return
ret
;
}
}
public
static
VipRestPojo
create
(
Vip
v
)
{
VipRestPojo
r
=
new
VipRestPojo
();
r
.
id
=
v
.
getId
();
r
.
description
=
v
.
getDescription
();
r
.
shortdescr
=
v
.
getShortdescr
();
r
.
created
=
v
.
getCreated
();
if
(
v
.
getEventUser
()
!=
null
)
{
r
.
eventuserId
=
v
.
getEventUser
().
getId
();
}
if
(
v
.
getCreator
()
!=
null
)
{
r
.
creatorId
=
v
.
getCreator
().
getId
();
}
if
(
v
.
getHost
()
!=
null
)
{
r
.
hostId
=
v
.
getHost
().
getId
();
}
for
(
VipProduct
prod
:
v
.
getProducts
())
{
r
.
products
.
add
(
VipProductPojo
.
create
(
prod
));
}
return
r
;
}
}
}
code/moya-web/src/main/java/fi/codecrew/moya/servlet/IrcServlet.java
View file @
cb3e883
...
@@ -56,6 +56,7 @@ import fi.codecrew.moya.beans.EventBeanLocal;
...
@@ -56,6 +56,7 @@ 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.codecrew.moya.utilities.SystemProperty
;
import
fi.codecrew.moya.utilities.moyamessage.MoyaEventType
;
import
fi.iudex.utils.irc.IrcBot
;
import
fi.iudex.utils.irc.IrcBot
;
import
fi.iudex.utils.irc.IrcBotListener
;
import
fi.iudex.utils.irc.IrcBotListener
;
import
net.sf.jerklib.Profile
;
import
net.sf.jerklib.Profile
;
...
@@ -126,8 +127,13 @@ public class IrcServlet extends HttpServlet {
...
@@ -126,8 +127,13 @@ public class IrcServlet extends HttpServlet {
@Override
@Override
public
void
executeIrc
(
IrcBot
bot
,
String
data
)
{
public
void
executeIrc
(
IrcBot
bot
,
String
data
)
{
botbean
.
getIgnoreTypes
().
add
(
data
);
try
{
bot
.
say
(
"Added "
+
data
+
" as ignored message type"
);
MoyaEventType
d
=
MoyaEventType
.
valueOf
(
data
);
botbean
.
getIgnoreTypes
().
add
(
d
);
bot
.
say
(
"Added "
+
data
+
" as ignored message type"
);
}
catch
(
Exception
e
)
{
bot
.
say
(
"Unknown message type "
+
data
);
}
}
}
}
}
...
@@ -156,8 +162,8 @@ public class IrcServlet extends HttpServlet {
...
@@ -156,8 +162,8 @@ public class IrcServlet extends HttpServlet {
public
void
executeIrc
(
IrcBot
bot
,
String
data
)
{
public
void
executeIrc
(
IrcBot
bot
,
String
data
)
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"Ignored messagetypes: "
);
sb
.
append
(
"Ignored messagetypes: "
);
for
(
String
d
:
botbean
.
getIgnoreTypes
())
{
for
(
MoyaEventType
d
:
botbean
.
getIgnoreTypes
())
{
sb
.
append
(
d
).
append
(
", "
);
sb
.
append
(
d
.
name
()
).
append
(
", "
);
}
}
bot
.
say
(
sb
.
toString
());
bot
.
say
(
sb
.
toString
());
}
}
...
...
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