Commit 09f3c396 by Juho Juopperi

merge

2 parents d091843b 5db922ed
Showing with 948 additions and 255 deletions
deploy.ant.properties.file=/home/tuukka/.netbeans/6.8/gfv3-913352158.properties
deploy.ant.properties.file=/home/tuukka/.netbeans/6.8/gfv3307033442.properties
j2ee.appclient.tool.jvmoptions=-Djava.endorsed.dirs="/usr/local/sges-v3/glassfish/lib/endorsed":"/usr/local/sges-v3/glassfish/modules/endorsed" -javaagent:"/usr/local/sges-v3/glassfish/modules/gf-client.jar"=mode=acscript,arg=-configxml,arg="/home/tuukka/.netbeans/6.8/GlassFish_v3/config/sun-acc.xml",client=jar=
j2ee.appclient.tool.mainclass=org.glassfish.appclient.client.AppClientFacade
j2ee.appclient.tool.runtime=
j2ee.platform.classpath=/usr/local/sges-v3/glassfish/modules/endorsed/jaxb-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/webservices-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/javax.security.jacc.jar:/usr/local/sges-v3/glassfish/modules/javax.resource.jar:/usr/local/sges-v3/glassfish/modules/javax.transaction.jar:/usr/local/sges-v3/glassfish/modules/mail.jar:/usr/local/sges-v3/glassfish/modules/javax.persistence.jar:/usr/local/sges-v3/glassfish/modules/javax.enterprise.deploy.jar:/usr/local/sges-v3/glassfish/modules/bean-validator.jar:/usr/local/sges-v3/glassfish/modules/jsr311-api.jar:/usr/local/sges-v3/glassfish/modules/jsf-api.jar:/usr/local/sges-v3/glassfish/modules/weld-osgi-bundle.jar:/usr/local/sges-v3/glassfish/modules/jstl-impl.jar:/usr/local/sges-v3/glassfish/modules/javax.servlet.jsp.jstl.jar:/usr/local/sges-v3/glassfish/modules/javax.management.j2ee.jar:/usr/local/sges-v3/glassfish/modules/javax.security.auth.message.jar:/usr/local/sges-v3/glassfish/modules/javax.ejb.jar:/usr/local/sges-v3/glassfish/modules/javax.servlet.jsp.jar:/usr/local/sges-v3/glassfish/modules/javax.jms.jar:/usr/local/sges-v3/glassfish/modules/endorsed/javax.annotation.jar:/usr/local/sges-v3/glassfish/modules/javax.servlet.jar:/usr/local/sges-v3/glassfish/modules/jsf-impl.jar
j2ee.server.instance=[/usr/local/sges-v3/glassfish]deployer:gfv3ee6:localhost:36570
j2ee.server.instance=[/usr/local/sges-v3/glassfish]deployer:gfv3ee6:localhost:28892
netbeans.user=/home/tuukka/.netbeans/6.8
wa.copy.client.jar.from=/home/tuukka/.netbeans/6.8/GlassFish_v3/generated/xml
package fi.insomnia.bortal.beans;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.persistence.TypedQuery;
import fi.insomnia.bortal.facade.EventFacade;
import fi.insomnia.bortal.model.Event;
/**
* Session Bean implementation class EventBean
*/
@Stateless
public class EventBean implements EventBeanLocal {
@EJB
private EventFacade eventFacade;
@Override
public Event getEventByHostname(String hostname) {
Event ret = eventFacade.findByHostname(hostname);
if (ret == null) {
ret = findOrCreateDefaultEvent();
}
return ret;
}
public Event findOrCreateDefaultEvent() {
Event ret = eventFacade.findByHostname("");
if (ret == null) {
ret = new Event();
ret.setReferer("");
ret.setName("DEFAULT EVENT");
eventFacade.create(ret);
}
return ret;
}
}
package fi.insomnia.bortal.beans;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.imageio.ImageIO;
import fi.insomnia.bortal.facade.EventMapFacade;
import fi.insomnia.bortal.facade.PlaceFacade;
import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.model.Event;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.EventPk;
import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.PlaceGroup;
import fi.insomnia.bortal.model.User;
/**
* Session Bean implementation class PlaceMapBean
*/
@Stateless
public class PlaceMapBean implements PlaceMapBeanLocal {
/**
* Default constructor.
*/
public PlaceMapBean() {
// TODO Auto-generated constructor stub
}
@EJB
private PlaceFacade placeFacade;
@EJB
private EventMapFacade eventMapFacade;
@EJB
private UserFacade userFacade;
@Override
public void printPlaceMapToStream(OutputStream outputStream, String filetype, Event event, Integer mapId, Integer userId, Integer placeId) throws IOException {
Integer eventId = event.getId();
Place place = null;
EventMap map = null;
if (placeId != null) {
EventPk pk = new EventPk();
pk.setEventId(eventId);
pk.setId(placeId);
place = placeFacade.find(eventId, placeId);
}
if (place != null) {
map = place.getMap();
} else {
EventPk pk = new EventPk();
pk.setEventId(eventId);
pk.setId(mapId);
map = eventMapFacade.find(pk);
}
BufferedImage image = map.getMapWithPlaces();
if (userId != null) {
User user = userFacade.find(userId);
if (user != null) {
for (PlaceGroup uplacegroup : user.getPlaceGroupList()) {
for (Place uplace : uplacegroup.getPlaces())
uplace.drawOwnedPlace(image);
}
}
}
if (place != null) {
place.drawSelectedPlace(image);
}
ImageIO.write(image, filetype, outputStream);
}
}
......@@ -22,9 +22,9 @@ public class SecurityBean implements SecurityBeanLocal {
private final Logger logger = org.slf4j.LoggerFactory.getLogger(SecurityBean.class);
@EJB
LogEntryTypeFacade typeFacade;
private LogEntryTypeFacade typeFacade;
@EJB
LogEntryFacade entryFacade;
private LogEntryFacade entryFacade;
/**
* Default constructor.
......
......@@ -29,7 +29,7 @@ import fi.insomnia.bortal.model.User;
*/
@Stateless
@DeclareRoles("admin")
public class SessionHandlerBean implements SessionHandlerBeanLocal, SessionHandlerBeanRemote{
public class SessionHandlerBean implements SessionHandlerBeanLocal, SessionHandlerBeanRemote {
private static final Logger logger = LoggerFactory.getLogger(SessionHandlerBean.class);
@EJB
......@@ -38,10 +38,12 @@ public class SessionHandlerBean implements SessionHandlerBeanLocal, SessionHandl
private AccessRightFacade accessRightFacade;
@EJB
private RoleFacade roleFacade;
@Resource
SessionContext context;
@Resource
private SessionContext context;
@EJB
private UserBean userbean;
/**
* Default constructor.
*/
......@@ -52,17 +54,20 @@ public class SessionHandlerBean implements SessionHandlerBeanLocal, SessionHandl
@Override
public boolean hasPermission(String target, User user, RolePermission permission) {
if (user == null) {
return false;
}
AccessRight expectedRight = accessRightFacade.findOrCreateByName(target);
User dbusr = userfacade.find(user.getId());
Set<Role> checkedRoles = new HashSet<Role>();
for (Role r : dbusr.getRoles()) {
if (getRights(r, expectedRight, permission, checkedRoles)) {
return true;
if (dbusr != null) {
Set<Role> checkedRoles = new HashSet<Role>();
for (Role r : dbusr.getRoles()) {
if (getRights(r, expectedRight, permission, checkedRoles)) {
return true;
}
}
}
return false;
}
......@@ -129,17 +134,9 @@ public class SessionHandlerBean implements SessionHandlerBeanLocal, SessionHandl
return defaultUser;
}
public void testing()
{
Principal principal = context.getCallerPrincipal();
logger.warn("principal {}",principal.getName());
logger.warn("Principal in admin: {}",context.isCallerInRole("admin"));
}
@Override
public boolean authenticate(String username, String password) {
return (tryLogin(username,password) != null);
return (tryLogin(username, password) != null);
}
@Override
......@@ -148,4 +145,15 @@ public class SessionHandlerBean implements SessionHandlerBeanLocal, SessionHandl
foo.add("admin");
return foo.elements();
}
@Override
public User getCurrentUser() {
Principal principal = context.getCallerPrincipal();
User ret = userbean.getUser(principal.getName());
if (ret == null)
{
ret = getDefaultUser();
}
return ret;
}
}
package fi.insomnia.bortal.beans;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import fi.insomnia.bortal.facade.EventFacade;
import fi.insomnia.bortal.facade.EventMapFacade;
import fi.insomnia.bortal.facade.EventSettingsFacade;
import fi.insomnia.bortal.facade.EventStatusFacade;
import fi.insomnia.bortal.facade.PlaceFacade;
import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.model.Event;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.EventSettings;
import fi.insomnia.bortal.model.EventStatus;
import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.User;
/**
* Session Bean implementation class TestDataBean
*/
@Stateless
public class TestDataBean implements TestDataBeanLocal {
public static final String TEST_MAP_IMAGE_NAME = "testmap.png";
@EJB
private EventMapFacade eventMapFacade;
@EJB
private EventStatusFacade eventStatusFacade;
@EJB
private EventSettingsFacade eventSettingsFacade;
@EJB
private EventFacade eventFacade;
@EJB
private UserFacade userFacade;
@EJB
private PlaceFacade placeFacade;
/**
* Default constructor.
*/
public TestDataBean() {
// TODO Auto-generated constructor stub
}
public EventMap generateTestMap(Event event) {
try {
EventMap map = new EventMap();
map.setEvent(event);
InputStream stream = getClass().getResourceAsStream(TEST_MAP_IMAGE_NAME);
File file = new File(getClass().getResource(TEST_MAP_IMAGE_NAME).toURI());
long length = file.length();
// Create the byte array to hold the data
byte[] bytes = new byte[(int) length];
// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < bytes.length
&& (numRead = stream.read(bytes, offset, bytes.length - offset)) >= 0) {
offset += numRead;
}
// Ensure all the bytes have been read in
if (offset < bytes.length) {
throw new IOException("Could not completely read file " + file.getName());
}
stream.close();
map.setMapData(bytes);
eventMapFacade.create(map);
return map;
} catch (URISyntaxException ex) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
}
return null;
}
/**
* Generate all metashit, ex. events.
*/
public Event generateMetaData() {
EventStatus status = new EventStatus();
status.setStatusName("BLAAH");
eventStatusFacade.create(status);
EventSettings settings = new EventSettings();
settings.setOrganisation("MUN ORGANISAATIO; EI SUN!");
settings.setAdmin(generateUser());
eventSettingsFacade.create(settings);
Event event = new Event();
event.setName("testEvent");
event.setSettings(settings);
event.setStatus(status);
eventFacade.create(event);
return event;
}
private User generateUser() {
User user = new User();
user.setNick("Nick");
user.setPassword("plaah");
userFacade.create(user);
return user;
}
public void generateTestPlaces(EventMap map) {
for (int x = 5; x < 400; x += 50) {
for (int y = 5; y < 150; y += 50) {
Place place = new Place();
place.setMap(map);
place.setMapX(x);
place.setMapY(y);
placeFacade.create(place);
}
}
}
}
......@@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.model.User;
import fi.insomnia.bortal.utilities.PasswordFunctions;
/**
* Session Bean implementation class UserBean
......
......@@ -26,9 +26,10 @@ public class AccessRightFacade extends IntegerPkGenericFacade<AccessRight> {
public AccessRight findOrCreateByName(String target) {
// Fetch access right by name
TypedQuery<AccessRight> q = em.createNamedQuery("AccessRight.findByName", AccessRight.class);
TypedQuery<AccessRight> q = em.createQuery("SELECT a FROM AccessRight a WHERE a.name = :name", AccessRight.class);
q.setParameter("name", target);
AccessRight right = q.getSingleResult();
AccessRight right = null;
right = this.getSingleNullableResult(q);
// Might not exist yet -> create
if (right == null) {
......
......@@ -12,6 +12,14 @@ public abstract class EventChildGenericFacade<T extends EventChildInterface> ext
super(entityClass);
}
public T find(Integer eventId, Integer id)
{
EventPk pk = new EventPk();
pk.setEventId(eventId);
pk.setId(id);
return find(pk);
}
......
......@@ -4,6 +4,8 @@ import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import fi.insomnia.bortal.model.Event;
@Stateless
......@@ -21,4 +23,13 @@ public class EventFacade extends GenericFacade<Integer, Event> {
return em;
}
public Event findByHostname(String hostname) {
TypedQuery<Event> q = em.createNamedQuery("Event.findByReferer", Event.class);
q.setParameter("referer", hostname);
return this.getSingleNullableResult(q);
}
}
......@@ -3,6 +3,7 @@ package fi.insomnia.bortal.facade;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
......@@ -12,7 +13,7 @@ import fi.insomnia.bortal.model.ModelInterface;
/**
* Session Bean implementation class GenericFacade
*/
public abstract class GenericFacade<PK,T extends ModelInterface<PK>> implements GenericFacadeLocal<PK,T> {
public abstract class GenericFacade<PK,T extends ModelInterface<PK>>{
private Class<T> entClass;
public GenericFacade(Class<T>entityClass)
......@@ -26,16 +27,16 @@ public abstract class GenericFacade<PK,T extends ModelInterface<PK>> implements
protected abstract EntityManager getEm();
@Override
public void create(T entity) {
getEm().persist(entity);
}
@Override
public void remove(T entity) {
getEm().remove(entity);
}
@Override
public T merge(T entity) {
return getEm().merge(entity);
}
......@@ -66,5 +67,15 @@ public abstract class GenericFacade<PK,T extends ModelInterface<PK>> implements
TypedQuery<Long> q = getEm().createQuery(cq);
return q.getSingleResult();
}
protected T getSingleNullableResult(TypedQuery<T> q) {
T ret = null;
try {
ret = q.getSingleResult();
} catch (NoResultException e) {
ret = null;
}
return ret;
}
}
......@@ -5,13 +5,13 @@ import fi.insomnia.bortal.model.ModelInterface;
/**
* Session Bean implementation class GenericFacade
*/
public abstract class IntegerPkGenericFacade<T extends ModelInterface<Integer>> extends GenericFacade<Integer,T> {
public abstract class IntegerPkGenericFacade<T extends ModelInterface<Integer>> extends GenericFacade<Integer, T> {
public IntegerPkGenericFacade(Class<T> entityClass) {
super(entityClass);
}
}
}
......@@ -25,9 +25,9 @@ public class RoleFacade extends EventChildGenericFacade<Role> {
}
public Role findByName(String name) {
TypedQuery<Role> q = em.createNamedQuery("User.findByName", Role.class);
TypedQuery<Role> q = em.createNamedQuery("Role.findByRoleName", Role.class);
q.setParameter("name", name);
return q.getSingleResult();
return this.getSingleNullableResult(q);
}
public Role getOrCreatePublicRole() {
......
......@@ -4,16 +4,15 @@ import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import fi.insomnia.bortal.model.User;
@Stateless
@LocalBean
public class UserFacade extends GenericFacade<Integer, User> {
public class UserFacade extends GenericFacade<Integer, User>{
public static final String DEFAULT_USER_LOGIN = "default";
public static final String DEFAULT_USER_LOGIN = "ANONYMOUS";
@PersistenceContext
private EntityManager em;
......@@ -34,9 +33,10 @@ public class UserFacade extends GenericFacade<Integer, User> {
// return q.getSingleResult();
TypedQuery<User> q = em.createQuery("SELECT u FROM User u WHERE u.login = :login", User.class);
q.setParameter("login", login);
return (User) q.getSingleResult();
return getSingleNullableResult(q);
}
public User getOrCreateDefaultUser() {
User defaultUser = findByLogin(DEFAULT_USER_LOGIN);
......
deploy.ant.properties.file=/home/tuukka/.netbeans/6.8/gfv3-913352158.properties
deploy.ant.properties.file=/home/tuukka/.netbeans/6.8/gfv3307033442.properties
j2ee.platform.classpath=/usr/local/sges-v3/glassfish/modules/endorsed/jaxb-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/webservices-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/javax.security.jacc.jar:/usr/local/sges-v3/glassfish/modules/javax.resource.jar:/usr/local/sges-v3/glassfish/modules/javax.transaction.jar:/usr/local/sges-v3/glassfish/modules/mail.jar:/usr/local/sges-v3/glassfish/modules/javax.persistence.jar:/usr/local/sges-v3/glassfish/modules/javax.enterprise.deploy.jar:/usr/local/sges-v3/glassfish/modules/bean-validator.jar:/usr/local/sges-v3/glassfish/modules/jsr311-api.jar:/usr/local/sges-v3/glassfish/modules/jsf-api.jar:/usr/local/sges-v3/glassfish/modules/weld-osgi-bundle.jar:/usr/local/sges-v3/glassfish/modules/jstl-impl.jar:/usr/local/sges-v3/glassfish/modules/javax.servlet.jsp.jstl.jar:/usr/local/sges-v3/glassfish/modules/javax.management.j2ee.jar:/usr/local/sges-v3/glassfish/modules/javax.security.auth.message.jar:/usr/local/sges-v3/glassfish/modules/javax.ejb.jar:/usr/local/sges-v3/glassfish/modules/javax.servlet.jsp.jar:/usr/local/sges-v3/glassfish/modules/javax.jms.jar:/usr/local/sges-v3/glassfish/modules/endorsed/javax.annotation.jar:/usr/local/sges-v3/glassfish/modules/javax.servlet.jar:/usr/local/sges-v3/glassfish/modules/jsf-impl.jar
j2ee.platform.embeddableejb.classpath=/usr/local/sges-v3/glassfish/lib/embedded/glassfish-embedded-static-shell.jar
j2ee.platform.wsgen.classpath=/usr/local/sges-v3/glassfish/modules/webservices-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/webservices-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/jaxb-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/jaxb-api-osgi.jar
j2ee.platform.wsimport.classpath=/usr/local/sges-v3/glassfish/modules/webservices-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/webservices-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/jaxb-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/jaxb-api-osgi.jar
j2ee.platform.wsit.classpath=
j2ee.server.instance=[/usr/local/sges-v3/glassfish]deployer:gfv3ee6:localhost:36570
j2ee.server.instance=[/usr/local/sges-v3/glassfish]deployer:gfv3ee6:localhost:28892
javac.debug=true
javadoc.preview=true
jaxbwiz.endorsed.dirs=/usr/local/netbeans-6.8/ide12/modules/ext/jaxb/api
......
package fi.insomnia.bortal.beans;
import javax.ejb.Local;
import fi.insomnia.bortal.model.Event;
@Local
public interface EventBeanLocal {
Event getEventByHostname(String hostname);
}
package fi.insomnia.bortal.beans;
import java.io.IOException;
import java.io.OutputStream;
import javax.ejb.Local;
import fi.insomnia.bortal.model.Event;
@Local
public interface PlaceMapBeanLocal {
void printPlaceMapToStream(OutputStream outputStream, String filetype, Event event, Integer mapId, Integer userId, Integer placeId) throws IOException;
}
......@@ -9,15 +9,7 @@ public interface SessionHandlerBeanLocal {
boolean hasPermission(String target, User user, RolePermission permission);
/**
*
* @param username
* @param password
* @return User on success, null on fail
*/
User tryLogin(String username, String password);
User getDefaultUser();
void testing();
User getCurrentUser();
}
package fi.insomnia.bortal.beans;
import javax.ejb.Local;
import fi.insomnia.bortal.model.Event;
import fi.insomnia.bortal.model.EventMap;
@Local
public interface TestDataBeanLocal {
EventMap generateTestMap(Event event);
Event generateMetaData();
void generateTestPlaces(EventMap map);
}
package fi.insomnia.bortal.facade;
import java.util.List;
import javax.ejb.Local;
import fi.insomnia.bortal.model.ModelInterface;
@Local
public interface GenericFacadeLocal<PK, T extends ModelInterface<PK>> {
void create(T entity);
void remove(T entity);
T merge(T entity);
T find(PK id);
List<T> findAll();
List<T> findRange(int[] range);
long count();
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
<nextCatalog catalog="nbproject/private/retriever/catalog.xml"/>
</catalog>
......@@ -3,7 +3,7 @@
<persistence-unit name="BortalDb" transaction-type="JTA">
<jta-data-source>jdbc/bortal</jta-data-source>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="database"/>
</properties>
</persistence-unit>
......
......@@ -71,7 +71,7 @@ public class AccessRight implements ModelInterface<Integer> {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public AccessRight() {
}
......
......@@ -121,7 +121,7 @@ public class AccountEvent implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
@Override
public EventPk getId() {
......
......@@ -134,7 +134,7 @@ public class Bill implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public Bill() {
}
......
......@@ -72,7 +72,7 @@ public class BillLine implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
/**
* Calculate the total price for the items on this line
......
......@@ -47,7 +47,7 @@ public class CardTemplate implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public CardTemplate() {
}
......
......@@ -101,7 +101,7 @@ public class Compo implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
@Override
public EventPk getId() {
......
......@@ -90,7 +90,7 @@ public class CompoEntry implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
@Override
public EventPk getId() {
......
......@@ -67,7 +67,7 @@ public class CompoEntryFile implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
@Override
public EventPk getId() {
......
......@@ -57,7 +57,7 @@ public class CompoEntryParticipant implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
@Override
public EventPk getId() {
......
......@@ -87,7 +87,7 @@ public class Discount implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public Discount() {
}
......
......@@ -53,7 +53,7 @@ public class DiscountInstance implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public DiscountInstance() {
}
......
......@@ -86,7 +86,7 @@ public class Event implements ModelInterface<Integer> {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
@OneToMany(mappedBy = "event_id")
private List<Bill> bills;
......
......@@ -11,7 +11,7 @@ import java.io.Serializable;
*
* @author tuukka
*/
public interface EventChildInterface extends ModelInterface<EventPk>, Serializable {
public interface EventChildInterface extends ModelInterface<EventPk> {
public EventPk getId();
public void setId(EventPk id);
......
......@@ -4,7 +4,11 @@
*/
package fi.insomnia.bortal.model;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.List;
import javax.imageio.ImageIO;
import javax.persistence.CascadeType;
import javax.persistence.Column;
......@@ -46,7 +50,7 @@ public class EventMap implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
@OneToMany(mappedBy = "eventMap")
private List<Reader> readers;
......@@ -156,4 +160,20 @@ public class EventMap implements EventChildInterface {
public void setReaders(List<Reader> readers) {
this.readers = readers;
}
public BufferedImage getMapWithPlaces() throws IOException {
BufferedImage image = ImageIO.read(new ByteArrayInputStream(getMapData()));
for(Place place : getPlaces()) {
place.drawPlace(image);
}
return image;
}
}
......@@ -52,7 +52,7 @@ public class EventSettings implements ModelInterface<Integer> {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public EventSettings() {
}
......
......@@ -30,21 +30,18 @@ import javax.persistence.Version;
public class EventStatus implements ModelInterface<Integer> {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "event_status_id", nullable = false)
private Integer id;
@Column(name = "status_name", nullable = false)
private String name;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "status")
private List<Event> events;
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public EventStatus() {
}
......
......@@ -56,7 +56,7 @@ public class FoodWave implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public FoodWave() {
}
......
......@@ -44,7 +44,7 @@ public class FoodWaveTemplate implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public FoodWaveTemplate() {
}
......
......@@ -71,7 +71,7 @@ public class GroupMembership implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public GroupMembership() {
}
......
......@@ -41,7 +41,7 @@ public class Location implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public Location() {
}
......
......@@ -55,7 +55,7 @@ public class LogEntry implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public LogEntry() {
}
......
......@@ -56,7 +56,7 @@ public class LogEntryType implements ModelInterface<Integer> {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
/**
* Admins can change the loglevel of EntryTypes to receive eg. email for
......
package fi.insomnia.bortal.model;
public interface ModelInterface<T> {
import java.io.Serializable;
public interface ModelInterface<T> extends Serializable {
public T getId();
public void setId(T id);
......
......@@ -71,7 +71,7 @@ public class News implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public News() {
}
......
......@@ -51,7 +51,7 @@ public class NewsGroup implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public NewsGroup() {
}
......
......@@ -4,6 +4,10 @@
*/
package fi.insomnia.bortal.model;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
......@@ -44,15 +48,17 @@ public class Place implements EventChildInterface {
private Integer mapX;
@Column(name = "map_y")
private Integer mapY;
@Column(name = "width")
private Integer width;
@Column(name = "height")
private Integer height;
@Column(name = "place_details")
@Lob
private String details;
@Column(name = "place_code")
private String code;
@OneToOne(mappedBy = "placeReservation")
private GroupMembership placeReserver;
/**
* Which group has bought the place
*/
......@@ -67,7 +73,6 @@ public class Place implements EventChildInterface {
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne(optional = false)
private EventMap map;
/**
* Which ticket type is this place sold as
*/
......@@ -76,7 +81,6 @@ public class Place implements EventChildInterface {
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne()
private Product product;
/**
* Who is the current currentUser (mapped with code printed on the place) of
* the place. Used in Vectorama currentUser tracking.
......@@ -84,10 +88,9 @@ public class Place implements EventChildInterface {
@JoinColumn(name = "current_user_id", referencedColumnName = "id")
@ManyToOne
private User currentUser;
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public Place() {
}
......@@ -244,4 +247,73 @@ public class Place implements EventChildInterface {
public GroupMembership getPlaceReserver() {
return placeReserver;
}
/**
* @return the height
*/
public Integer getHeight() {
return height;
}
/**
* @param height the height to set
*/
public void setHeight(Integer height) {
this.height = height;
}
/**
* @return the width
*/
public Integer getWidth() {
return width;
}
/**
* @param width the width to set
*/
public void setWidth(Integer width) {
this.width = width;
}
public boolean isCoordinateInPlace(int x, int y) {
if (x > mapX
&& x < (mapX + width)
&& y > mapY
&& y < (mapY + height)) {
return true;
}
return false;
}
private static final Color NORMAL_COLOR = Color.BLUE;
private static final Color RESERVED_COLOR = Color.RED;
private static final Color SELECTED_COLOR = Color.GREEN;
private static final Color OWNED_COLOR = Color.GREEN;
public void drawPlace(BufferedImage targetImage) {
Graphics2D g = targetImage.createGraphics();
if (placeGroup != null) {
g.setColor(RESERVED_COLOR);
g.fill(new Rectangle(mapX, mapY, width, height));
} else {
g.setColor(NORMAL_COLOR);
g.draw(new Rectangle(mapX, mapY, width, height));
}
}
public void drawSelectedPlace(BufferedImage targetImage) {
Graphics2D g = targetImage.createGraphics();
g.setColor(SELECTED_COLOR);
g.fill(new Rectangle(mapX, mapY, width, height));
}
public void drawOwnedPlace(BufferedImage targetImage) {
Graphics2D g = targetImage.createGraphics();
g.setColor(OWNED_COLOR);
g.fill(new Rectangle(mapX, mapY, width, height));
}
}
......@@ -74,7 +74,7 @@ public class PlaceGroup implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public PlaceGroup() {
}
......
......@@ -74,7 +74,7 @@ public class PrintedCard implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public PrintedCard() {
}
......
......@@ -60,7 +60,7 @@ public class Product implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public Product() {
}
......
......@@ -65,7 +65,7 @@ public class Reader implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public Reader() {
}
......
......@@ -57,7 +57,7 @@ public class ReaderEvent implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public ReaderEvent() {
}
......
......@@ -76,7 +76,7 @@ public class Role implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public Role() {
}
......
......@@ -61,7 +61,7 @@ public class RoleRight implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public RoleRight() {
}
......
......@@ -27,8 +27,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.utilities.PasswordFunctions;
import java.io.Serializable;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
/**
*
......@@ -162,7 +162,7 @@ public class User implements ModelInterface<Integer> {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
@OneToMany(mappedBy = "admin")
private List<EventSettings> eventSettings;
......
......@@ -58,7 +58,7 @@ public class UserImage implements ModelInterface<Integer> {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public UserImage() {
}
......
......@@ -56,7 +56,7 @@ public class Vote implements EventChildInterface {
@Version
@Column(nullable = false)
private int jpaVersionField;
private int jpaVersionField = 0;
public Vote() {
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="LanBortalUtilities" default="default" basedir=".">
<description>Builds, tests, and runs the project LanBortalUtilities.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="LanBortalUtilities-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
......@@ -79,4 +79,11 @@ public class PasswordFunctions {
}
return sb.toString();
}
public static String createPassword(String password) {
// TODO Auto-generated method stub
return null;
}
}
......@@ -2,6 +2,7 @@
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="BortalDb" transaction-type="JTA">
<jta-data-source>jdbc/bortal</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="database"/>
......
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>LanBortalWeb</display-name>
<context-param>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>LanBortalWeb</display-name>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<servlet-mapping>
<servlet-name>PlaceMap</servlet-name>
<url-pattern>/PlaceMap</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsf</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>PlaceMap</servlet-name>
<servlet-class>fi.insomnia.bortal.servlet.PlaceMap</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<filter>
<display-name>HostnameFilter</display-name>
<filter-name>HostnameFilter</filter-name>
<filter-class>fi.insomnia.bortal.HostnameFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HostnameFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>omniarealm</realm-name>
<form-login-config>
<form-login-page>/auth/login.jsf</form-login-page>
<form-error-page>/auth/loginError.jsf</form-error-page>
</form-login-config>
</login-config>
<security-role>
<role-name>admin</role-name>
</security-role>
<security-role>
<role-name>user</role-name>
</security-role>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsf</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<filter>
<display-name>HostnameFilter</display-name>
<filter-name>HostnameFilter</filter-name>
<filter-class>fi.insomnia.bortal.HostnameFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HostnameFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>omniarealm</realm-name>
<form-login-config>
<form-login-page>/auth/login.jsf</form-login-page>
<form-error-page>/auth/loginError.jsf</form-error-page>
</form-login-config>
</login-config>
<security-role>
<role-name>admin</role-name>
</security-role>
<security-role>
<role-name>user</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>forbidden</web-resource-name>
<url-pattern>*.xhtml</url-pattern>
</web-resource-collection>
<auth-constraint>
<description>Thou shall not read the sources..</description>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>forbidden</web-resource-name>
<url-pattern>*.xhtml</url-pattern>
</web-resource-collection>
<auth-constraint>
<description>Thou shall not read the sources..</description>
</auth-constraint>
</security-constraint>
</web-app>
\ No newline at end of file
</web-app>
......@@ -11,21 +11,19 @@
<ui:define name="header">Add new user</ui:define>
<ui:define name="content">
<
<form method="post" action="j_security_check">
<table border="0">
<tr>
<td>#{i18n['login.username']}</td>
<td><input type="text" name="j_username" /></td>
</tr>
<tr>
<td>#{i18n['login.password']}</td>
<td><input type="password" name="j_password" /></td>
</tr>
</table>
<input type="submit" value="#{i18n['login.submit']}" />
<h:panelGrid columns="2">
<h:outputText value="#{i18n['login.username']}" />
<input type="text" name="j_username" />
<h:outputText value="#{i18n['login.password']}" />
<input type="password" name="j_password" />
</h:panelGrid>
<h:outputText>
<input type="submit" value="#{i18n['login.submit']}" />
</h:outputText>
</form>
</ui:define>
<ui:define name="footer">footer</ui:define>
</ui:composition>
......
......@@ -10,7 +10,8 @@
<ui:define name="title">CreateUser</ui:define>
<ui:define name="header">Add new user</ui:define>
<ui:define name="content">
Logged out.${userView.logout() }
<h:outputText value="#{i18n['logoutmessage'] }" />
${userView.logout() }
</ui:define>
<ui:define name="footer">footer</ui:define>
</ui:composition>
......
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form>
<!-- todo: remember to remove this :) -->
<h:commandButton value="generate the data" action="#{TestDataView.generateData}" />
</h:form>
</h:body>
</html>
......@@ -20,7 +20,7 @@
<div id="links">
<!-- **** INSERT LINKS HERE **** -->
<ui:insert name="somelinks">
<a href="http://www.insomnia.fi">www.insomnia.fi</a>
<a href="http://www.insomnia.fi">www.insomnia.fi</a> <tools:loginLogout />
</ui:insert>
</div>
<div id="logo"><h1><ui:insert name="globaltitle">Lan Bortal</ui:insert></h1></div>
......@@ -79,8 +79,7 @@
<div id="column2">
<h:messages globalOnly="true"/>
<tools:loginLogout /><br />
<ui:insert name="content">
Default content..
</ui:insert>
......
......@@ -14,26 +14,30 @@
</composite:interface>
<composite:implementation>
<h:form>
<form>
<c:choose>
<c:when test="#{not empty cc.attrs.isOneliner}">
<h:inputText value="#{sessionHandler.username}" />
<h:inputSecret value="#{sessionHandler.password}" />
<h:commandButton value="#{i18n['login.submit']}" action="#{sessionHandler.login}" />
<input type="text" name="j_username" />
<input type="password" name="j_password" />
<input type="submit" value="#{i18n['login.submit']}" />
</c:when>
<c:otherwise>
<h:panelGrid columns="2">
<h:outputText value="#{i18n['login.username']}" /> <h:inputText value="#{sessionHandler.username}" />
<h:outputText value="#{i18n['login.password']}" /> <h:inputSecret value="#{sessionHandler.password}" />
<h:commandButton value="#{i18n['login.submit']}" action="#{sessionHandler.login}" />
<h:outputText value="#{i18n['login.username']}" />
<input type="text" name="j_username" />
<h:outputText value="#{i18n['login.password']}" />
<input type="password" name="j_password" />
</h:panelGrid>
<input type="submit" value="#{i18n['login.submit']}" />
</c:otherwise>
</c:choose>
</h:form>
</form>
</composite:implementation>
......
deploy.ant.properties.file=/home/tuukka/.netbeans/6.8/gfv3-913352158.properties
deploy.ant.properties.file=/home/tuukka/.netbeans/6.8/gfv3307033442.properties
j2ee.platform.classpath=/usr/local/sges-v3/glassfish/modules/endorsed/jaxb-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/webservices-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/javax.security.jacc.jar:/usr/local/sges-v3/glassfish/modules/javax.resource.jar:/usr/local/sges-v3/glassfish/modules/javax.transaction.jar:/usr/local/sges-v3/glassfish/modules/mail.jar:/usr/local/sges-v3/glassfish/modules/javax.persistence.jar:/usr/local/sges-v3/glassfish/modules/javax.enterprise.deploy.jar:/usr/local/sges-v3/glassfish/modules/bean-validator.jar:/usr/local/sges-v3/glassfish/modules/jsr311-api.jar:/usr/local/sges-v3/glassfish/modules/jsf-api.jar:/usr/local/sges-v3/glassfish/modules/weld-osgi-bundle.jar:/usr/local/sges-v3/glassfish/modules/jstl-impl.jar:/usr/local/sges-v3/glassfish/modules/javax.servlet.jsp.jstl.jar:/usr/local/sges-v3/glassfish/modules/javax.management.j2ee.jar:/usr/local/sges-v3/glassfish/modules/javax.security.auth.message.jar:/usr/local/sges-v3/glassfish/modules/javax.ejb.jar:/usr/local/sges-v3/glassfish/modules/javax.servlet.jsp.jar:/usr/local/sges-v3/glassfish/modules/javax.jms.jar:/usr/local/sges-v3/glassfish/modules/endorsed/javax.annotation.jar:/usr/local/sges-v3/glassfish/modules/javax.servlet.jar:/usr/local/sges-v3/glassfish/modules/jsf-impl.jar
j2ee.platform.embeddableejb.classpath=/usr/local/sges-v3/glassfish/lib/embedded/glassfish-embedded-static-shell.jar
j2ee.platform.is.jsr109=true
j2ee.platform.wsgen.classpath=/usr/local/sges-v3/glassfish/modules/webservices-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/webservices-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/jaxb-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/jaxb-api-osgi.jar
j2ee.platform.wsimport.classpath=/usr/local/sges-v3/glassfish/modules/webservices-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/webservices-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/jaxb-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/jaxb-api-osgi.jar
j2ee.platform.wsit.classpath=
j2ee.server.instance=[/usr/local/sges-v3/glassfish]deployer:gfv3ee6:localhost:36570
j2ee.server.instance=[/usr/local/sges-v3/glassfish]deployer:gfv3ee6:localhost:28892
javac.debug=true
javadoc.preview=true
jaxbwiz.endorsed.dirs=/usr/local/netbeans-6.8/ide12/modules/ext/jaxb/api
......
......@@ -27,7 +27,7 @@ file.reference.slf4j-api-1.5.8.jar=../LanBortal/EarContent/lib/slf4j-api-1.5.8.j
file.reference.slf4j-jdk14-1.5.8.jar=../LanBortal/EarContent/lib/slf4j-jdk14-1.5.8.jar
includes=**
j2ee.deploy.on.save=true
j2ee.platform=1.6-web
j2ee.platform=1.6
j2ee.server.type=gfv3ee6
jar.compress=false
java.source.based=true
......
......@@ -82,5 +82,6 @@ public class HostnameFilter implements Filter {
}
return ret;
}
}
......@@ -27,8 +27,6 @@ public class SessionHandler {
@EJB
private SessionHandlerBeanLocal handlerbean;
private User user = null;
private String username = "";
private String password = "";
/** Creates a new instance of SessionHandler */
public SessionHandler() {
......@@ -46,17 +44,24 @@ public class SessionHandler {
return hasPermission(target, perm);
}
public String getHostname()
{
private HttpSession getHttpSession() {
FacesContext ctx = FacesContext.getCurrentInstance();
HttpSession sess =(HttpSession) ctx.getExternalContext().getSession(false);
return HostnameFilter.getHostname(sess);
HttpSession sess = (HttpSession) ctx.getExternalContext().getSession(false);
return sess;
}
public String getHostname() {
HttpSession sess = getHttpSession();
String ret = "";
if (sess != null) {
ret = HostnameFilter.getHostname(getHttpSession());
}
return ret;
}
public boolean hasPermission(String target, RolePermission permission) {
return true;
// return handlerbean.hasPermission(target, getUser(), permission);
return handlerbean.hasPermission(target, getUser(), permission);
}
......@@ -73,60 +78,31 @@ public class SessionHandler {
}
public void setUser(User user) {
this.user = user;
if (user == null) {
this.user = getUser();
} else if (canExecute("impersonateUser")) {
this.user = user;
}
}
public User getUser() {
if (user == null) {
user = handlerbean.getDefaultUser();
user = handlerbean.getCurrentUser();
}
return user;
}
public String logout() {
user = null;
return "logout";
}
public String login() {
user = handlerbean.tryLogin(username, password);
if (user == null) {
return "loginFailed";
} else {
return "loginSuccess";
FacesContext ctx = FacesContext.getCurrentInstance();
HttpSession sess = (HttpSession) ctx.getExternalContext().getSession(false);
if (sess != null) {
sess.invalidate();
}
}
/**
* @return the username
*/
public String getUsername() {
return username;
}
/**
* @param username the username to set
*/
public void setUsername(String username) {
this.username = username;
}
/**
* @return the password
*/
public String getPassword() {
return password;
}
/**
* @param password the password to set
*/
public void setPassword(String password) {
this.password = password;
return "logout";
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.insomnia.bortal.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import fi.insomnia.bortal.HostnameFilter;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.PlaceMapBeanLocal;
import fi.insomnia.bortal.model.Event;
/**
*
* @author tuukka
*/
public class PlaceMap extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 8769688627918936258L;
@EJB
private PlaceMapBeanLocal placemapBean;
private EventBeanLocal eventBean;
public static final String PARAMETER_EVENT_MAP_ID = "mapid";
public static final String PARAMETER_SELECTED_PLACE_ID = "placeid";
public static final String PARAMETER_CURRENT_USER_ID = "userid";
public static final String PARAMETER_EVENT_ID = "eventid";
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request
* servlet request
* @param response
* servlet response
* @throws ServletException
* if a servlet-specific error occurs
* @throws IOException
* if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
Integer placeId = getIntegerParameter(request, PARAMETER_SELECTED_PLACE_ID);
Integer mapId = getIntegerParameter(request, PARAMETER_EVENT_MAP_ID);
Integer userId = getIntegerParameter(request, PARAMETER_CURRENT_USER_ID);
response.setContentType("image/png");
placemapBean.printPlaceMapToStream(response.getOutputStream(), "png", getEvent(request), mapId, userId, placeId);
/*
* TODO output your page here out.println("<html>");
* out.println("<head>");
* out.println("<title>Servlet PlaceMap</title>");
* out.println("</head>"); out.println("<body>");
* out.println("<h1>Servlet PlaceMap at " + request.getContextPath
* () + "</h1>"); out.println("</body>"); out.println("</html>");
*/
} finally {
out.close();
}
}
private Event getEvent(HttpServletRequest request) {
String hostname = HostnameFilter.getHostname(request.getSession());
return eventBean.getEventByHostname(hostname);
}
public void addPlacesToMap() {
}
/***
* Convert request parameter into integer
*
* @param request
* @param parameter
* @return
*/
private static Integer getIntegerParameter(HttpServletRequest request, String parameter) {
try {
String valueString = request.getParameter(parameter);
Integer value = Integer.parseInt(valueString);
return value;
} catch (NumberFormatException nfe) {
}
return null;
}
// <editor-fold defaultstate="collapsed"
// desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
*
* @param request
* servlet request
* @param response
* servlet response
* @throws ServletException
* if a servlet-specific error occurs
* @throws IOException
* if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
*
* @param request
* servlet request
* @param response
* servlet response
* @throws ServletException
* if a servlet-specific error occurs
* @throws IOException
* if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.insomnia.bortal.view;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import fi.insomnia.bortal.beans.TestDataBeanLocal;
import fi.insomnia.bortal.model.Event;
import fi.insomnia.bortal.model.EventMap;
/**
*
* @author tuukka
*/
@ManagedBean(name = "TestDataView")
@RequestScoped
public class TestDataView {
@EJB
private TestDataBeanLocal testdatabean;
public void generateData() {
Event event = testdatabean.generateMetaData();
EventMap map = testdatabean.generateTestMap(event);
testdatabean.generateTestPlaces(map);
}
/** Creates a new instance of TestDataView */
public TestDataView() {
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!