java/nekurak.net-web/src/java/cz/frantovo/nekurak/web/FunkceEL.java
author František Kučera <franta-hg@frantovo.cz>
Tue Jun 08 14:42:00 2010 +0200 (2010-06-08)
changeset 134 4bd1e353c527
parent 68 df5aedafb826
child 145 0efefbf5f8b6
permissions -rw-r--r--
Kontrola komentářů i na výstupu.
franta-hg@66
     1
package cz.frantovo.nekurak.web;
franta-hg@66
     2
franta-hg@68
     3
import cz.frantovo.nekurak.dto.Podnik;
franta-hg@66
     4
import cz.frantovo.nekurak.servlet.Fotky;
franta-hg@134
     5
import cz.frantovo.nekurak.util.Komentare;
franta-hg@134
     6
import cz.frantovo.nekurak.vyjimky.KomentarovaVyjimka;
franta-hg@134
     7
import java.util.logging.Level;
franta-hg@134
     8
import java.util.logging.Logger;
franta-hg@66
     9
franta-hg@66
    10
/**
franta-hg@66
    11
 * Knihovna funkcí použitelná v EL
franta-hg@66
    12
 * @author fiki
franta-hg@66
    13
 */
franta-hg@66
    14
public class FunkceEL {
franta-hg@66
    15
franta-hg@66
    16
    /** Musí odpovídat cestě, kam je namapovaný servlet. */
franta-hg@66
    17
    private static final String SERVLET = "fotky";
franta-hg@66
    18
franta-hg@66
    19
    public static String fotka(int id, boolean nahled) {
franta-hg@66
    20
	String prostredek = nahled ? Fotky.PODADRESAR_NAHLED : Fotky.PODADRESAR_ORIGINAL;
franta-hg@66
    21
	return SERVLET + "/" + prostredek + "/" + id + "." + Fotky.PRIPONA;
franta-hg@66
    22
    }
franta-hg@68
    23
franta-hg@68
    24
    public static boolean maFotky(Podnik p) {
franta-hg@68
    25
	return !p.getFotky().isEmpty();
franta-hg@68
    26
    }
franta-hg@134
    27
franta-hg@134
    28
    /**
franta-hg@134
    29
     * @param komentar komentář včetně kořenové značky, XML jako text
franta-hg@134
    30
     * @return true, pokud vyhovuje XML schématu
franta-hg@134
    31
     */
franta-hg@134
    32
    public static boolean zkontrolujKomentar(String komentar) {
franta-hg@134
    33
	try {
franta-hg@134
    34
	    Komentare.zkontroluj(komentar);
franta-hg@134
    35
	    return true;
franta-hg@134
    36
	} catch (KomentarovaVyjimka ex) {
franta-hg@134
    37
	    return false;
franta-hg@134
    38
	}
franta-hg@134
    39
    }
franta-hg@66
    40
}