Commit 41c6f5ab by juhosa

Merge branch 'master' of g:/bortal/bortal

Conflicts:
	code/external/tuomari

asd
2 parents 0ba5b72f 2ac8beb0
[submodule "code/external/tuomari"]
path = code/external/tuomari
url = tuomari.iki.fi:/home/tuomari/git/iudex/
......@@ -2,7 +2,7 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/LanBortalAuthModuleClient"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM 1.6">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
......
......@@ -7,7 +7,7 @@
<attribute name="owner.project.facets" value="jst.utility"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM 1.6">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
......
......@@ -18,50 +18,68 @@ import javax.mail.internet.MimeMessage.RecipientType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.clientutils.BortalLocalContextHolder;
import fi.insomnia.bortal.util.MailMessage;
/**
* Message-Driven Bean implementation class for: MailMessageBean
*
*/
@MessageDriven(
activationConfig = { @ActivationConfigProperty( propertyName = "destinationType", propertyValue = "javax.jms.Queue" ) },
mappedName = "jms/mailque")
@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue") }, mappedName = "jms/mailque")
public class MailMessageBean implements MessageListener {
@Resource(name = "mail/lanbortal")
private Session mailSession;
private static final Logger logger = LoggerFactory.getLogger(MailMessageBean.class);
/**
* Default constructor.
*/
public MailMessageBean() {
// TODO Auto-generated constructor stub
}
@Resource(name = "mail/lanbortal")
private Session mailSession;
private static final Logger logger = LoggerFactory
.getLogger(MailMessageBean.class);
/**
* @see MessageListener#onMessage(Message)
*/
public void onMessage(Message message) {
/**
* Default constructor.
*/
public MailMessageBean() {
// TODO Auto-generated constructor stub
}
MailMessage mailmsg = null;
try {
mailmsg = (MailMessage) ((ObjectMessage) message).getObject();
logger.debug("Got message {}", mailmsg.getToName());
MimeMessage msg = new MimeMessage(mailSession);
msg.setSubject(mailmsg.getSubject());
msg.setFrom(mailmsg.getFrom());
msg.setRecipient(RecipientType.TO, mailmsg.getTo());
msg.setText(mailmsg.getMessage(), mailmsg.getCharset());
Transport.send(msg);
/**
* @see MessageListener#onMessage(Message)
*/
@Override
public void onMessage(Message message) {
} catch (JMSException e) {
logger.debug("Error receiving jms for {}", mailmsg, e);
} catch (MessagingException e) {
logger.debug("Unsupported encoding exception while sending mail to {}", mailmsg, e);
} catch (UnsupportedEncodingException e) {
logger.debug("Unsupported encoding exception while sending mail to {}", mailmsg, e);
}
MailMessage mailmsg = null;
try {
mailmsg = (MailMessage) ((ObjectMessage) message).getObject();
logger.debug("Got message {}", mailmsg.getToName());
}
if (BortalLocalContextHolder.isInDevelopmentMode()) {
String dmessage = " To: "
+ mailmsg.getTo() + "\n Subject: "
+ mailmsg.getSubject() + "\n Text: "
+ mailmsg.getMessage() + "\n";
logger.debug("Not sendet mail (debug -mode): {}", dmessage);
} else {
MimeMessage msg = new MimeMessage(mailSession);
msg.setSubject(mailmsg.getSubject());
msg.setFrom(mailmsg.getFrom());
msg.setRecipient(RecipientType.TO, mailmsg.getTo());
msg.setText(mailmsg.getMessage(), mailmsg.getCharset());
Transport.send(msg);
}
} catch (JMSException e) {
logger.debug("Error receiving jms for {}", mailmsg, e);
} catch (MessagingException e) {
logger.debug(
"Unsupported encoding exception while sending mail to {}",
mailmsg, e);
} catch (UnsupportedEncodingException e) {
logger.debug(
"Unsupported encoding exception while sending mail to {}",
mailmsg, e);
}
}
}
package fi.insomnia.bortal.beans.mail;
import javax.ejb.Local;
@Local
public interface MailBeanLocal {
}
......@@ -11,6 +11,8 @@ public class BortalLocalContextHolder {
private String hostname;
private final Map<IAppPermission, Boolean> rightcache = new HashMap<IAppPermission, Boolean>();
private static boolean inDevelopmentMode = false;
public BortalLocalContextHolder() {
}
......@@ -63,4 +65,16 @@ public class BortalLocalContextHolder {
return getThread();
}
public static boolean isInDevelopmentMode() {
return inDevelopmentMode;
}
public static void setInDevelopmentMode(boolean developmentMode) {
inDevelopmentMode = developmentMode;
}
}
\ No newline at end of file
......@@ -8,105 +8,105 @@ import javax.mail.internet.InternetAddress;
import fi.insomnia.bortal.model.User;
public class MailMessage implements Serializable {
/**
/**
*
*/
private static final long serialVersionUID = -4769468394850407107L;
private static final String DEFAULT_MAIL_CHARSET = "iso-8859-1";
private String subject;
private String fromName = "Insomnia lippukauppa";
private String fromAddress = "info@insomnia.fi";
private String toName;
private String toAddress;
private String message;
private String charset = DEFAULT_MAIL_CHARSET;
public InternetAddress getTo() throws UnsupportedEncodingException {
return new InternetAddress(toAddress, toName, getCharset());
}
public InternetAddress getFrom() throws UnsupportedEncodingException {
return new InternetAddress(fromAddress, fromName, getCharset());
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getFromName() {
return fromName;
}
public void setFromName(String fromName) {
this.fromName = fromName;
}
public String getFromAddress() {
return fromAddress;
}
public void setFromAddress(String fromAddress) {
this.fromAddress = fromAddress;
}
public String getToName() {
return toName;
}
public void setToName(String toName) {
this.toName = toName;
}
public String getToAddress() {
return toAddress;
}
public void setToAddress(String toAddress) {
this.toAddress = toAddress;
}
public String getMessage() {
return message;
}
public void setMessage(Object... msgpart) {
StringBuilder msg = new StringBuilder();
for (Object o : msgpart) {
msg.append(o);
}
message = msg.toString();
}
public void setMessage(String message) {
this.message = message;
}
public static String getDefaultMailCharset() {
return DEFAULT_MAIL_CHARSET;
}
public void setCharset(String charset) {
this.charset = charset;
}
public String getCharset() {
return charset;
}
public void setTo(User user) {
setToName(user.getWholeName());
setToAddress(user.getEmail());
}
@Override
public String toString() {
return new StringBuilder("fi.insomnia.bortal.util.MailMessage[to=").append(toAddress).append("]").toString();
}
private static final long serialVersionUID = -4769468394850407107L;
private static final String DEFAULT_MAIL_CHARSET = "iso-8859-1";
private String subject;
private String fromName = "Insomnia lippukauppa";
private String fromAddress = "info@insomnia.fi";
private String toName;
private String toAddress;
private String message;
private String charset = DEFAULT_MAIL_CHARSET;
public InternetAddress getTo() throws UnsupportedEncodingException {
return new InternetAddress(toAddress, toName, getCharset());
}
public InternetAddress getFrom() throws UnsupportedEncodingException {
return new InternetAddress(fromAddress, fromName, getCharset());
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getFromName() {
return fromName;
}
public void setFromName(String fromName) {
this.fromName = fromName;
}
public String getFromAddress() {
return fromAddress;
}
public void setFromAddress(String fromAddress) {
this.fromAddress = fromAddress;
}
public String getToName() {
return toName;
}
public void setToName(String toName) {
this.toName = toName;
}
public String getToAddress() {
return toAddress;
}
public void setToAddress(String toAddress) {
this.toAddress = toAddress;
}
public String getMessage() {
return message;
}
public void setMessage(Object... msgpart) {
StringBuilder msg = new StringBuilder();
for (Object o : msgpart) {
msg.append(o);
}
message = msg.toString();
}
public void setMessage(String message) {
this.message = message;
}
public static String getDefaultMailCharset() {
return DEFAULT_MAIL_CHARSET;
}
public void setCharset(String charset) {
this.charset = charset;
}
public String getCharset() {
return charset;
}
public void setTo(User user) {
setToName(user.getWholeName());
setToAddress(user.getEmail());
}
@Override
public String toString() {
return new StringBuilder("fi.insomnia.bortal.util.MailMessage[to=").append(toAddress).append("]").toString();
}
}
......@@ -7,7 +7,7 @@
<attribute name="owner.project.facets" value="jst.utility"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM 1.6">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
......
......@@ -14,6 +14,7 @@ public class GenericEntity extends EntityEquals implements ModelInterface<Intege
private static final long serialVersionUID = -9041737052951021560L;
public static final String ID_COLUMN = "id";
@Id
@Column(name = ID_COLUMN, nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
......
......@@ -47,7 +47,6 @@ public class User extends GenericEntity {
private static final long serialVersionUID = -1632200627103418206L;
@Column(name = "created", nullable = false)
// , columnDefinition = "timestamptz default now()")
@Temporal(TemporalType.TIMESTAMP)
private Calendar created = Calendar.getInstance();
......
<?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"
<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_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>LanBortalWeb</display-name>
......@@ -8,6 +8,11 @@
<session-timeout>30</session-timeout>
</session-config>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
<!--param-value>Production</param-value-->
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
......@@ -49,7 +54,7 @@
<servlet-name>UserCardServlet</servlet-name>
<url-pattern>/UserCard</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>CardTemplateServlet</servlet-name>
<servlet-class>fi.insomnia.bortal.servlet.CardTemplateServlet</servlet-class>
......@@ -58,7 +63,7 @@
<servlet-name>CardTemplateServlet</servlet-name>
<url-pattern>/CardTemplate</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>PlaceMap</servlet-name>
......@@ -119,23 +124,12 @@
<servlet-name>PrintBill</servlet-name>
<url-pattern>/PrintBill</url-pattern>
</servlet-mapping>
<!-- <error-page>
<error-code>401</error-code>
<location>/permissionDeniedRedirect.jsp</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/permissionDeniedRedirect.jsp</location>
</error-page>
<error-page>
<exception-type>fi.insomnia.bortal.exceptions.PermissionDeniedException</exception-type>
<location>/permissionDeniedRedirect.jsp</location>
</error-page>
<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/permissionDeniedRedirect.jsp</location>
</error-page>
-->
<!-- <error-page> <error-code>401</error-code> <location>/permissionDeniedRedirect.jsp</location>
</error-page> <error-page> <error-code>403</error-code> <location>/permissionDeniedRedirect.jsp</location>
</error-page> <error-page> <exception-type>fi.insomnia.bortal.exceptions.PermissionDeniedException</exception-type>
<location>/permissionDeniedRedirect.jsp</location> </error-page> <error-page>
<exception-type>javax.servlet.ServletException</exception-type> <location>/permissionDeniedRedirect.jsp</location>
</error-page> -->
<persistence-unit-ref>
<persistence-unit-ref-name>BortalEMF</persistence-unit-ref-name>
</persistence-unit-ref>
......@@ -150,4 +144,6 @@
<url-pattern>/PlaceGroupPdf</url-pattern>
</servlet-mapping>
</web-app>
\ No newline at end of file
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"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"
xmlns:h="http://java.sun.com/jsf/html" xmlns:users="http://java.sun.com/jsf/composite/cditools/user"
xmlns:tools="http://java.sun.com/jsf/composite/cditools" xmlns:f="http://java.sun.com/jsf/core"
>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<!-- f:event type="preRenderView" listener="#{newsListView.initView}" /-->
</f:metadata>
<ui:define name="content">
<h1>#{i18n['actionlog.messagelist.header']}</h1>
<h:dataTable styleClass="bordertable" id="message" value="#{actionLogMessageView.messages}" var="message">
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['actionlog.user']}" />
</f:facet>
<h:outputText value="#{message.user}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['actionlog.crew']}" />
</f:facet>
<h:outputText value="#{message.crew}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['actionlog.message']}" />
</f:facet>
<h:outputText value="#{message.message}" />
</h:column>
</h:dataTable>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
......@@ -23,14 +23,19 @@
</h:inputText>
<h:outputLabel value="#{i18n['bill.billNumber']}:" />
<h:inputText value="#{billEditView.bill.billNumber}" />
<h:outputLabel value="#{i18n['bill.addr1']}:" />
<h:inputText value="#{billEditView.bill.addr1}" />
<h:outputLabel value="#{i18n['bill.addr2']}:" />
<h:inputText value="#{billEditView.bill.addr2}" />
<h:outputLabel value="#{i18n['bill.addr3']}:" />
<h:inputText value="#{billEditView.bill.addr3}" />
<h:outputLabel value="#{i18n['bill.addr4']}:" />
<h:inputText value="#{billEditView.bill.addr4}" />
<h:outputLabel value="#{i18n['bill.addr5']}:" />
<h:inputText value="#{billEditView.bill.addr5}" />
......
......@@ -9,6 +9,12 @@
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:define name="content">
<h:outputLabel rendered="#{sessionHandler.isInDevelopmentMode()}">
Development-tilassa.
Vaihda web.xml-tiedostosta ohjelman tila (javax.faces.PROJECT_STAGE) Productioniksi ennen kuin julkaiset ohjelman tuotantoon.
</h:outputLabel>
<h1>Insomnia lippukauppa</h1>
<h3>Lippujen hinnat</h3>
<ul>
......
......@@ -19,7 +19,16 @@
<div id="header">
<div id="logo">
<img src="#{request.contextPath}/resources/style/insomnia2/img/logo.png" />
<c:choose>
<c:when test="#{sessionHandler.isInDevelopmentMode()}">
<img src="#{request.contextPath}/resources/style/insomnia2/img/devel_logo.png" />
</c:when>
<c:otherwise>
<img src="#{request.contextPath}/resources/style/insomnia2/img/logo.png" />
</c:otherwise>
</c:choose>
</div>
<div id="login">
<h:outputText rendered="#{sessionHandler.loggedIn}"
......
......@@ -11,7 +11,6 @@
<f:event type="preRenderView" listener="#{newsListView.initView}" />
</f:metadata>
<ui:param name="thispage" value="page.user.create" />
<ui:define name="content">
<h1>#{i18n['newslist.header']}</h1>
......
......@@ -2,6 +2,7 @@ package fi.insomnia.bortal;
import java.io.IOException;
import javax.faces.context.FacesContext;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
......@@ -23,7 +24,9 @@ import fi.insomnia.bortal.model.User;
*/
public class HostnameFilter implements Filter {
private static final Logger logger = LoggerFactory.getLogger(HostnameFilter.class);
private static final Logger logger = LoggerFactory
.getLogger(HostnameFilter.class);
private boolean developmentMode = false;
/**
* Default constructor.
......@@ -44,7 +47,9 @@ public class HostnameFilter implements Filter {
* @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
*/
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = null;
if (request != null && request instanceof HttpServletRequest) {
......@@ -66,16 +71,19 @@ public class HostnameFilter implements Filter {
}
String hostname = url.substring(beginindex, lastindex);
httpRequest.getSession().setAttribute(EventBeanLocal.HTTP_URL_HOSTNAME, hostname);
httpRequest.getSession().setAttribute(
EventBeanLocal.HTTP_URL_HOSTNAME, hostname);
BortalLocalContextHolder.setHostname(hostname);
BortalLocalContextHolder.setInDevelopmentMode(developmentMode);
if (httpRequest.getUserPrincipal() == null) {
try {
httpRequest.login(User.ANONYMOUS_LOGINNAME, null);
} catch (Throwable t) {
logger.warn("Error logging in as anonymous... ignoring.. ", t);
logger.warn("Error logging in as anonymous... ignoring.. ",
t);
}
}
......@@ -94,7 +102,16 @@ public class HostnameFilter implements Filter {
*/
@Override
public void init(FilterConfig fConfig) throws ServletException {
// Nothing...
// check if software is in development -mode
FacesContext fc = FacesContext.getCurrentInstance();
String stage = fc.getExternalContext().getInitParameter(
"javax.faces.PROJECT_STAGE");
if (stage.trim().equalsIgnoreCase("Development")) {
developmentMode = true;
}
}
public static String getCurrentHostname(HttpSession sess) {
......@@ -108,4 +125,5 @@ public class HostnameFilter implements Filter {
return ret;
}
}
......@@ -17,9 +17,11 @@ import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.HostnameFilter;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.PermissionBeanLocal;
import fi.insomnia.bortal.beans.RoleBeanLocal;
import fi.insomnia.bortal.clientutils.BortalLocalContextHolder;
import fi.insomnia.bortal.enums.apps.IAppPermission;
import fi.insomnia.bortal.model.User;
......@@ -152,4 +154,8 @@ public class SessionHandler {
}
return preurlString;
}
public boolean isInDevelopmentMode() {
return BortalLocalContextHolder.isInDevelopmentMode();
}
}
package fi.insomnia.bortal.web.cdiview.actionlog;
import java.util.ArrayList;
import javax.faces.bean.RequestScoped;
import javax.inject.Named;
import fi.insomnia.bortal.web.cdiview.actionlog.ActionMessage;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@RequestScoped
public class ActionLogMessageView extends GenericCDIView {
private static final long serialVersionUID = 1L;
ArrayList<ActionMessage> messages = null;
public ArrayList<ActionMessage> getMessages() {
if(messages == null) {
messages = new ArrayList<ActionMessage>();
ActionMessage test = new ActionMessage();
test.setTimestamp("test123");
test.setUser("homo");
test.setCrew("oijdsaofdsa");
test.setMessage("pupu on siella");
messages.add(test);
messages.add(test);
messages.add(test);
messages.add(test);
}
return messages;
}
}
package fi.insomnia.bortal.web.cdiview.actionlog;
public class ActionMessage {
private String timestamp;
private String user;
private String crew;
private String message;
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public String getCrew() {
return crew;
}
public void setCrew(String crew) {
this.crew = crew;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
\ No newline at end of file
......@@ -42,6 +42,7 @@ public class UserView extends GenericCDIView {
private CroppedImage croppedImage;
private User user;
@Inject
private transient Conversation conversation;
......@@ -56,6 +57,7 @@ public class UserView extends GenericCDIView {
private boolean canSave = false;
private String password;
private String passwordcheck;
@EJB
private CardTemplateBeanLocal cardBean;
......
TuomariUtils @ a91e217e
Subproject commit a91e217e681f3baa8e73f1edd22b263a99a6828d
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!