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 97900ed7
authored
May 17, 2014
by
Antti Tönkyrä
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Frontend stuff
1 parent
cf7a4105
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
128 additions
and
2 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/NetworkAssociationBean.java
code/MoyaDatabase/src/fi/codecrew/moya/model/NetworkAssociation.java
code/MoyaWeb/WebContent/networkassociation/index.xhtml
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/networkassociation/NetworkAssociationView.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/NetworkAssociationBean.java
View file @
97900ed
...
@@ -181,6 +181,15 @@ public class NetworkAssociationBean implements NetworkAssociationBeanLocal {
...
@@ -181,6 +181,15 @@ public class NetworkAssociationBean implements NetworkAssociationBeanLocal {
activeAssoc
.
setStatus
(
NetworkAssociationStatus
.
EXPIRED
);
activeAssoc
.
setStatus
(
NetworkAssociationStatus
.
EXPIRED
);
}
}
}
else
{
}
else
{
// Disassociate any colliding IPs
activeAssocs
=
networkAssociationFacade
.
findActiveAssociationsByIP
(
eventBean
.
getCurrentEvent
(),
ip
);
for
(
NetworkAssociation
activeAssoc
:
activeAssocs
)
{
activeAssoc
.
setModifyTime
(
Calendar
.
getInstance
());
activeAssoc
.
setStatus
(
NetworkAssociationStatus
.
EXPIRED
);
}
// In here we disassociate old associations from this place unless the user has many
// In here we disassociate old associations from this place unless the user has many
// associations per place
// associations per place
if
(!
userPerms
.
contains
(
NetworkAssociationPermission
.
CAN_ASSOCIATE_MANY_PER_PLACE
))
{
if
(!
userPerms
.
contains
(
NetworkAssociationPermission
.
CAN_ASSOCIATE_MANY_PER_PLACE
))
{
...
...
code/MoyaDatabase/src/fi/codecrew/moya/model/NetworkAssociation.java
View file @
97900ed
...
@@ -68,6 +68,10 @@ public class NetworkAssociation extends GenericEntity {
...
@@ -68,6 +68,10 @@ public class NetworkAssociation extends GenericEntity {
public
String
getIP
()
{
public
String
getIP
()
{
return
ip
;
return
ip
;
}
}
public
String
getIp
()
{
return
ip
;
}
public
void
setIP
(
String
ip
)
{
public
void
setIP
(
String
ip
)
{
this
.
ip
=
ip
;
this
.
ip
=
ip
;
...
@@ -76,6 +80,10 @@ public class NetworkAssociation extends GenericEntity {
...
@@ -76,6 +80,10 @@ public class NetworkAssociation extends GenericEntity {
public
String
getMAC
()
{
public
String
getMAC
()
{
return
mac
;
return
mac
;
}
}
public
String
getMac
()
{
return
mac
;
}
public
void
setMAC
(
String
mac
)
{
public
void
setMAC
(
String
mac
)
{
this
.
mac
=
mac
;
this
.
mac
=
mac
;
...
...
code/MoyaWeb/WebContent/networkassociation/index.xhtml
View file @
97900ed
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:products=
"http://java.sun.com/jsf/composite/cditools/products"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:products=
"http://java.sun.com/jsf/composite/cditools/products"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:p=
"http://primefaces.org/ui"
>
>
<h:body>
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<ui:composition
template=
"#{sessionHandler.template}"
>
...
@@ -11,7 +11,52 @@
...
@@ -11,7 +11,52 @@
<f:event
type=
"preRenderView"
listener=
"#{networkAssociationView.initView}"
/>
<f:event
type=
"preRenderView"
listener=
"#{networkAssociationView.initView}"
/>
</f:metadata>
</f:metadata>
<ui:define
name=
"content"
>
<ui:define
name=
"content"
>
LRN
<h:form>
<p:messages
autoUpdate=
"true"
redisplay=
"false"
></p:messages>
<h1>
#{i18n['networkassociation.current_associations']}
</h1>
<p:dataTable
var=
"activeAssoc"
value=
"#{networkAssociationView.activeAssociations}"
>
<p:column
headerText=
"#{i18n['networkassociation.create_time']}"
>
<h:outputText
value=
"#{activeAssoc.createTime.time}"
>
<f:convertDateTime
pattern=
"#{sessionHandler.datetimeFormat}"
timeZone=
"#{sessionHandler.timezone}"
/>
</h:outputText>
</p:column>
<p:column
headerText=
"#{i18n['networkassociation.modify_time']}"
>
<h:outputText
value=
"#{activeAssoc.modifyTime.time}"
>
<f:convertDateTime
pattern=
"#{sessionHandler.datetimeFormat}"
timeZone=
"#{sessionHandler.timezone}"
/>
</h:outputText>
</p:column>
<p:column
headerText=
"#{i18n['networkassociation.create_time']}"
>
<h:outputText
value=
"#{activeAssoc.eventUser.user.nick}"
/>
</p:column>
<p:column
headerText=
"#{i18n['networkassociation.ip_address']}"
>
<h:outputText
value=
"#{activeAssoc.ip}"
/>
</p:column>
<p:column
headerText=
"#{i18n['networkassociation.mac_address']}"
>
<h:outputText
value=
"#{activeAssoc.mac}"
/>
</p:column>
<p:column
headerText=
"#{i18n['networkassociation.place']}"
>
<h:outputText
value=
"#{activeAssoc.place.name}"
/>
</p:column>
<p:column
headerText=
"#{i18n['networkassociation.action']}"
>
PRESSME
</p:column>
</p:dataTable>
<h:panelGrid
columns=
"3"
>
<h:outputText
value=
"#{i18n['networkassociation.ip_address']}"
/>
<h:outputText
value=
"#{i18n['networkassociation.mac_address']}"
/>
<h:outputText
value=
""
/>
<p:inputText
style=
"width: 100%;"
validator=
"#{networkAssociationView.validateIP}"
/>
<p:inputText
style=
"width: 100%;"
validator=
"#{networkAssociationView.validateMAC}"
/>
<p:commandButton
value=
"#{i18n['networkassociation.create_association']}"
action=
"#{networkAssociationView.createAssociation}"
/>
</h:panelGrid>
</h:form>
</ui:define>
</ui:define>
</ui:composition>
</ui:composition>
</h:body>
</h:body>
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/networkassociation/NetworkAssociationView.java
View file @
97900ed
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
networkassociation
;
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
networkassociation
;
import
java.net.InetAddress
;
import
java.util.List
;
import
java.util.regex.Pattern
;
import
javax.ejb.EJB
;
import
javax.faces.application.FacesMessage
;
import
javax.faces.component.UIComponent
;
import
javax.faces.context.FacesContext
;
import
javax.faces.validator.ValidatorException
;
import
javax.inject.Named
;
import
javax.inject.Named
;
import
javax.mail.internet.InternetAddress
;
import
fi.codecrew.moya.beans.NetworkAssociationBeanLocal
;
import
fi.codecrew.moya.model.NetworkAssociation
;
import
fi.codecrew.moya.utilities.jsf.MessageHelper
;
@Named
@Named
public
class
NetworkAssociationView
{
public
class
NetworkAssociationView
{
private
String
ipAddress
;
private
String
macAddress
;
@EJB
private
NetworkAssociationBeanLocal
networkAssociationBean
;
public
void
initView
()
{
}
public
String
createAssociation
()
{
return
""
;
}
public
void
validateIP
(
FacesContext
context
,
UIComponent
ui
,
Object
object
)
throws
Exception
{
String
addr
=
object
.
toString
().
trim
();
try
{
InetAddress
.
getByName
(
addr
);
}
catch
(
Exception
e
)
{
throw
new
ValidatorException
(
new
FacesMessage
(
FacesMessage
.
SEVERITY_ERROR
,
"networkassociation.invalid_ip_address"
,
""
));
}
}
public
void
validateMAC
(
FacesContext
context
,
UIComponent
ui
,
Object
object
)
{
String
addr
=
object
.
toString
().
trim
();
Pattern
p
=
Pattern
.
compile
(
"(?:[0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}"
);
if
(!
p
.
matcher
(
addr
).
find
())
{
throw
new
ValidatorException
(
new
FacesMessage
(
FacesMessage
.
SEVERITY_ERROR
,
"networkassociation.invalid_mac_address"
,
""
));
}
}
public
List
<
NetworkAssociation
>
getActiveAssociations
()
{
return
networkAssociationBean
.
getActiveAssociations
(
false
);
}
public
String
getIpAddress
()
{
return
ipAddress
;
}
public
void
setIpAddress
(
String
ipAddress
)
{
this
.
ipAddress
=
ipAddress
;
}
public
String
getMacAddress
()
{
return
macAddress
;
}
public
void
setMacAddress
(
String
macAddress
)
{
this
.
macAddress
=
macAddress
;
}
}
}
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