Zakládání podniků + HTTP autentizace.
1.1 --- a/java/nekurak.net-ejb/src/conf/Podnik.hbm.xml Thu Feb 25 02:41:57 2010 +0100
1.2 +++ b/java/nekurak.net-ejb/src/conf/Podnik.hbm.xml Thu Feb 25 08:26:46 2010 +0100
1.3 @@ -3,7 +3,11 @@
1.4 "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
1.5 <hibernate-mapping>
1.6 <class name="cz.frantovo.nekurak.dto.Podnik" table="podnik">
1.7 - <id name="id" column="id" type="integer"/>
1.8 + <id name="id" column="id" type="integer">
1.9 + <generator class="sequence">
1.10 + <param name="sequence">podnik_seq</param>
1.11 + </generator>
1.12 + </id>
1.13 <property name="nazev" column="nazev"/>
1.14 <property name="popis" column="popis"/>
1.15 <property name="url" column="url"/>
2.1 --- a/java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/dao/PodnikDAO.java Thu Feb 25 02:41:57 2010 +0100
2.2 +++ b/java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/dao/PodnikDAO.java Thu Feb 25 08:26:46 2010 +0100
2.3 @@ -26,6 +26,10 @@
2.4 return dotaz.getResultList();
2.5 }
2.6
2.7 + public void uloz(Podnik p) {
2.8 + em.persist(p);
2.9 + }
2.10 +
2.11 private static String t(Class trida) {
2.12 return trida.getSimpleName();
2.13 }
3.1 --- a/java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/ejb/PodnikEJB.java Thu Feb 25 02:41:57 2010 +0100
3.2 +++ b/java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/ejb/PodnikEJB.java Thu Feb 25 08:26:46 2010 +0100
3.3 @@ -3,6 +3,7 @@
3.4 import cz.frantovo.nekurak.dao.PodnikDAO;
3.5 import cz.frantovo.nekurak.dto.Podnik;
3.6 import java.util.Collection;
3.7 +import javax.annotation.security.RolesAllowed;
3.8 import javax.ejb.EJB;
3.9 import javax.ejb.Stateless;
3.10
3.11 @@ -20,4 +21,14 @@
3.12 Collection<Podnik> vysledek = podnikDAO.getPodniky();
3.13 return vysledek;
3.14 }
3.15 +
3.16 + @RolesAllowed("opravneny")
3.17 + public void zalozPodnik(Podnik p) {
3.18 + podnikDAO.uloz(p);
3.19 + }
3.20 +
3.21 + @RolesAllowed("opravneny")
3.22 + public void upravPodnik(Podnik p) {
3.23 + podnikDAO.uloz(p);
3.24 + }
3.25 }
4.1 --- a/java/nekurak.net-lib/src/cz/frantovo/nekurak/ejb/PodnikRemote.java Thu Feb 25 02:41:57 2010 +0100
4.2 +++ b/java/nekurak.net-lib/src/cz/frantovo/nekurak/ejb/PodnikRemote.java Thu Feb 25 08:26:46 2010 +0100
4.3 @@ -12,5 +12,9 @@
4.4 public interface PodnikRemote {
4.5
4.6 public Collection<Podnik> getPodniky();
4.7 +
4.8 + public void zalozPodnik(cz.frantovo.nekurak.dto.Podnik p);
4.9 +
4.10 + public void upravPodnik(cz.frantovo.nekurak.dto.Podnik p);
4.11
4.12 }
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/java/nekurak.net-web/src/java/cz/frantovo/nekurak/web/PridatPodnik.java Thu Feb 25 08:26:46 2010 +0100
5.3 @@ -0,0 +1,23 @@
5.4 +package cz.frantovo.nekurak.web;
5.5 +
5.6 +import cz.frantovo.nekurak.dto.Podnik;
5.7 +
5.8 +public class PridatPodnik {
5.9 +
5.10 + private HledacSluzby hledac = new HledacSluzby();
5.11 +
5.12 + private Podnik podnik = new Podnik();
5.13 +
5.14 + public Podnik getPodnik() {
5.15 + return podnik;
5.16 + }
5.17 +
5.18 + public void setPodnik(Podnik podnik) {
5.19 + this.podnik = podnik;
5.20 + }
5.21 +
5.22 + public boolean getPridano() {
5.23 + hledac.getPodnikEJB().zalozPodnik(podnik);
5.24 + return true;
5.25 + }
5.26 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/java/nekurak.net-web/web/WEB-INF/casti/detail.jsp Thu Feb 25 08:26:46 2010 +0100
6.3 @@ -0,0 +1,12 @@
6.4 +<?xml version="1.0" encoding="UTF-8"?>
6.5 +<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
6.6 + xmlns:c="http://java.sun.com/jsp/jstl/core"
6.7 + xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
6.8 + xmlns:fn="http://java.sun.com/jsp/jstl/functions"
6.9 + version="2.0">
6.10 +
6.11 + <jsp:useBean id="uvod" class="cz.frantovo.nekurak.web.Uvod" scope="request"/>
6.12 +
6.13 + <p>TODO: Detail podniku (<c:out value="${param.podnik}"/>).</p>
6.14 +
6.15 +</jsp:root>
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/java/nekurak.net-web/web/WEB-INF/casti/pridatPodnik.jsp Thu Feb 25 08:26:46 2010 +0100
7.3 @@ -0,0 +1,48 @@
7.4 +<?xml version="1.0" encoding="UTF-8"?>
7.5 +<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
7.6 + xmlns:c="http://java.sun.com/jsp/jstl/core"
7.7 + xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
7.8 + xmlns:fn="http://java.sun.com/jsp/jstl/functions"
7.9 + version="2.0">
7.10 +
7.11 + <jsp:useBean id="podnik" class="cz.frantovo.nekurak.dto.Podnik" scope="request"/>
7.12 + <jsp:useBean id="pridatPodnik" class="cz.frantovo.nekurak.web.PridatPodnik" scope="request"/>
7.13 +
7.14 + <h1>Přidání nového podniku</h1>
7.15 +
7.16 + <c:choose>
7.17 + <c:when test="${param.akcePridat == 'pridej'}">
7.18 + <jsp:setProperty name="podnik" property="*"/>
7.19 + <jsp:setProperty name="pridatPodnik" property="podnik" value="${podnik}"/>
7.20 +
7.21 + <p>Název: ${pridatPodnik.podnik.nazev} / ${param.nazev}</p>
7.22 + <p>Popis: ${pridatPodnik.podnik.popis}</p>
7.23 + <p>URL: ${pridatPodnik.podnik.url}</p>
7.24 + <p>Ulice: ${pridatPodnik.podnik.ulice}</p>
7.25 + <p>č.p.: ${pridatPodnik.podnik.cisloPopisne}</p>
7.26 + <p>Město: ${pridatPodnik.podnik.mesto}</p>
7.27 +
7.28 +
7.29 + <c:if test="${pridatPodnik.pridano}">
7.30 + <p>Podnik byl přidán.</p>
7.31 + </c:if>
7.32 + </c:when>
7.33 + <c:otherwise>
7.34 + <form method="post" action="?akce=pridatPodnik&amp;akcePridat=pridej">
7.35 + <fieldset>
7.36 + <label>Název: <input type="text" name="nazev" maxlength="255"/></label><br/>
7.37 + <label>Popis: <input type="text" name="popis" maxlength="255"/></label><br/>
7.38 + <label>URL: <input type="text" name="url" maxlength="255"/></label><br/>
7.39 + <label>Ulice: <input type="text" name="ulice" maxlength="64"/></label><br/>
7.40 + <label>č.p.: <input type="text" name="cisloPopisne" maxlength="5"/></label><br/>
7.41 + <label>Město: <input type="text" name="mesto" maxlength="64"/></label><br/>
7.42 + <button value="submit">Přidat podnik</button>
7.43 + </fieldset>
7.44 + </form>
7.45 + </c:otherwise>
7.46 + </c:choose>
7.47 +
7.48 +
7.49 +
7.50 +
7.51 +</jsp:root>
8.1 --- a/java/nekurak.net-web/web/WEB-INF/casti/uvod.jsp Thu Feb 25 02:41:57 2010 +0100
8.2 +++ b/java/nekurak.net-web/web/WEB-INF/casti/uvod.jsp Thu Feb 25 08:26:46 2010 +0100
8.3 @@ -10,17 +10,19 @@
8.4 <p>Naposledy přidané podniky:</p>
8.5
8.6 <c:forEach var="p" items="${uvod.podniky}">
8.7 - <h2><c:out value="${p.nazev}"/></h2>
8.8 - <p><c:out value="${p.popis}"/></p>
8.9 - <p>
8.10 + <div class="podnik">
8.11 + <a href="?akce=detail&amp;podnik=${p.id}"><h2><c:out value="${p.nazev}"/></h2></a>
8.12 + <p><c:out value="${p.popis}"/></p>
8.13 + <p>
8.14 Adresa:<br/>
8.15 - <c:out value="${p.ulice}"/>&#160;
8.16 - <c:out value="${p.cisloPopisne}"/><br/>
8.17 - <c:out value="${p.mesto}"/>
8.18 - </p>
8.19 - <c:if test="${p.url != null}">
8.20 - <p><a href="${fn:escapeXml(p.url)}">www stránka</a></p>
8.21 - </c:if>
8.22 + <c:out value="${p.ulice}"/>&#160;
8.23 + <c:out value="${p.cisloPopisne}"/><br/>
8.24 + <c:out value="${p.mesto}"/>
8.25 + </p>
8.26 + <c:if test="${p.url != null}">
8.27 + <p><a href="${fn:escapeXml(p.url)}">www stránka</a></p>
8.28 + </c:if>
8.29 + </div>
8.30 </c:forEach>
8.31
8.32 </jsp:root>
9.1 --- a/java/nekurak.net-web/web/WEB-INF/sun-web.xml Thu Feb 25 02:41:57 2010 +0100
9.2 +++ b/java/nekurak.net-web/web/WEB-INF/sun-web.xml Thu Feb 25 08:26:46 2010 +0100
9.3 @@ -1,12 +1,16 @@
9.4 <?xml version="1.0" encoding="UTF-8"?>
9.5 <!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
9.6 <sun-web-app error-url="">
9.7 - <context-root>/nekurak.net-web</context-root>
9.8 - <class-loader delegate="true"/>
9.9 - <parameter-encoding default-charset="UTF-8"/>
9.10 - <jsp-config>
9.11 - <property name="keepgenerated" value="true">
9.12 - <description>Keep a copy of the generated servlet class' java code.</description>
9.13 - </property>
9.14 - </jsp-config>
9.15 + <context-root>/nekurak.net-web</context-root>
9.16 + <class-loader delegate="true"/>
9.17 + <parameter-encoding default-charset="UTF-8"/>
9.18 + <jsp-config>
9.19 + <property name="keepgenerated" value="true">
9.20 + <description>Keep a copy of the generated servlet class' java code.</description>
9.21 + </property>
9.22 + </jsp-config>
9.23 + <security-role-mapping>
9.24 + <role-name>opravneny</role-name>
9.25 + <group-name>spravce</group-name>
9.26 + </security-role-mapping>
9.27 </sun-web-app>
10.1 --- a/java/nekurak.net-web/web/WEB-INF/web.xml Thu Feb 25 02:41:57 2010 +0100
10.2 +++ b/java/nekurak.net-web/web/WEB-INF/web.xml Thu Feb 25 08:26:46 2010 +0100
10.3 @@ -1,24 +1,44 @@
10.4 <?xml version="1.0" encoding="UTF-8"?>
10.5 <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" 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">
10.6 <session-config>
10.7 - <session-timeout>30</session-timeout>
10.8 + <session-timeout>
10.9 + 30
10.10 + </session-timeout>
10.11 </session-config>
10.12 <welcome-file-list>
10.13 - <welcome-file>index.jsp</welcome-file>
10.14 + <welcome-file>index.jsp</welcome-file>
10.15 </welcome-file-list>
10.16 <error-page>
10.17 - <!-- Stránka nenalezena -->
10.18 - <error-code>404</error-code>
10.19 - <location>/WEB-INF/chyby/404.jsp</location>
10.20 + <!-- Stránka nenalezena -->
10.21 + <error-code>404</error-code>
10.22 + <location>/WEB-INF/chyby/404.jsp</location>
10.23 </error-page>
10.24 <error-page>
10.25 - <!-- Interní chyba serveru -->
10.26 - <error-code>500</error-code>
10.27 - <location>/WEB-INF/chyby/500.jsp</location>
10.28 + <!-- Interní chyba serveru -->
10.29 + <error-code>500</error-code>
10.30 + <location>/WEB-INF/chyby/500.jsp</location>
10.31 </error-page>
10.32 <context-param>
10.33 - <!-- Pro případ, že chybí hlavička „Accept-language“ v HTTP požadavku -->
10.34 - <param-name>javax.servlet.jsp.jstl.fmt.fallbackLocale</param-name>
10.35 - <param-value>cs</param-value>
10.36 + <!-- Pro případ, že chybí hlavička „Accept-language“ v HTTP požadavku -->
10.37 + <param-name>javax.servlet.jsp.jstl.fmt.fallbackLocale</param-name>
10.38 + <param-value>cs</param-value>
10.39 </context-param>
10.40 + <!-- <zabezpečení> -->
10.41 + <security-role>
10.42 + <role-name>opravneny</role-name>
10.43 + </security-role>
10.44 + <security-constraint>
10.45 + <web-resource-collection>
10.46 + <web-resource-name>Správa Nekuřák.net</web-resource-name>
10.47 + <url-pattern>/sprava/*</url-pattern>
10.48 + </web-resource-collection>
10.49 + <auth-constraint>
10.50 + <role-name>opravneny</role-name>
10.51 + </auth-constraint>
10.52 + </security-constraint>
10.53 + <login-config>
10.54 + <auth-method>BASIC</auth-method>
10.55 + <realm-name>nekurakNET</realm-name>
10.56 + </login-config>
10.57 + <!-- </zabezpečení> -->
10.58 </web-app>
11.1 --- a/java/nekurak.net-web/web/index.jsp Thu Feb 25 02:41:57 2010 +0100
11.2 +++ b/java/nekurak.net-web/web/index.jsp Thu Feb 25 08:26:46 2010 +0100
11.3 @@ -30,19 +30,26 @@
11.4 </div>
11.5
11.6 <ul id="nabidka">
11.7 - <li><a href="#">Úvod</a></li>
11.8 - <li><a href="#">Přidat podnik</a></li>
11.9 - <li><a href="#">Přihlásit se</a></li>
11.10 + <li><a href="?">Úvod</a></li>
11.11 + <li><a href="${pageContext.servletContext.contextPath}/sprava">Správa</a></li>
11.12 + <c:if test="${pageContext.request.userPrincipal.name != null}">
11.13 + <li><a href="?akce=pridatPodnik">Přidat podnik</a></li>
11.14 + <li id="prihlasenyUzivatel">Přihlášený uživatel: ${pageContext.request.userPrincipal.name}</li>
11.15 + </c:if>
11.16 +
11.17 </ul>
11.18
11.19 <div id="obsah">
11.20
11.21 <c:choose>
11.22 <c:when test="${param.akce == 'detail'}">
11.23 -
11.24 + <jsp:include page="/WEB-INF/casti/detail.jsp" flush="false"/>
11.25 + </c:when>
11.26 + <c:when test="${param.akce == 'pridatPodnik'}">
11.27 + <jsp:include page="/WEB-INF/casti/pridatPodnik.jsp" flush="false"/>
11.28 </c:when>
11.29 <c:otherwise>
11.30 - <jsp:include page="WEB-INF/casti/uvod.jsp" flush="false"/>
11.31 + <jsp:include page="/WEB-INF/casti/uvod.jsp" flush="false"/>
11.32 </c:otherwise>
11.33 </c:choose>
11.34
11.35 @@ -51,8 +58,8 @@
11.36 <div id="paticka">
11.37 <p>
11.38 © 2010 nekurak.net. Licence: Affero GPL.
11.39 - <a href="nekurak.net-src.zip">nekurak.net-src.zip</a>
11.40 - <a href="nekurak.net-src.zip.SHA-512">.</a>
11.41 + <a href="${pageContext.servletContext.contextPath}/nekurak.net-src.zip">nekurak.net-src.zip</a>
11.42 + <a href="${pageContext.servletContext.contextPath}/nekurak.net-src.zip.SHA-512">.</a>
11.43 </p>
11.44 </div>
11.45
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/java/nekurak.net-web/web/sprava/grafika Thu Feb 25 08:26:46 2010 +0100
12.3 @@ -0,0 +1,1 @@
12.4 +../grafika/
12.5 \ No newline at end of file
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/java/nekurak.net-web/web/sprava/index.jsp Thu Feb 25 08:26:46 2010 +0100
13.3 @@ -0,0 +1,1 @@
13.4 +../index.jsp
13.5 \ No newline at end of file
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2 +++ b/java/nekurak.net-web/web/sprava/styl.css Thu Feb 25 08:26:46 2010 +0100
14.3 @@ -0,0 +1,1 @@
14.4 +../styl.css
14.5 \ No newline at end of file
15.1 --- a/java/nekurak.net-web/web/styl.css Thu Feb 25 02:41:57 2010 +0100
15.2 +++ b/java/nekurak.net-web/web/styl.css Thu Feb 25 08:26:46 2010 +0100
15.3 @@ -5,6 +5,10 @@
15.4 text-align: center;
15.5 }
15.6
15.7 +a {
15.8 + text-decoration: none;
15.9 +}
15.10 +
15.11 .body {
15.12 width: 1000px;
15.13 text-align: left;
15.14 @@ -37,7 +41,7 @@
15.15 #nabidka li {
15.16 display: inline;
15.17 font-size: 14px;
15.18 - margin-left: 8px;
15.19 + margin-left: 12px;
15.20 }
15.21
15.22 #nabidka li a {
15.23 @@ -48,6 +52,10 @@
15.24 color: orange;
15.25 }
15.26
15.27 +#prihlasenyUzivatel {
15.28 + color: gray;
15.29 +}
15.30 +
15.31 #obsah {
15.32 width: 980px;
15.33 border: 1px solid silver;
15.34 @@ -81,3 +89,19 @@
15.35 font-weight: bold;
15.36 }
15.37
15.38 +.podnik a h2 {
15.39 + color: black;
15.40 +}
15.41 +
15.42 +fieldset {
15.43 + border: none;
15.44 +}
15.45 +
15.46 +form {
15.47 + text-align: right;
15.48 + max-width: 400px;
15.49 +}
15.50 +
15.51 +input {
15.52 + width:200px;
15.53 +}