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 c555a872
authored
May 09, 2010
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Role stuff.
1 parent
dbbc24c7
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
37 additions
and
17 deletions
code/LanBortalAuthModule.jar
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/JaasBean.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/PlaceMapBean.java
code/LanBortalBeansClient/.classpath
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/enums/Role.java
code/LanBortalDatabase/src/META-INF/persistence.xml
code/LanBortalDatabase/src/fi/insomnia/bortal/model/EventMap.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/Place.java
code/LanBortalWeb/src/fi/insomnia/bortal/servlet/PlaceMap.java
code/LanBortalAuthModule.jar
View file @
c555a87
No preview for this file type
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/JaasBean.java
View file @
c555a87
...
...
@@ -9,6 +9,7 @@ import javax.ejb.Stateless;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.insomnia.bortal.enums.Role
;
import
fi.insomnia.bortal.facade.UserFacade
;
import
fi.insomnia.bortal.model.User
;
...
...
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/PlaceMapBean.java
View file @
c555a87
package
fi
.
insomnia
.
bortal
.
beans
;
import
java.awt.Graphics
;
import
java.awt.image.BufferedImage
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.util.Date
;
import
java.util.List
;
import
javax.ejb.EJB
;
...
...
@@ -37,6 +39,7 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
public
PlaceMapBean
()
{
// TODO Auto-generated constructor stub
}
@EJB
private
PlaceFacade
placeFacade
;
@EJB
...
...
@@ -46,6 +49,7 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
@Override
public
void
printPlaceMapToStream
(
OutputStream
outputStream
,
String
filetype
,
Event
event
,
Integer
mapId
,
Integer
userId
,
List
<
Integer
>
placeIds
)
throws
IOException
{
long
begin
=
new
Date
().
getTime
();
Integer
eventId
=
event
.
getId
();
List
<
Place
>
selectedPlaceList
=
new
ArrayList
<
Place
>();
...
...
@@ -55,7 +59,7 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
selectedPlaceList
.
add
(
placeFacade
.
find
(
eventId
,
id
));
}
logger
.
info
(
"Got
event {}, mapid {}"
,
event
,
mapId
);
logger
.
info
(
"Got
mapid {}, time {}"
,
mapId
,
new
Date
().
getTime
()
-
begin
);
if
(
selectedPlaceList
.
size
()
>
0
)
{
map
=
selectedPlaceList
.
get
(
0
).
getMap
();
...
...
@@ -65,11 +69,9 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
List
<
Place
>
places
=
map
.
getPlaces
();
logger
.
info
(
"Places: from map {}"
,
places
.
size
());
logger
.
info
(
"Places: from map {}, time {}"
,
places
.
size
(),
new
Date
().
getTime
()
-
begin
);
BufferedImage
image
=
map
.
getMapWithPlaces
();
if
(
userId
!=
null
)
{
User
user
=
userFacade
.
find
(
userId
);
...
...
@@ -83,14 +85,18 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
}
}
}
logger
.
info
(
"sometime {}"
,
new
Date
().
getTime
()
-
begin
);
for
(
Place
place
:
selectedPlaceList
)
{
place
.
drawSelectedPlace
(
image
);
}
logger
.
info
(
"Prewrite {}"
,
new
Date
().
getTime
()
-
begin
);
ImageIO
.
write
(
image
,
filetype
,
outputStream
);
logger
.
info
(
"postwrite {}"
,
new
Date
().
getTime
()
-
begin
);
}
public
String
getSelectPlaceMapUrl
(
EventMap
activeMap
,
Place
selectedPlace
,
User
user
)
{
String
parameters
=
"?"
;
...
...
@@ -105,7 +111,6 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
parameters
+=
"&userid="
+
user
.
getId
();
}
return
"/PlaceMap"
+
parameters
;
// TODO: do something.
}
...
...
code/LanBortalBeansClient/.classpath
View file @
c555a87
...
...
@@ -2,7 +2,6 @@
<classpath>
<classpathentry
kind=
"src"
path=
"ejbModule"
/>
<classpathentry
kind=
"con"
path=
"org.eclipse.jst.j2ee.internal.module.container"
/>
<classpathentry
kind=
"lib"
path=
"/LanBortal/EarContent/lib/LanBortalDatabase.jar"
/>
<classpathentry
kind=
"con"
path=
"org.eclipse.jst.server.core.container/com.sun.enterprise.jst.server.runtimeTarget/GlassFish v3 Java EE 6"
>
<attributes>
<attribute
name=
"owner.project.facets"
value=
"jst.utility"
/>
...
...
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/enums/Role.java
View file @
c555a87
package
fi
.
insomnia
.
bortal
.
enums
;
public
enum
Role
{
USER_BASE
(
true
),
// Logged in user
ADMIN_BASE
(
true
),
SUPERADMIN
(
false
)
// Admin for this event
;
private
boolean
inDatabase
;
Role
(
boolean
inDb
)
{
inDatabase
=
inDb
;
}
public
boolean
isInDatabase
()
{
return
inDatabase
;
}
}
code/LanBortalDatabase/src/META-INF/persistence.xml
View file @
c555a87
...
...
@@ -5,7 +5,6 @@
<properties>
<property
name=
"eclipselink.ddl-generation"
value=
"drop-and-create-tables"
/>
<property
name=
"eclipselink.ddl-generation.output-mode"
value=
"both"
/>
<property
name=
"eclipselink.logging.level"
value=
"ALL"
/>
<property
name=
"eclipselink.cache.type.default"
value=
"NONE"
/>
</properties>
</persistence-unit>
...
...
code/LanBortalDatabase/src/fi/insomnia/bortal/model/EventMap.java
View file @
c555a87
...
...
@@ -15,6 +15,7 @@ import javax.persistence.CascadeType;
import
javax.persistence.Column
;
import
javax.persistence.EmbeddedId
;
import
javax.persistence.Entity
;
import
javax.persistence.FetchType
;
import
javax.persistence.JoinColumn
;
import
javax.persistence.Lob
;
import
javax.persistence.ManyToOne
;
...
...
@@ -24,7 +25,8 @@ import javax.persistence.OneToMany;
import
javax.persistence.Table
;
import
javax.persistence.Version
;
import
org.eclipse.persistence.annotations.Cache
;
import
org.eclipse.persistence.annotations.CacheType
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -36,7 +38,6 @@ import org.slf4j.LoggerFactory;
@NamedQueries
({
@NamedQuery
(
name
=
"EventMap.findAll"
,
query
=
"SELECT e FROM EventMap e"
),
@NamedQuery
(
name
=
"EventMap.findByName"
,
query
=
"SELECT e FROM EventMap e WHERE e.name = :name"
)
})
public
class
EventMap
implements
EventChildInterface
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
EventMap
.
class
);
...
...
@@ -48,7 +49,7 @@ public class EventMap implements EventChildInterface {
private
byte
[]
mapData
;
@Column
(
name
=
"map_name"
)
private
String
name
;
@OneToMany
(
cascade
=
CascadeType
.
ALL
,
mappedBy
=
"map"
)
@OneToMany
(
cascade
=
CascadeType
.
ALL
,
fetch
=
FetchType
.
EAGER
,
mappedBy
=
"map"
)
private
List
<
Place
>
places
=
new
ArrayList
<
Place
>();
@ManyToOne
(
optional
=
false
)
@JoinColumn
(
name
=
"event_id"
,
referencedColumnName
=
"event_id"
,
insertable
=
false
,
updatable
=
false
,
nullable
=
false
)
...
...
code/LanBortalDatabase/src/fi/insomnia/bortal/model/Place.java
View file @
c555a87
...
...
@@ -22,6 +22,9 @@ import javax.persistence.OneToOne;
import
javax.persistence.Table
;
import
javax.persistence.Version
;
import
org.eclipse.persistence.annotations.Cache
;
import
org.eclipse.persistence.annotations.CacheType
;
/**
*
...
...
@@ -206,12 +209,11 @@ public class Place implements EventChildInterface {
public
boolean
equals
(
Object
object
)
{
// TODO: Warning - this method won't work in the case the id fields are
// not set
if
(!(
object
instanceof
Place
))
{
if
(
object
==
null
||
!(
object
instanceof
Place
))
{
return
false
;
}
Place
other
=
(
Place
)
object
;
if
((
this
.
getId
()
==
null
&&
other
.
getId
()
!=
null
)
||
(
this
.
getId
()
!=
null
&&
!
this
.
id
.
equals
(
other
.
id
)))
{
if
((
this
.
getId
()
==
null
&&
other
.
getId
()
!=
null
)
||
(
this
.
getId
()
!=
null
&&
!
this
.
getId
().
equals
(
other
.
id
)))
{
return
false
;
}
return
true
;
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/servlet/PlaceMap.java
View file @
c555a87
...
...
@@ -68,9 +68,9 @@ public class PlaceMap extends HttpServlet {
Integer
userId
=
getIntegerParameter
(
request
,
PARAMETER_CURRENT_USER_ID
);
response
.
setContentType
(
"image/
png
"
);
response
.
setContentType
(
"image/
gif
"
);
placemapBean
.
printPlaceMapToStream
(
ostream
,
"
png
"
,
getEvent
(
request
),
mapId
,
userId
,
placeIds
);
placemapBean
.
printPlaceMapToStream
(
ostream
,
"
gif
"
,
getEvent
(
request
),
mapId
,
userId
,
placeIds
);
/*
* TODO output your page here out.println("<html>");
...
...
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