Compare commits
No commits in common. 'master' and 'Verze_2.0' have entirely different histories.
@ -1,79 +0,0 @@
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number: 16464111046498525641 (0xe47c45c4252121c9)
|
||||
Signature Algorithm: sha1WithRSAEncryption
|
||||
Issuer: C=CZ, ST=Vysocina, O=bukova.info, CN=Josef Rokos/emailAddress=rokos@bukova.info
|
||||
Validity
|
||||
Not Before: Jun 24 09:59:50 2015 GMT
|
||||
Not After : Jun 21 09:59:50 2025 GMT
|
||||
Subject: C=CZ, ST=Vysocina, O=bukova.info, CN=Josef Rokos/emailAddress=rokos@bukova.info
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsaEncryption
|
||||
Public-Key: (2048 bit)
|
||||
Modulus:
|
||||
00:bc:fb:64:50:5b:58:03:8c:20:1c:77:d3:50:31:
|
||||
94:55:78:d6:05:bb:bc:88:9d:cb:20:b1:8c:ff:ac:
|
||||
fc:97:1a:b1:9c:29:c4:ac:af:ed:3b:de:93:d5:cf:
|
||||
75:3e:d0:05:41:32:bf:12:25:53:60:28:af:ff:3e:
|
||||
3c:3a:4c:52:78:3f:b2:78:b9:c6:2f:fc:0e:44:eb:
|
||||
65:c3:7f:38:2b:ab:88:37:8c:68:55:69:e3:3d:5e:
|
||||
9b:99:25:11:55:06:ab:e8:c1:fa:54:da:5b:e7:9b:
|
||||
3e:3f:39:4f:cf:b3:cb:48:cf:96:02:89:0b:7e:24:
|
||||
c7:00:e9:ce:8d:ea:07:cf:21:f2:89:51:c8:cc:7a:
|
||||
04:e4:68:6f:1c:a8:e0:76:18:40:62:ee:2f:bd:13:
|
||||
64:b7:1e:2e:18:bb:b1:d4:17:d5:fb:1f:07:59:65:
|
||||
46:f0:c4:51:dc:ac:62:ff:31:a8:72:26:a6:1a:88:
|
||||
37:23:82:49:9a:02:d2:39:74:98:71:7f:a4:77:52:
|
||||
3a:ed:22:2e:99:9c:81:2c:48:16:3c:82:7b:af:2c:
|
||||
0d:4b:28:4d:e0:46:7d:b5:b8:ea:3f:e7:5a:5b:4f:
|
||||
d8:06:b2:a3:86:2f:8b:5b:9c:bc:04:2e:64:b6:e1:
|
||||
09:c9:14:6d:54:7e:86:40:7b:66:33:27:33:4a:3d:
|
||||
7c:97
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Subject Key Identifier:
|
||||
EF:9B:88:5C:07:27:79:EA:60:90:5C:7A:28:45:FB:7F:35:E6:CB:3F
|
||||
X509v3 Authority Key Identifier:
|
||||
keyid:EF:9B:88:5C:07:27:79:EA:60:90:5C:7A:28:45:FB:7F:35:E6:CB:3F
|
||||
|
||||
X509v3 Basic Constraints:
|
||||
CA:TRUE
|
||||
Signature Algorithm: sha1WithRSAEncryption
|
||||
08:e9:a4:32:cc:35:7c:66:5a:ea:f2:bd:e6:75:78:81:52:11:
|
||||
22:27:32:c9:ec:91:6e:51:8a:f1:1e:0f:25:8a:e1:64:ba:e4:
|
||||
85:1c:e4:fd:75:f0:26:3d:65:62:16:29:20:4f:5f:d2:66:36:
|
||||
de:2b:bd:7b:96:71:f6:2c:d1:c5:54:69:89:dd:52:20:49:49:
|
||||
b1:ac:09:b4:1e:33:59:0d:89:fd:a4:28:7a:70:96:e5:cb:58:
|
||||
7e:b9:1d:02:7a:33:ee:ad:6a:ad:2c:3c:5e:7d:cc:f5:72:69:
|
||||
51:fd:77:b4:0f:10:fd:9e:c2:1a:04:c5:a9:56:6e:fd:66:9f:
|
||||
b6:1c:f9:d3:68:f4:4f:8c:6c:67:af:f5:e0:a5:30:67:a6:a7:
|
||||
9b:6e:16:89:8a:e5:b4:20:f4:f7:74:f4:9c:ca:5d:c7:2f:e6:
|
||||
30:9d:6b:2e:95:29:c1:e7:aa:d7:d6:59:dc:a9:f0:10:40:02:
|
||||
66:3f:58:a2:38:8c:89:1a:0b:94:1a:e5:80:49:14:44:f4:06:
|
||||
b1:11:1a:cd:ef:76:6a:bf:f8:6f:58:9d:af:a3:6b:9a:8e:bb:
|
||||
6c:10:d6:d8:4e:73:58:20:0b:99:38:41:d4:22:d4:80:0b:09:
|
||||
0d:25:40:3e:66:15:a0:44:4e:d6:59:5a:58:07:e5:4b:62:f1:
|
||||
e9:ae:b6:7c
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDrzCCApegAwIBAgIJAOR8RcQlISHJMA0GCSqGSIb3DQEBBQUAMG4xCzAJBgNV
|
||||
BAYTAkNaMREwDwYDVQQIDAhWeXNvY2luYTEUMBIGA1UECgwLYnVrb3ZhLmluZm8x
|
||||
FDASBgNVBAMMC0pvc2VmIFJva29zMSAwHgYJKoZIhvcNAQkBFhFyb2tvc0BidWtv
|
||||
dmEuaW5mbzAeFw0xNTA2MjQwOTU5NTBaFw0yNTA2MjEwOTU5NTBaMG4xCzAJBgNV
|
||||
BAYTAkNaMREwDwYDVQQIDAhWeXNvY2luYTEUMBIGA1UECgwLYnVrb3ZhLmluZm8x
|
||||
FDASBgNVBAMMC0pvc2VmIFJva29zMSAwHgYJKoZIhvcNAQkBFhFyb2tvc0BidWtv
|
||||
dmEuaW5mbzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALz7ZFBbWAOM
|
||||
IBx301AxlFV41gW7vIidyyCxjP+s/JcasZwpxKyv7Tvek9XPdT7QBUEyvxIlU2Ao
|
||||
r/8+PDpMUng/sni5xi/8DkTrZcN/OCuriDeMaFVp4z1em5klEVUGq+jB+lTaW+eb
|
||||
Pj85T8+zy0jPlgKJC34kxwDpzo3qB88h8olRyMx6BORobxyo4HYYQGLuL70TZLce
|
||||
Lhi7sdQX1fsfB1llRvDEUdysYv8xqHImphqINyOCSZoC0jl0mHF/pHdSOu0iLpmc
|
||||
gSxIFjyCe68sDUsoTeBGfbW46j/nWltP2Aayo4Yvi1ucvAQuZLbhCckUbVR+hkB7
|
||||
ZjMnM0o9fJcCAwEAAaNQME4wHQYDVR0OBBYEFO+biFwHJ3nqYJBceihF+3815ss/
|
||||
MB8GA1UdIwQYMBaAFO+biFwHJ3nqYJBceihF+3815ss/MAwGA1UdEwQFMAMBAf8w
|
||||
DQYJKoZIhvcNAQEFBQADggEBAAjppDLMNXxmWuryveZ1eIFSESInMsnskW5RivEe
|
||||
DyWK4WS65IUc5P118CY9ZWIWKSBPX9JmNt4rvXuWcfYs0cVUaYndUiBJSbGsCbQe
|
||||
M1kNif2kKHpwluXLWH65HQJ6M+6taq0sPF59zPVyaVH9d7QPEP2ewhoExalWbv1m
|
||||
n7Yc+dNo9E+MbGev9eClMGemp5tuFomK5bQg9Pd09JzKXccv5jCday6VKcHnqtfW
|
||||
Wdyp8BBAAmY/WKI4jIkaC5Qa5YBJFET0BrERGs3vdmq/+G9Yna+ja5qOu2wQ1thO
|
||||
c1ggC5k4QdQi1IALCQ0lQD5mFaBETtZZWlgH5Uti8emutnw=
|
||||
-----END CERTIFICATE-----
|
@ -1,135 +1,57 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
|
||||
public class DateTimeUtils {
|
||||
public static Date getDate(Date value) {
|
||||
if (value == null) {
|
||||
return value;
|
||||
}
|
||||
|
||||
// Keep date - truncate time
|
||||
return DateUtils.truncate(value, Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
public static int getYear(Date value) {
|
||||
if (value == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Calendar cal =Calendar.getInstance();
|
||||
cal.setTime(value);
|
||||
return cal.get(Calendar.YEAR);
|
||||
}
|
||||
|
||||
public static boolean isEqualByDate(Date d1, Date d2) {
|
||||
if (d1 != null && d2 != null) {
|
||||
d1 = DateTimeUtils.getDate(d1);
|
||||
d2 = DateTimeUtils.getDate(d2);
|
||||
boolean equals = (d1.compareTo(d2) == 0);
|
||||
return equals;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEqualByYear(Date d1, Date d2) {
|
||||
if (d1 != null && d2 != null) {
|
||||
int year1 = DateTimeUtils.getYear(d1);
|
||||
int year2 = DateTimeUtils.getYear(d2);
|
||||
boolean equals = (year1 == year2);
|
||||
return equals;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public static boolean isEqualByDateForFilter(Date value, Date search) {
|
||||
if (search == null) {
|
||||
return true;
|
||||
} else if (value != null) {
|
||||
return DateTimeUtils.isEqualByDate(value, search);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getFormatedDate(Date value) {
|
||||
if (value == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(StringUtils.localize("DateFormat"));
|
||||
String result = sdf.format(value);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getFormatedDirDate(Date value) {
|
||||
if (value == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||||
String result = sdf.format(value);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getFormatedDirDateDDMM(Date value) {
|
||||
if (value == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("MMdd");
|
||||
String result = sdf.format(value);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getFormatedYear(Date value) {
|
||||
if (value == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
|
||||
String result = sdf.format(value);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Date getCurrDateTime() {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
public static Date getCurrDate() {
|
||||
return DateTimeUtils.getDate(DateTimeUtils.getCurrDateTime());
|
||||
}
|
||||
|
||||
public static Calendar getCalendarDelta(Date value, int calendarType, int delta) {
|
||||
if (value == null) {
|
||||
value = DateTimeUtils.getCurrDate();
|
||||
}
|
||||
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(value);
|
||||
int deltaValue = calendar.get(calendarType);
|
||||
calendar.set(calendarType, deltaValue + delta);
|
||||
return calendar;
|
||||
}
|
||||
|
||||
public static Calendar getCalendar(Date value) {
|
||||
if (value == null) {
|
||||
value = DateTimeUtils.getCurrDate();
|
||||
}
|
||||
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(value);
|
||||
return calendar;
|
||||
}
|
||||
|
||||
public static Date getDateDelta(Date value, int calendarType, int delta) {
|
||||
Calendar calendar = DateTimeUtils.getCalendarDelta(value, calendarType, delta);
|
||||
return calendar.getTime();
|
||||
}
|
||||
public class DateTimeUtils
|
||||
{
|
||||
public static Date getDate(Date value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
// Keep date - truncate time
|
||||
return DateUtils.truncate(value, Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
public static boolean isEqualByDate(Date d1, Date d2)
|
||||
{
|
||||
if (d1 != null && d2 != null)
|
||||
{
|
||||
d1 = DateTimeUtils.getDate(d1);
|
||||
d2 = DateTimeUtils.getDate(d2);
|
||||
boolean equals = (d1.compareTo(d2) == 0);
|
||||
return equals;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEqualByDateForFilter(Date value, Date search)
|
||||
{
|
||||
if (search == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (value != null)
|
||||
{
|
||||
return DateTimeUtils.isEqualByDate(value, search);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Date getCurrDateTime()
|
||||
{
|
||||
return new Date();
|
||||
}
|
||||
|
||||
public static Date getCurrDate()
|
||||
{
|
||||
return DateTimeUtils.getDate(DateTimeUtils.getCurrDateTime());
|
||||
}
|
||||
}
|
||||
|
@ -1,31 +0,0 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class RegExUtils {
|
||||
public static List<String> getMatches(String input, String regEx, int group) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(input) && !StringUtils.isNullOrEmpty(regEx)) {
|
||||
Pattern pattern = Pattern.compile(regEx);
|
||||
Matcher matcher = pattern.matcher(input);
|
||||
int groupCount = matcher.groupCount() + 1;
|
||||
|
||||
if ((groupCount >= 0) && (group < groupCount)) {
|
||||
while (matcher.find()) {
|
||||
String item = matcher.group(group);
|
||||
list.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<String> getMatches(String input, String regEx) {
|
||||
return RegExUtils.getMatches(input, regEx, 0);
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class SpringUtils {
|
||||
|
||||
private static WebApplicationContext webCtx(ServletContext sc) {
|
||||
return WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
|
||||
}
|
||||
|
||||
public static Object getBean(String name, ServletContext sc) {
|
||||
return webCtx(sc).getBean(name);
|
||||
}
|
||||
|
||||
public static <T> T getBean(Class<T> clazz, ServletContext sc) {
|
||||
return webCtx(sc).getBean(clazz);
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package info.bukova.isspst.dao;
|
||||
|
||||
import info.bukova.isspst.data.Limit;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public interface LimitDao extends BaseDao<Limit> {
|
||||
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package info.bukova.isspst.dao;
|
||||
|
||||
import info.bukova.isspst.data.Season;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public interface SeasonDao extends BaseDao<Season> {
|
||||
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package info.bukova.isspst.dao;
|
||||
|
||||
import info.bukova.isspst.data.SignedDocument;
|
||||
|
||||
public interface SignedDocumentDao extends BaseDao<SignedDocument> {
|
||||
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package info.bukova.isspst.dao.jpa;
|
||||
|
||||
import info.bukova.isspst.dao.LimitDao;
|
||||
import info.bukova.isspst.data.Limit;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class LimitDaoJPA extends BaseDaoJPA<Limit> implements LimitDao {
|
||||
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package info.bukova.isspst.dao.jpa;
|
||||
|
||||
import info.bukova.isspst.dao.SeasonDao;
|
||||
import info.bukova.isspst.data.Season;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class SeasonDaoJPA extends BaseDaoJPA<Season> implements SeasonDao {
|
||||
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package info.bukova.isspst.dao.jpa;
|
||||
|
||||
import info.bukova.isspst.dao.SignedDocumentDao;
|
||||
import info.bukova.isspst.data.SignedDocument;
|
||||
|
||||
public class SignedDocumentDaoJPA extends BaseDaoJPA<SignedDocument> implements SignedDocumentDao {
|
||||
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "LIMITS")
|
||||
public class Limit extends BaseData implements SeasonsAware {
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "WORKGROUP_ID")
|
||||
private Workgroup workgroup;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "SEASON_ID")
|
||||
private Season season;
|
||||
@Column(name = "REQ_LIMIT", precision = 15, scale = 4)
|
||||
private BigDecimal limit;
|
||||
|
||||
public Workgroup getWorkgroup() {
|
||||
return workgroup;
|
||||
}
|
||||
|
||||
public void setWorkgroup(Workgroup workgroup) {
|
||||
this.workgroup = workgroup;
|
||||
}
|
||||
|
||||
public Season getSeason() {
|
||||
return season;
|
||||
}
|
||||
|
||||
public void setSeason(Season season) {
|
||||
this.season = season;
|
||||
}
|
||||
|
||||
public BigDecimal getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public void setLimit(BigDecimal limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "SEASON")
|
||||
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
public class Season extends BaseData {
|
||||
@Column(name = "DESCRIPTION")
|
||||
private String description;
|
||||
@Column(name = "VALID_FROM")
|
||||
private Date validFrom;
|
||||
@Column(name = "VALID_TO")
|
||||
private Date validTo;
|
||||
@Column(name = "ACTIVE")
|
||||
private boolean active;
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Season)) return false;
|
||||
|
||||
Season season = (Season) o;
|
||||
|
||||
if (getId() != season.getId()) return false;
|
||||
if (active != season.active) return false;
|
||||
if (description != null ? !description.equals(season.description) : season.description != null) return false;
|
||||
if (validFrom != null ? !validFrom.equals(season.validFrom) : season.validFrom != null) return false;
|
||||
if (validTo != null ? !validTo.equals(season.validTo) : season.validTo != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = description != null ? description.hashCode() : 0;
|
||||
result = 31 * result + (validFrom != null ? validFrom.hashCode() : 0);
|
||||
result = 31 * result + (validTo != null ? validTo.hashCode() : 0);
|
||||
result = 31 * result + (active ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Date getValidFrom() {
|
||||
return validFrom;
|
||||
}
|
||||
|
||||
public void setValidFrom(Date validFrom) {
|
||||
this.validFrom = validFrom;
|
||||
}
|
||||
|
||||
public Date getValidTo() {
|
||||
return validTo;
|
||||
}
|
||||
|
||||
public void setValidTo(Date validTo) {
|
||||
this.validTo = validTo;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public interface SeasonsAware {
|
||||
public Season getSeason();
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import info.bukova.isspst.Constants;
|
||||
import info.bukova.isspst.Module;
|
||||
import info.bukova.isspst.StringUtils;
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "SIGNED_DOCUMENTS")
|
||||
public class SignedDocument extends BaseData {
|
||||
|
||||
@Transient
|
||||
private String agendaName;
|
||||
|
||||
@Column(name = "MODULE_NAME", length = Constants.LEN_TEXT)
|
||||
private String moduleName;
|
||||
|
||||
@Column(name = "RECORD_ID")
|
||||
private int recordId;
|
||||
|
||||
@Column(name = "NUMSER", length = Constants.LEN_TEXT)
|
||||
private String numser;
|
||||
|
||||
@Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION)
|
||||
private String description;
|
||||
|
||||
@Column(name = "SIGN_DATE")
|
||||
private Date signDate;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "signedDocument", orphanRemoval = true)
|
||||
@LazyCollection(LazyCollectionOption.TRUE)
|
||||
@IndexedEmbedded
|
||||
private List<SignedDocumentItem> items;
|
||||
|
||||
public SignedDocument() {
|
||||
}
|
||||
|
||||
public String getModuleName() {
|
||||
return moduleName;
|
||||
}
|
||||
|
||||
public void setModuleName(String moduleName) {
|
||||
this.moduleName = moduleName;
|
||||
}
|
||||
|
||||
public int getRecordId() {
|
||||
return recordId;
|
||||
}
|
||||
|
||||
public void setRecordId(int recordId) {
|
||||
this.recordId = recordId;
|
||||
}
|
||||
|
||||
public String getNumser() {
|
||||
return numser;
|
||||
}
|
||||
|
||||
public void setNumser(String numser) {
|
||||
this.numser = numser;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Date getSignDate() {
|
||||
return signDate;
|
||||
}
|
||||
|
||||
public void setSignDate(Date signDate) {
|
||||
this.signDate = signDate;
|
||||
}
|
||||
|
||||
public String getAgendaName() {
|
||||
if (!StringUtils.isNullOrEmpty(this.agendaName)) {
|
||||
return this.agendaName;
|
||||
}
|
||||
|
||||
if (StringUtils.isNullOrEmpty(this.moduleName)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
for (Module m : Constants.MODULES) {
|
||||
if (this.moduleName.equals(m.getId())) {
|
||||
return m.getName();
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setAgendaName(String agendaName) {
|
||||
this.agendaName = agendaName;
|
||||
}
|
||||
|
||||
public List<SignedDocumentItem> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(List<SignedDocumentItem> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public void addItem(SignedDocumentItem item) {
|
||||
if (items == null) {
|
||||
items = new ArrayList<SignedDocumentItem>();
|
||||
}
|
||||
|
||||
item.setSignedDocument(this);
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import info.bukova.isspst.Constants;
|
||||
import info.bukova.isspst.reporting.Report;
|
||||
import info.bukova.isspst.reporting.ReportMapping;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "SIGNED_DOCUMENTS_ITEMS")
|
||||
public class SignedDocumentItem {
|
||||
|
||||
@Id
|
||||
@Column(name = "ID")
|
||||
@GeneratedValue
|
||||
private int id;
|
||||
|
||||
@Column(name = "REPORT_ID")
|
||||
private long reportId;
|
||||
|
||||
@Column(name = "REPORT_NAME", length = Constants.LEN_TEXT)
|
||||
private String reportName;
|
||||
|
||||
@Column(name = "FILENAME", length = Constants.LEN_TEXT)
|
||||
private String fileName;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "SIGNED_DOCUMENT_ID")
|
||||
private SignedDocument signedDocument;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public long getReportId() {
|
||||
return reportId;
|
||||
}
|
||||
|
||||
public void setReportId(long reportId) {
|
||||
this.reportId = reportId;
|
||||
}
|
||||
|
||||
public String getReportName() {
|
||||
return reportName;
|
||||
}
|
||||
|
||||
public void setReportName(String reportName) {
|
||||
this.reportName = reportName;
|
||||
}
|
||||
|
||||
public String getActualReportName() {
|
||||
for (ReportMapping rm : Constants.REPORTS) {
|
||||
Report rep = rm.getReport();
|
||||
|
||||
if (this.reportId == rep.getReportId()) {
|
||||
return rep.getName();
|
||||
}
|
||||
}
|
||||
|
||||
return reportName;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public SignedDocument getSignedDocument() {
|
||||
return signedDocument;
|
||||
}
|
||||
|
||||
public void setSignedDocument(SignedDocument signedDocument) {
|
||||
this.signedDocument = signedDocument;
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
package info.bukova.isspst.filters;
|
||||
|
||||
import info.bukova.isspst.DateTimeUtils;
|
||||
import info.bukova.isspst.StringUtils;
|
||||
import info.bukova.isspst.data.SignedDocument;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Factory;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
|
||||
public class SignedDocumentFilter implements Filter<SignedDocument>
|
||||
{
|
||||
private SignedDocument condition;
|
||||
|
||||
public SignedDocumentFilter(SignedDocument cond)
|
||||
{
|
||||
this.condition = cond;
|
||||
}
|
||||
|
||||
private static class SignedDocumentMatcher extends TypeSafeMatcher<SignedDocument>
|
||||
{
|
||||
private SignedDocument condition;
|
||||
|
||||
public SignedDocumentMatcher(SignedDocument cond)
|
||||
{
|
||||
this.condition = cond;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description desc)
|
||||
{
|
||||
desc.appendText("SignedDocument matches");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(SignedDocument item)
|
||||
{
|
||||
boolean foundAgendaName = StringUtils.isEqualForFilter(item.getAgendaName(), condition.getAgendaName());
|
||||
boolean foundNumSer = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser());
|
||||
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
|
||||
boolean foundSignDate = DateTimeUtils.isEqualByDateForFilter(item.getSignDate(), condition.getSignDate());
|
||||
return (foundAgendaName && foundNumSer && foundDescription && foundSignDate);
|
||||
}
|
||||
|
||||
@Factory
|
||||
public static Matcher<SignedDocument> matchBuilding(SignedDocument item)
|
||||
{
|
||||
return new SignedDocumentMatcher(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SignedDocumentMatcher matcher()
|
||||
{
|
||||
return new SignedDocumentMatcher(condition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryString()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
package info.bukova.isspst.filters;
|
||||
|
||||
import info.bukova.isspst.BooleanUtils;
|
||||
import info.bukova.isspst.DateTimeUtils;
|
||||
import info.bukova.isspst.StringUtils;
|
||||
import info.bukova.isspst.data.TripBillApproval;
|
||||
import info.bukova.isspst.data.User;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Factory;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
|
||||
public class TripBillApprovalFilter implements Filter<TripBillApproval>
|
||||
{
|
||||
|
||||
private TripBillApproval condition;
|
||||
|
||||
public TripBillApprovalFilter(TripBillApproval cond)
|
||||
{
|
||||
this.condition = cond;
|
||||
}
|
||||
|
||||
private static class TripBillApprovalMatcher extends TypeSafeMatcher<TripBillApproval>
|
||||
{
|
||||
|
||||
private TripBillApproval condition;
|
||||
|
||||
public TripBillApprovalMatcher(TripBillApproval cond)
|
||||
{
|
||||
this.condition = cond;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description desc)
|
||||
{
|
||||
desc.appendText("requirement matches");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(TripBillApproval item)
|
||||
{
|
||||
if (item.getBill() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean foundNumser = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser());
|
||||
boolean foundReqDate = DateTimeUtils.isEqualByDateForFilter(item.getBill().getRequirement().getReqDate(), condition.getBill().getRequirement().getReqDate());
|
||||
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
|
||||
boolean foundFrom = StringUtils.isEqualForFilter(item.getBill().getRequirement().getFrom(), condition.getBill().getRequirement().getFrom());
|
||||
boolean foundTo = StringUtils.isEqualForFilter(item.getBill().getRequirement().getTo(), condition.getBill().getRequirement().getTo());
|
||||
boolean foundWorkgroup = (condition.getWorkgroup() == null ||(item.getWorkgroup() != null && item.getWorkgroup().equals(condition.getWorkgroup())));
|
||||
boolean foundCentre = (condition.getCentre() == null || (item.getCentre() != null && item.getCentre().equals(condition.getCentre())));
|
||||
boolean foundOwner = User.isEqualByUserForFilter(item.getBill().getOwnedBy(), condition.getBill().getOwnedBy());
|
||||
boolean foundPaid = BooleanUtils.isEqualByBooleanValue(item.getBill().getPaid(), condition.getBill().getPaid());
|
||||
boolean foundPaidDate = DateTimeUtils.isEqualByDateForFilter(item.getBill().getPaidDate(), condition.getBill().getPaidDate());
|
||||
boolean foundPassenger = (item.getBill().getOwnedBy() != item.getBill().getRequirement().getOwnedBy()) == condition.isBillForPassenger();
|
||||
boolean foundApproveDate = DateTimeUtils.isEqualByDateForFilter(item.getApproveDate(), condition.getApproveDate());
|
||||
boolean foundTripDate = DateTimeUtils.isEqualByDateForFilter(item.getBill().getRequirement().getTripDate(), condition.getTripDate());
|
||||
return foundNumser && foundReqDate && foundDescription && foundFrom && foundTo && foundWorkgroup && foundCentre && foundOwner && foundPaid
|
||||
&& foundPaidDate && foundPassenger && foundApproveDate && foundTripDate;
|
||||
}
|
||||
|
||||
@Factory
|
||||
public static Matcher<TripBillApproval> matchTripRequirement(TripBillApproval building)
|
||||
{
|
||||
return new TripBillApprovalMatcher(building);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TripBillApprovalMatcher matcher()
|
||||
{
|
||||
return new TripBillApprovalMatcher(condition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryString()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package info.bukova.isspst.reporting;
|
||||
|
||||
import com.lowagie.text.Rectangle;
|
||||
import com.lowagie.text.pdf.PdfFormField;
|
||||
import com.lowagie.text.pdf.PdfName;
|
||||
import net.sf.jasperreports.engine.JRGenericPrintElement;
|
||||
import net.sf.jasperreports.engine.JRPropertiesMap;
|
||||
import net.sf.jasperreports.engine.export.GenericElementHandler;
|
||||
import net.sf.jasperreports.engine.export.GenericElementHandlerBundle;
|
||||
import net.sf.jasperreports.engine.export.GenericElementPdfHandler;
|
||||
import net.sf.jasperreports.engine.export.JRPdfExporter;
|
||||
import net.sf.jasperreports.engine.export.JRPdfExporterContext;
|
||||
import net.sf.jasperreports.extensions.ExtensionsRegistry;
|
||||
import net.sf.jasperreports.extensions.ExtensionsRegistryFactory;
|
||||
import net.sf.jasperreports.extensions.SingletonExtensionRegistry;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class SignaturePdfHandler implements GenericElementPdfHandler, GenericElementHandlerBundle, ExtensionsRegistryFactory {
|
||||
|
||||
@Override
|
||||
public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) {
|
||||
return new SingletonExtensionRegistry<GenericElementHandlerBundle>(GenericElementHandlerBundle.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportElement(JRPdfExporterContext exporterContext, JRGenericPrintElement element) {
|
||||
//PdfFormField field = PdfFormField.createSignature(exporterContext.getPdfWriter());
|
||||
PdfFormField field = PdfFormField.createTextField(exporterContext.getPdfWriter(), true, false, 255);
|
||||
Object param = element.getParameterValue("index");
|
||||
String index = param != null ? String.valueOf(param) : null;
|
||||
|
||||
if (index != null) {
|
||||
field.setFieldName("signature-" + index);
|
||||
} else {
|
||||
field.setFieldName("signature");
|
||||
}
|
||||
|
||||
field.put(PdfName.V, exporterContext.getPdfWriter().getPdfIndirectReference());
|
||||
field.setFieldFlags(PdfFormField.FF_READ_ONLY);
|
||||
|
||||
field.setWidget(new Rectangle(element.getX(),
|
||||
exporterContext.getExportedReport().getPageHeight() - element.getY(),
|
||||
element.getX() + element.getWidth(),
|
||||
exporterContext.getExportedReport().getPageHeight() - element.getY() - element.getHeight()), PdfName.HIGHLIGHT);
|
||||
exporterContext.getPdfWriter().addAnnotation(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toExport(JRGenericPrintElement element) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return "urn:sig:sig";
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericElementHandler getHandler(String elementName, String exporterKey) {
|
||||
if (elementName.equals("signature") && exporterKey.equals(JRPdfExporter.PDF_EXPORTER_KEY)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,306 +0,0 @@
|
||||
package info.bukova.isspst.security;
|
||||
|
||||
import org.springframework.ldap.core.DirContextOperations;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
import org.springframework.security.authentication.AccountExpiredException;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.CredentialsExpiredException;
|
||||
import org.springframework.security.authentication.DisabledException;
|
||||
import org.springframework.security.authentication.LockedException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.AuthorityUtils;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.ldap.SpringSecurityLdapTemplate;
|
||||
import org.springframework.security.ldap.authentication.AbstractLdapAuthenticationProvider;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.naming.AuthenticationException;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.OperationNotSupportedException;
|
||||
import javax.naming.directory.DirContext;
|
||||
import javax.naming.directory.SearchControls;
|
||||
import javax.naming.ldap.InitialLdapContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Hashtable;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class AdAuthenticationProvider extends AbstractLdapAuthenticationProvider{
|
||||
private static final Pattern SUB_ERROR_CODE = Pattern.compile(".*data\\s([0-9a-f]{3,4}).*");
|
||||
|
||||
// Error codes
|
||||
private static final int USERNAME_NOT_FOUND = 0x525;
|
||||
private static final int INVALID_PASSWORD = 0x52e;
|
||||
private static final int NOT_PERMITTED = 0x530;
|
||||
private static final int PASSWORD_EXPIRED = 0x532;
|
||||
private static final int ACCOUNT_DISABLED = 0x533;
|
||||
private static final int ACCOUNT_EXPIRED = 0x701;
|
||||
private static final int PASSWORD_NEEDS_RESET = 0x773;
|
||||
private static final int ACCOUNT_LOCKED = 0x775;
|
||||
|
||||
private final String domain;
|
||||
private final String rootDn;
|
||||
private final String url;
|
||||
private final String upnSuffix;
|
||||
private boolean convertSubErrorCodesToExceptions;
|
||||
|
||||
// Only used to allow tests to substitute a mock LdapContext
|
||||
ContextFactory contextFactory = new ContextFactory();
|
||||
|
||||
/**
|
||||
* @param domain the domain for which authentication should take place
|
||||
*/
|
||||
// public ActiveDirectoryLdapAuthenticationProvider(String domain) {
|
||||
// this (domain, null);
|
||||
// }
|
||||
|
||||
/**
|
||||
* @param domain the domain name (may be null or empty)
|
||||
* @param url an LDAP url (or multiple URLs)
|
||||
*/
|
||||
public AdAuthenticationProvider(String domain, String upnSuffix, String url) {
|
||||
Assert.isTrue(StringUtils.hasText(url), "Url cannot be empty");
|
||||
this.domain = StringUtils.hasText(domain) ? domain.toLowerCase() : null;
|
||||
//this.url = StringUtils.hasText(url) ? url : null;
|
||||
this.url = url;
|
||||
this.upnSuffix = upnSuffix;
|
||||
rootDn = this.domain == null ? null : rootDnFromDomain(this.domain);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DirContextOperations doAuthentication(UsernamePasswordAuthenticationToken auth) {
|
||||
String username = auth.getName();
|
||||
String password = (String)auth.getCredentials();
|
||||
|
||||
DirContext ctx = bindAsUser(username, password);
|
||||
|
||||
try {
|
||||
return searchForUser(ctx, username);
|
||||
|
||||
} catch (NamingException e) {
|
||||
logger.error("Failed to locate directory entry for authenticated user: " + username, e);
|
||||
throw badCredentials();
|
||||
} finally {
|
||||
LdapUtils.closeContext(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the user authority list from the values of the {@code memberOf} attribute obtained from the user's
|
||||
* Active Directory entry.
|
||||
*/
|
||||
@Override
|
||||
protected Collection<? extends GrantedAuthority> loadUserAuthorities(DirContextOperations userData, String username, String password) {
|
||||
String[] groups = userData.getStringAttributes("memberOf");
|
||||
|
||||
if (groups == null) {
|
||||
logger.debug("No values for 'memberOf' attribute.");
|
||||
|
||||
return AuthorityUtils.NO_AUTHORITIES;
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("'memberOf' attribute values: " + Arrays.asList(groups));
|
||||
}
|
||||
|
||||
ArrayList<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(groups.length);
|
||||
|
||||
for (String group : groups) {
|
||||
authorities.add(new SimpleGrantedAuthority(new DistinguishedName(group).removeLast().getValue()));
|
||||
}
|
||||
|
||||
return authorities;
|
||||
}
|
||||
|
||||
private DirContext bindAsUser(String username, String password) {
|
||||
// TODO. add DNS lookup based on domain
|
||||
final String bindUrl = url;
|
||||
|
||||
Hashtable<String,String> env = new Hashtable<String,String>();
|
||||
env.put(Context.SECURITY_AUTHENTICATION, "simple");
|
||||
String bindPrincipal = createBindPrincipal(username);
|
||||
env.put(Context.SECURITY_PRINCIPAL, bindPrincipal);
|
||||
env.put(Context.PROVIDER_URL, bindUrl);
|
||||
env.put(Context.SECURITY_CREDENTIALS, password);
|
||||
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
|
||||
|
||||
try {
|
||||
return contextFactory.createContext(env);
|
||||
} catch (NamingException e) {
|
||||
if ((e instanceof AuthenticationException) || (e instanceof OperationNotSupportedException)) {
|
||||
handleBindException(bindPrincipal, e);
|
||||
throw badCredentials();
|
||||
} else {
|
||||
throw LdapUtils.convertLdapException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void handleBindException(String bindPrincipal, NamingException exception) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Authentication for " + bindPrincipal + " failed:" + exception);
|
||||
}
|
||||
|
||||
int subErrorCode = parseSubErrorCode(exception.getMessage());
|
||||
|
||||
if (subErrorCode > 0) {
|
||||
logger.info("Active Directory authentication failed: " + subCodeToLogMessage(subErrorCode));
|
||||
|
||||
if (convertSubErrorCodesToExceptions) {
|
||||
raiseExceptionForErrorCode(subErrorCode);
|
||||
}
|
||||
} else {
|
||||
logger.debug("Failed to locate AD-specific sub-error code in message");
|
||||
}
|
||||
}
|
||||
|
||||
int parseSubErrorCode(String message) {
|
||||
Matcher m = SUB_ERROR_CODE.matcher(message);
|
||||
|
||||
if (m.matches()) {
|
||||
return Integer.parseInt(m.group(1), 16);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void raiseExceptionForErrorCode(int code) {
|
||||
switch (code) {
|
||||
case PASSWORD_EXPIRED:
|
||||
throw new CredentialsExpiredException(messages.getMessage("LdapAuthenticationProvider.credentialsExpired",
|
||||
"User credentials have expired"));
|
||||
case ACCOUNT_DISABLED:
|
||||
throw new DisabledException(messages.getMessage("LdapAuthenticationProvider.disabled",
|
||||
"User is disabled"));
|
||||
case ACCOUNT_EXPIRED:
|
||||
throw new AccountExpiredException(messages.getMessage("LdapAuthenticationProvider.expired",
|
||||
"User account has expired"));
|
||||
case ACCOUNT_LOCKED:
|
||||
throw new LockedException(messages.getMessage("LdapAuthenticationProvider.locked",
|
||||
"User account is locked"));
|
||||
}
|
||||
}
|
||||
|
||||
String subCodeToLogMessage(int code) {
|
||||
switch (code) {
|
||||
case USERNAME_NOT_FOUND:
|
||||
return "User was not found in directory";
|
||||
case INVALID_PASSWORD:
|
||||
return "Supplied password was invalid";
|
||||
case NOT_PERMITTED:
|
||||
return "User not permitted to logon at this time";
|
||||
case PASSWORD_EXPIRED:
|
||||
return "Password has expired";
|
||||
case ACCOUNT_DISABLED:
|
||||
return "Account is disabled";
|
||||
case ACCOUNT_EXPIRED:
|
||||
return "Account expired";
|
||||
case PASSWORD_NEEDS_RESET:
|
||||
return "User must reset password";
|
||||
case ACCOUNT_LOCKED:
|
||||
return "Account locked";
|
||||
}
|
||||
|
||||
return "Unknown (error code " + Integer.toHexString(code) +")";
|
||||
}
|
||||
|
||||
private BadCredentialsException badCredentials() {
|
||||
return new BadCredentialsException(messages.getMessage(
|
||||
"LdapAuthenticationProvider.badCredentials", "Bad credentials"));
|
||||
}
|
||||
|
||||
private DirContextOperations searchForUser(DirContext ctx, String username) throws NamingException {
|
||||
SearchControls searchCtls = new SearchControls();
|
||||
searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
|
||||
|
||||
String searchFilter = "(&(objectClass=user)(userPrincipalName={0}))";
|
||||
|
||||
final String bindPrincipal = createBindPrincipal(username);
|
||||
final String searchDn = createSearchDn(username);
|
||||
|
||||
String searchRoot = rootDn != null ? rootDn : searchRootFromPrincipal(bindPrincipal);
|
||||
|
||||
DirContextOperations ctxOp;
|
||||
|
||||
try {
|
||||
ctxOp = SpringSecurityLdapTemplate.searchForSingleEntryInternal(ctx, searchCtls, searchRoot, searchFilter,
|
||||
new Object[]{searchDn});
|
||||
|
||||
if (ctxOp != null) {
|
||||
return ctxOp;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn("UPN " + searchDn + " not found. Falling back to search with domain UPN suffix.");
|
||||
}
|
||||
|
||||
return SpringSecurityLdapTemplate.searchForSingleEntryInternal(ctx, searchCtls, searchRoot, searchFilter,
|
||||
new Object[]{bindPrincipal});
|
||||
}
|
||||
|
||||
private String searchRootFromPrincipal(String bindPrincipal) {
|
||||
int atChar = bindPrincipal.lastIndexOf('@');
|
||||
|
||||
if (atChar < 0) {
|
||||
logger.debug("User principal '" + bindPrincipal + "' does not contain the domain, and no domain has been configured");
|
||||
throw badCredentials();
|
||||
}
|
||||
|
||||
return rootDnFromDomain(bindPrincipal.substring(atChar+ 1, bindPrincipal.length()));
|
||||
}
|
||||
|
||||
private String rootDnFromDomain(String domain) {
|
||||
String[] tokens = StringUtils.tokenizeToStringArray(domain, ".");
|
||||
StringBuilder root = new StringBuilder();
|
||||
|
||||
for (String token : tokens) {
|
||||
if (root.length() > 0) {
|
||||
root.append(',');
|
||||
}
|
||||
root.append("dc=").append(token);
|
||||
}
|
||||
|
||||
return root.toString();
|
||||
}
|
||||
|
||||
String createBindPrincipal(String username) {
|
||||
if (domain == null || username.toLowerCase().endsWith(domain)) {
|
||||
return username;
|
||||
}
|
||||
|
||||
return username + "@" + domain;
|
||||
}
|
||||
|
||||
String createSearchDn(String username) {
|
||||
if (upnSuffix == null) {
|
||||
return createBindPrincipal(username);
|
||||
}
|
||||
|
||||
return username + "@" + upnSuffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, a failed authentication (LDAP error 49) will result in a {@code BadCredentialsException}.
|
||||
* <p>
|
||||
* If this property is set to {@code true}, the exception message from a failed bind attempt will be parsed
|
||||
* for the AD-specific error code and a {@link CredentialsExpiredException}, {@link DisabledException},
|
||||
* {@link AccountExpiredException} or {@link LockedException} will be thrown for the corresponding codes. All
|
||||
* other codes will result in the default {@code BadCredentialsException}.
|
||||
*
|
||||
* @param convertSubErrorCodesToExceptions {@code true} to raise an exception based on the AD error code.
|
||||
*/
|
||||
public void setConvertSubErrorCodesToExceptions(boolean convertSubErrorCodesToExceptions) {
|
||||
this.convertSubErrorCodesToExceptions = convertSubErrorCodesToExceptions;
|
||||
}
|
||||
|
||||
static class ContextFactory {
|
||||
DirContext createContext(Hashtable<?,?> env) throws NamingException {
|
||||
return new InitialLdapContext(env, null);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
package info.bukova.isspst.services;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class HqlDataFilter {
|
||||
private String where;
|
||||
private String orderBy;
|
||||
private Map<String, Object> params;
|
||||
private Class<?> dataClass;
|
||||
|
||||
public HqlDataFilter() {
|
||||
params = new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public HqlDataFilter(String where) {
|
||||
this();
|
||||
this.where = where;
|
||||
}
|
||||
|
||||
public HqlDataFilter(String where, String orderBy) {
|
||||
this(where);
|
||||
this.orderBy = orderBy;
|
||||
}
|
||||
|
||||
public String getWhere() {
|
||||
return where;
|
||||
}
|
||||
|
||||
public void setWhere(String where) {
|
||||
this.where = where;
|
||||
}
|
||||
|
||||
public String getOrderBy() {
|
||||
return orderBy;
|
||||
}
|
||||
|
||||
public void setOrderBy(String orderBy) {
|
||||
this.orderBy = orderBy;
|
||||
}
|
||||
|
||||
public void setParam(String key, Object value) {
|
||||
params.put(key, value);
|
||||
}
|
||||
|
||||
public Object getParam(String key) {
|
||||
return params.get(key);
|
||||
}
|
||||
|
||||
public Set<String> getParamKeys() {
|
||||
return params.keySet();
|
||||
}
|
||||
|
||||
public void andFilter(String filter) {
|
||||
if (where == null || where.isEmpty()) {
|
||||
where = filter;
|
||||
} else {
|
||||
where += " and (" + filter + ")";
|
||||
}
|
||||
}
|
||||
|
||||
public void orFilter(String filter) {
|
||||
if (where == null ||where.isEmpty()) {
|
||||
where = filter;
|
||||
} else {
|
||||
where += " or (" + filter + ")";
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
where = "";
|
||||
orderBy = "";
|
||||
params.clear();
|
||||
}
|
||||
|
||||
public Class<?> getDataClass() {
|
||||
return dataClass;
|
||||
}
|
||||
|
||||
public void setDataClass(Class<?> dataClass) {
|
||||
this.dataClass = dataClass;
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
package info.bukova.isspst.services;
|
||||
|
||||
import org.hibernate.Query;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class HqlUtils {
|
||||
|
||||
public static String buildHql(String select, HqlDataFilter filter) {
|
||||
if (select.toLowerCase().contains("where")
|
||||
|| select.toLowerCase().contains("order by")) {
|
||||
throw new IsspstException("Use add*() methods instead.");
|
||||
}
|
||||
|
||||
String hql = addWhere(select, filter, "");
|
||||
return addOrderBy(hql, filter);
|
||||
}
|
||||
|
||||
public static String addAndWhere(String hql, HqlDataFilter filter) {
|
||||
if (!checkWhere(filter)) {
|
||||
return hql;
|
||||
}
|
||||
|
||||
return addWhere(hql, filter, "and");
|
||||
}
|
||||
|
||||
public static String addOrWhere(String hql, HqlDataFilter filter) {
|
||||
if (!checkWhere(filter)) {
|
||||
return hql;
|
||||
}
|
||||
|
||||
return addWhere(hql, filter, "or");
|
||||
}
|
||||
|
||||
public static String addOrderBy(String hql, HqlDataFilter filter) {
|
||||
if (filter == null || filter.getOrderBy() == null || filter.getOrderBy().isEmpty()) {
|
||||
return hql;
|
||||
}
|
||||
|
||||
if (!hql.contains("order by")) {
|
||||
hql += " order by ";
|
||||
}
|
||||
|
||||
hql += filter.getOrderBy();
|
||||
return hql;
|
||||
}
|
||||
|
||||
public static void addParameters(Query query, HqlDataFilter filter) {
|
||||
if (filter == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String key : filter.getParamKeys()) {
|
||||
if (filter.getParam(key) instanceof Collection<?>) {
|
||||
query.setParameterList(key, (Collection) filter.getParam(key));
|
||||
} else {
|
||||
query.setParameter(key, filter.getParam(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean checkWhere(HqlDataFilter filter) {
|
||||
return filter != null && filter.getWhere() != null && !filter.getWhere().isEmpty();
|
||||
}
|
||||
|
||||
private static String addWhere(String hql, HqlDataFilter filter, String operator) {
|
||||
if (hql.toLowerCase().contains("where") && hql.toLowerCase().contains("order by")) {
|
||||
String[] split = hql.split("order by");
|
||||
hql = split[0] + " " + operator + " (" + filter.getWhere() + ") order by " + split[1];
|
||||
return hql;
|
||||
}
|
||||
|
||||
if (hql.toLowerCase().contains("where")) {
|
||||
hql += " " + operator + " (" + filter.getWhere() + ")";
|
||||
return hql;
|
||||
}
|
||||
|
||||
if (hql.toLowerCase().contains("order by")) {
|
||||
String[] split = hql.split("order by");
|
||||
hql = split[0] + " where (" + filter.getWhere() + ") order by " + split[1];
|
||||
return hql;
|
||||
}
|
||||
|
||||
hql += " where (" + filter.getWhere() + ")";
|
||||
return hql;
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package info.bukova.isspst.services.limits;
|
||||
|
||||
import info.bukova.isspst.services.IsspstException;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class LimitException extends IsspstException {
|
||||
|
||||
public LimitException(String reason) {
|
||||
setReason(reason);
|
||||
}
|
||||
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package info.bukova.isspst.services.limits;
|
||||
|
||||
import info.bukova.isspst.data.Limit;
|
||||
import info.bukova.isspst.data.Season;
|
||||
import info.bukova.isspst.data.Workgroup;
|
||||
import info.bukova.isspst.services.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public interface LimitService extends Service<Limit> {
|
||||
List<Limit> getForSeason(Season season);
|
||||
Limit getForWorkgroupAndSeason(Workgroup wg, Season season);
|
||||
Limit getForWorkgroup(Workgroup wg);
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
package info.bukova.isspst.services.limits;
|
||||
|
||||
import info.bukova.isspst.data.Limit;
|
||||
import info.bukova.isspst.data.Season;
|
||||
import info.bukova.isspst.data.Workgroup;
|
||||
import info.bukova.isspst.services.AbstractOwnedService;
|
||||
import info.bukova.isspst.services.settings.SeasonService;
|
||||
import org.hibernate.Query;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class LimitServiceImpl extends AbstractOwnedService<Limit> implements LimitService {
|
||||
|
||||
@Autowired
|
||||
private SeasonService seasonService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public List<Limit> getForSeason(Season season) {
|
||||
Query q = dao.getQuery("from Limit where season = :season");
|
||||
q.setParameter("season", season);
|
||||
return q.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Limit getForWorkgroupAndSeason(Workgroup wg, Season season) {
|
||||
Query q = dao.getQuery("from Limit where workgroup = :wg and season = :season");
|
||||
q.setParameter("wg", wg);
|
||||
q.setParameter("season", season);
|
||||
return (Limit) q.uniqueResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Limit getForWorkgroup(Workgroup wg) {
|
||||
return getForWorkgroupAndSeason(wg, seasonService.getActive());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@PreAuthorize("hasPermission(this, 'PERM_ADD')")
|
||||
public void add(Limit entity) {
|
||||
if (getForWorkgroupAndSeason(entity.getWorkgroup(),entity.getSeason()) != null) {
|
||||
throw new LimitException("LimitExists");
|
||||
}
|
||||
super.add(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Limit createEntity() {
|
||||
Limit limit = new Limit();
|
||||
limit.setSeason(seasonService.getActive());
|
||||
return limit;
|
||||
}
|
||||
}
|
@ -1,18 +1,11 @@
|
||||
package info.bukova.isspst.services.numberseries;
|
||||
|
||||
import info.bukova.isspst.data.NumberSeries;
|
||||
import info.bukova.isspst.data.Season;
|
||||
import info.bukova.isspst.services.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface NumberSeriesService extends Service<NumberSeries>
|
||||
{
|
||||
public NumberSeries getNumberSerie(String module);
|
||||
|
||||
public NumberSeries getNumberSerieForSeason(String module, Season season);
|
||||
|
||||
public void increase(NumberSeries ns);
|
||||
|
||||
public List<NumberSeries> getSeriesForSeason(Season season);
|
||||
}
|
||||
|
@ -1,48 +1,24 @@
|
||||
package info.bukova.isspst.services.numberseries;
|
||||
|
||||
import info.bukova.isspst.data.NumberSeries;
|
||||
import info.bukova.isspst.data.Season;
|
||||
import info.bukova.isspst.services.AbstractService;
|
||||
|
||||
import info.bukova.isspst.services.settings.SeasonService;
|
||||
import org.hibernate.Query;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NumberSeriesServiceImpl extends AbstractService<NumberSeries> implements NumberSeriesService
|
||||
{
|
||||
@Autowired
|
||||
private SeasonService seasonService;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public NumberSeries getNumberSerie(String module) {
|
||||
return getNumberSerieForSeason(module, seasonService.getActive());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public NumberSeries getNumberSerieForSeason(String module, Season season) {
|
||||
Query q = dao.getQuery("from NumberSeries where module = :m and season = :s");
|
||||
q.setParameter("m", module);
|
||||
q.setParameter("s", season);
|
||||
return (NumberSeries) q.uniqueResult();
|
||||
public NumberSeries getNumberSerie(String module)
|
||||
{
|
||||
return this.selectSingle("from NumberSeries where MODULE = '" + module + "'");
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void increase(NumberSeries ns) {
|
||||
public void increase(NumberSeries ns)
|
||||
{
|
||||
ns.setNumber(ns.getNumber() + 1);
|
||||
this.update(ns);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public List<NumberSeries> getSeriesForSeason(Season season) {
|
||||
Query q = dao.getQuery("from NumberSeries where season = :s");
|
||||
q.setParameter("s", season);
|
||||
return q.list();
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +0,0 @@
|
||||
package info.bukova.isspst.services.settings;
|
||||
|
||||
import info.bukova.isspst.services.IsspstException;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class SeasonException extends IsspstException {
|
||||
|
||||
SeasonException() {
|
||||
super();
|
||||
}
|
||||
|
||||
SeasonException(String msg) {
|
||||
super(msg);
|
||||
setReason(msg);
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package info.bukova.isspst.services.settings;
|
||||
|
||||
import info.bukova.isspst.data.Season;
|
||||
import info.bukova.isspst.services.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public interface SeasonService extends Service<Season> {
|
||||
Season addSeason();
|
||||
Season getActive();
|
||||
List<Season> getAllSeasons();
|
||||
void setActive(Season season);
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
package info.bukova.isspst.services.settings;
|
||||
|
||||
import info.bukova.isspst.StringUtils;
|
||||
import info.bukova.isspst.data.NumberSeries;
|
||||
import info.bukova.isspst.data.Season;
|
||||
import info.bukova.isspst.services.AbstractOwnedService;
|
||||
import info.bukova.isspst.services.numberseries.NumberSeriesService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class SeasonServiceImpl extends AbstractOwnedService<Season> implements SeasonService {
|
||||
private Season activeSeason;
|
||||
@Autowired
|
||||
private NumberSeriesService numberSeriesService;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public Season addSeason() {
|
||||
Season season = new Season();
|
||||
season.setDescription(StringUtils.localize("SeasonsNewSeason"));
|
||||
season.setValidFrom(new Date());
|
||||
season.setActive(true);
|
||||
|
||||
Season last = selectSingle("from Season where validTo Is Null");
|
||||
add(season);
|
||||
|
||||
last.setValidTo(new Date());
|
||||
last.setActive(false);
|
||||
update(last);
|
||||
|
||||
|
||||
activeSeason = null;
|
||||
|
||||
List<NumberSeries> numSeries = numberSeriesService.getSeriesForSeason(last);
|
||||
for (NumberSeries ns: numSeries) {
|
||||
String txt = ns.getPrefix().replaceAll("[0-9]+", "");
|
||||
String numTxt = ns.getPrefix().replaceAll("[a-zA-Z]+", "");
|
||||
|
||||
int num = 0;
|
||||
try {
|
||||
num = Integer.valueOf(numTxt);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String newPrefix = txt + String.valueOf(num + 1);
|
||||
|
||||
NumberSeries newNumSer = new NumberSeries();
|
||||
newNumSer.setPrefix(newPrefix);
|
||||
newNumSer.setModule(ns.getModule());
|
||||
newNumSer.setNumber(1);
|
||||
newNumSer.setSeason(season);
|
||||
numberSeriesService.add(newNumSer);
|
||||
}
|
||||
return season;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public Season getActive() {
|
||||
if (activeSeason == null) {
|
||||
activeSeason = selectSingle("from Season where active = true");
|
||||
}
|
||||
|
||||
if (activeSeason == null) {
|
||||
throw new SeasonException("Active_season_not_set");
|
||||
}
|
||||
return activeSeason;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public List<Season> getAllSeasons() {
|
||||
return getAll();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void setActive(Season season) {
|
||||
for (Season s: getAll()) {
|
||||
s.setActive(false);
|
||||
update(s);
|
||||
}
|
||||
|
||||
Season s = dao.getById(season.getId());
|
||||
|
||||
if (s == null) {
|
||||
throw new SeasonException("Season_not_in_database");
|
||||
}
|
||||
|
||||
s.setActive(true);
|
||||
activeSeason = s;
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package info.bukova.isspst.services.signeddocs;
|
||||
|
||||
import info.bukova.isspst.data.DataModel;
|
||||
import info.bukova.isspst.data.Member;
|
||||
import info.bukova.isspst.data.SignedDocument;
|
||||
import info.bukova.isspst.data.SignedDocumentItem;
|
||||
import info.bukova.isspst.services.Service;
|
||||
import info.bukova.isspst.ui.signeddocs.SignedDocsTreeNode;
|
||||
import org.zkoss.zul.TreeModel;
|
||||
import org.zkoss.zul.TreeNode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SignedDocumentService extends Service<SignedDocument> {
|
||||
|
||||
SignedDocument getForEntity(DataModel entity);
|
||||
SignedDocumentItem getItem(DataModel entity, long reportId);
|
||||
void addFromApprove(SignedDocument document);
|
||||
void delFromApprove(SignedDocument document);
|
||||
void deleteForEntity(DataModel entity);
|
||||
|
||||
public List<SignedDocument> getActualList();
|
||||
public List<SignedDocument> getArchiveList();
|
||||
public TreeModel<TreeNode<SignedDocumentItem>> getTree();
|
||||
}
|
@ -1,242 +0,0 @@
|
||||
package info.bukova.isspst.services.signeddocs;
|
||||
|
||||
import info.bukova.isspst.DateTimeUtils;
|
||||
import info.bukova.isspst.Module;
|
||||
import info.bukova.isspst.ModuleUtils;
|
||||
import info.bukova.isspst.data.DataModel;
|
||||
import info.bukova.isspst.data.Member;
|
||||
import info.bukova.isspst.data.SignedDocument;
|
||||
import info.bukova.isspst.data.SignedDocumentItem;
|
||||
import info.bukova.isspst.services.AbstractOwnedService;
|
||||
import info.bukova.isspst.services.LazyLoader;
|
||||
import info.bukova.isspst.storage.ReportFileStorage;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import info.bukova.isspst.ui.signeddocs.SignedDocsTreeNode;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.Query;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.zkoss.zul.DefaultTreeModel;
|
||||
import org.zkoss.zul.DefaultTreeNode;
|
||||
import org.zkoss.zul.TreeModel;
|
||||
import org.zkoss.zul.TreeNode;
|
||||
|
||||
public class SignedDocumentServiceImpl extends AbstractOwnedService<SignedDocument> implements SignedDocumentService {
|
||||
|
||||
@Autowired
|
||||
private ServletContext servletContext;
|
||||
@Autowired
|
||||
private ReportFileStorage signedDocStorage;
|
||||
|
||||
@LazyLoader("grid")
|
||||
@Transactional
|
||||
public void lazyLoadItems(SignedDocument signedDocument) {
|
||||
if (signedDocument == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SignedDocument sd = dao.getById(signedDocument.getId());
|
||||
Hibernate.initialize(sd.getItems());
|
||||
signedDocument.setItems(sd.getItems());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public SignedDocument getForEntity(DataModel entity) {
|
||||
Module module = ModuleUtils.getModule(entity, servletContext);
|
||||
|
||||
if (module == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Query q = dao.getQuery("from SignedDocument where moduleName = :module and recordId = :record");
|
||||
q.setParameter("module", module.getId());
|
||||
q.setParameter("record", entity.getId());
|
||||
|
||||
return (SignedDocument) q.uniqueResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public SignedDocumentItem getItem(DataModel entity, long reportId) {
|
||||
SignedDocument doc = getForEntity(entity);
|
||||
|
||||
if (doc == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (SignedDocumentItem item : doc.getItems()) {
|
||||
if (item.getReportId() == reportId) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFromApprove(SignedDocument document) {
|
||||
super.add(document);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delFromApprove(SignedDocument document) {
|
||||
if (document == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.delete(document);
|
||||
|
||||
for (SignedDocumentItem item : document.getItems()) {
|
||||
signedDocStorage.removeFile(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteForEntity(DataModel entity) {
|
||||
SignedDocument doc = getForEntity(entity);
|
||||
if (doc != null) {
|
||||
delFromApprove(doc);
|
||||
}
|
||||
}
|
||||
|
||||
private Date getTresholdDate() {
|
||||
Date date = DateTimeUtils.getDateDelta(DateTimeUtils.getCurrDate(), Calendar.MONTH, -6);
|
||||
return date;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Transactional
|
||||
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
||||
public List<SignedDocument> getActualList() {
|
||||
Query q = dao.getQuery("from SignedDocument where signDate >= :refDate");
|
||||
q.setParameter("refDate", this.getTresholdDate());
|
||||
return q.list();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Transactional
|
||||
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
||||
public List<SignedDocument> getArchiveList() {
|
||||
Query q = dao.getQuery("from SignedDocument where signDate < :refDate");
|
||||
q.setParameter("refDate", this.getTresholdDate());
|
||||
return q.list();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Transactional
|
||||
@PreAuthorize("hasPermission(this, 'PERM_READ')")
|
||||
public TreeModel<TreeNode<SignedDocumentItem>> getTree() {
|
||||
Query q = queryDao.getQuery("select item "
|
||||
+ "from SignedDocumentItem as item left join item.signedDocument as rec "
|
||||
+ "order by rec.moduleName, rec.signDate desc, item.reportName, item.fileName "
|
||||
);
|
||||
List<SignedDocumentItem> list = q.list();
|
||||
|
||||
SignedDocumentItem lastItem = null;
|
||||
SignedDocument lastRec = null;
|
||||
List<SignedDocsTreeNode> agendaNameList = new LinkedList<SignedDocsTreeNode>();
|
||||
List<SignedDocsTreeNode> signYearList = new LinkedList<SignedDocsTreeNode>();
|
||||
List<SignedDocsTreeNode> signDateList = new LinkedList<SignedDocsTreeNode>();
|
||||
List<SignedDocsTreeNode> filesList = null;
|
||||
|
||||
int documentsCount = list.size() - 1;
|
||||
|
||||
for (int i = 0; i <= documentsCount; i++) {
|
||||
SignedDocumentItem item = list.get(i);
|
||||
SignedDocument rec = item.getSignedDocument();
|
||||
SignedDocsTreeNode itemNode = new SignedDocsTreeNode(item);
|
||||
|
||||
boolean isChangedAgendaName = ((i == 0)
|
||||
|| (i == documentsCount)
|
||||
|| !lastRec.getAgendaName().equals(rec.getAgendaName())
|
||||
);
|
||||
boolean isChangedSignYear = ((i == 0)
|
||||
|| (i == documentsCount)
|
||||
|| isChangedAgendaName
|
||||
|| !DateTimeUtils.isEqualByYear(lastRec.getSignDate(), rec.getSignDate())
|
||||
);
|
||||
boolean isChangedSignDate = ((i == 0)
|
||||
|| (i == documentsCount)
|
||||
|| isChangedSignYear
|
||||
|| !DateTimeUtils.isEqualByDate(lastRec.getSignDate(), rec.getSignDate())
|
||||
);
|
||||
|
||||
if (isChangedAgendaName || isChangedSignYear || isChangedSignDate) {
|
||||
|
||||
if (isChangedSignDate) {
|
||||
if (i > 0) {
|
||||
SignedDocsTreeNode signDateNode = new SignedDocsTreeNode((i == documentsCount ? item : lastItem), filesList);
|
||||
signDateList.add(signDateNode);
|
||||
}
|
||||
|
||||
filesList = new LinkedList<SignedDocsTreeNode>();
|
||||
filesList.add(itemNode);
|
||||
}
|
||||
|
||||
if (isChangedSignYear) {
|
||||
if (i > 0) {
|
||||
SignedDocsTreeNode signYearNode = new SignedDocsTreeNode((i == documentsCount ? item : lastItem), signDateList);
|
||||
signYearList.add(signYearNode);
|
||||
}
|
||||
|
||||
signDateList = new LinkedList<SignedDocsTreeNode>();
|
||||
}
|
||||
|
||||
if (isChangedAgendaName) {
|
||||
if (i > 0) {
|
||||
SignedDocsTreeNode agendaNode = new SignedDocsTreeNode((i == documentsCount ? item : lastItem), signYearList);
|
||||
agendaNameList.add(agendaNode);
|
||||
}
|
||||
|
||||
signYearList = new LinkedList<SignedDocsTreeNode>();
|
||||
}
|
||||
} else {
|
||||
filesList.add(itemNode);
|
||||
}
|
||||
|
||||
lastItem = item;
|
||||
lastRec = lastItem.getSignedDocument();
|
||||
}
|
||||
|
||||
Collections.sort(agendaNameList, new Comparator<SignedDocsTreeNode>() {
|
||||
@Override
|
||||
public int compare(SignedDocsTreeNode nodeL, SignedDocsTreeNode nodeR) {
|
||||
if ((nodeL != null) && (nodeR != null)) {
|
||||
SignedDocumentItem itemL = nodeL.getData();
|
||||
SignedDocumentItem itemR = nodeR.getData();
|
||||
|
||||
if ((itemL != null) && (itemR != null)) {
|
||||
SignedDocument recL = itemL.getSignedDocument();
|
||||
SignedDocument recR = itemR.getSignedDocument();
|
||||
|
||||
if ((recL != null) && (recR != null)) {
|
||||
String nameL = recL.getAgendaName();
|
||||
String nameR = recR.getAgendaName();
|
||||
|
||||
if ((nameL != null) && (nameR != null)) {
|
||||
return nameL.compareTo(nameR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
SignedDocsTreeNode root = new SignedDocsTreeNode(null, agendaNameList);
|
||||
TreeModel<TreeNode<SignedDocumentItem>> tree = new DefaultTreeModel<SignedDocumentItem>(root);
|
||||
return tree;
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package info.bukova.isspst.services.tripbill;
|
||||
|
||||
import info.bukova.isspst.services.IsspstException;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class PayException extends IsspstException {
|
||||
|
||||
public PayException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PayException(String message) {
|
||||
super(message);
|
||||
setReason(message);
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package info.bukova.isspst.signapi;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public interface JnlpGenerator {
|
||||
|
||||
public byte[] generate();
|
||||
|
||||
}
|
@ -1,121 +0,0 @@
|
||||
package info.bukova.isspst.signapi;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class JnlpGeneratorImpl implements JnlpGenerator {
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Override
|
||||
public byte[] generate() {
|
||||
String sessionId;
|
||||
|
||||
if (request.getParameter("id") != null && !request.getParameter("id").isEmpty()) {
|
||||
sessionId = request.getParameter("id");
|
||||
} else {
|
||||
sessionId = request.getSession().getId();
|
||||
}
|
||||
|
||||
try {
|
||||
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
||||
|
||||
Document document = docBuilder.newDocument();
|
||||
Element root = document.createElement("jnlp");
|
||||
root.setAttribute("spec", "1.0+");
|
||||
|
||||
String signerUrl = request.getRequestURL().toString();
|
||||
signerUrl = signerUrl.substring(0, signerUrl.indexOf(request.getServletPath())) + "/api/sign";
|
||||
|
||||
root.setAttribute("codebase", signerUrl);
|
||||
root.setAttribute("href", "signer.jnlp" + "?id=" + sessionId);
|
||||
document.appendChild(root);
|
||||
|
||||
Element info = document.createElement("information");
|
||||
Element title = document.createElement("title");
|
||||
title.appendChild(document.createTextNode("Signer component"));
|
||||
info.appendChild(title);
|
||||
Element vendor = document.createElement("vendor");
|
||||
vendor.appendChild(document.createTextNode("bukova.info"));
|
||||
info.appendChild(vendor);
|
||||
root.appendChild(info);
|
||||
|
||||
Element security = document.createElement("security");
|
||||
security.appendChild(document.createElement("all-permissions"));
|
||||
root.appendChild(security);
|
||||
|
||||
Element resources = document.createElement("resources");
|
||||
resources.setAttribute("os", "Linux");
|
||||
Element j2se = document.createElement("j2se");
|
||||
j2se.setAttribute("version", "1.8+");
|
||||
Element jar = document.createElement("jar");
|
||||
jar.setAttribute("href", "pdfsigner.jar");
|
||||
resources.appendChild(j2se);
|
||||
resources.appendChild(jar);
|
||||
root.appendChild(resources);
|
||||
|
||||
Element resourcesWin = document.createElement("resources");
|
||||
resourcesWin.setAttribute("os", "Windows");
|
||||
Element j2seWin = document.createElement("j2se");
|
||||
j2seWin.setAttribute("version", "1.8+");
|
||||
Element jarWin = document.createElement("jar");
|
||||
jarWin.setAttribute("href", "pdfsignerWin.jar");
|
||||
resourcesWin.appendChild(j2seWin);
|
||||
|
||||
resourcesWin.appendChild(jarWin);
|
||||
root.appendChild(resourcesWin);
|
||||
|
||||
Element appDesc = document.createElement("application-desc");
|
||||
appDesc.setAttribute("main-class", "info.bukova.pdfsigner.Main");
|
||||
Element argUrl = document.createElement("argument");
|
||||
argUrl.appendChild(document.createTextNode(signerUrl + "/data"));
|
||||
appDesc.appendChild(argUrl);
|
||||
Element argSession = document.createElement("argument");
|
||||
argSession.appendChild(document.createTextNode(sessionId));
|
||||
appDesc.appendChild(argSession);
|
||||
root.appendChild(appDesc);
|
||||
|
||||
|
||||
System.out.println(signerUrl);
|
||||
System.out.println(request.getSession().getId());
|
||||
|
||||
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||
Transformer transformer = transformerFactory.newTransformer();
|
||||
DOMSource source = new DOMSource(document);
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
StreamResult result = new StreamResult(bos);
|
||||
|
||||
transformer.transform(source, result);
|
||||
|
||||
return bos.toByteArray();
|
||||
|
||||
} catch (ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (TransformerConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (TransformerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
package info.bukova.isspst.signapi;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class SignData implements Serializable {
|
||||
|
||||
private byte[] pdfData;
|
||||
private byte[] signImg;
|
||||
private int areaId;
|
||||
private Date signDate;
|
||||
private String description;
|
||||
private String numser;
|
||||
private boolean signed;
|
||||
private String signGuid;
|
||||
private boolean signSuccess;
|
||||
|
||||
public byte[] getPdfData() {
|
||||
return pdfData;
|
||||
}
|
||||
|
||||
public void setPdfData(byte[] pdfData) {
|
||||
this.pdfData = pdfData;
|
||||
}
|
||||
|
||||
public Date getSignDate() {
|
||||
return signDate;
|
||||
}
|
||||
|
||||
public void setSignDate(Date signDate) {
|
||||
this.signDate = signDate;
|
||||
}
|
||||
|
||||
public String getNumser() {
|
||||
return numser;
|
||||
}
|
||||
|
||||
public void setNumser(String numser) {
|
||||
this.numser = numser;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public boolean isSigned() {
|
||||
return signed;
|
||||
}
|
||||
|
||||
public void setSigned(boolean signed) {
|
||||
this.signed = signed;
|
||||
}
|
||||
|
||||
public String getSignGuid() {
|
||||
return signGuid;
|
||||
}
|
||||
|
||||
public void setSignGuid(String signGuid) {
|
||||
this.signGuid = signGuid;
|
||||
}
|
||||
|
||||
public boolean isSignSuccess() {
|
||||
return signSuccess;
|
||||
}
|
||||
|
||||
public void setSignSuccess(boolean signSuccess) {
|
||||
this.signSuccess = signSuccess;
|
||||
}
|
||||
|
||||
public byte[] getSignImg() {
|
||||
return signImg;
|
||||
}
|
||||
|
||||
public void setSignImg(byte[] signImg) {
|
||||
this.signImg = signImg;
|
||||
}
|
||||
|
||||
public int getAreaId() {
|
||||
return areaId;
|
||||
}
|
||||
|
||||
public void setAreaId(int areaId) {
|
||||
this.areaId = areaId;
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package info.bukova.isspst.signapi;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class SignUploadResponse implements Serializable {
|
||||
|
||||
private boolean ok;
|
||||
private String errorMessage;
|
||||
|
||||
public boolean isOk() {
|
||||
return ok;
|
||||
}
|
||||
|
||||
public void setOk(boolean ok) {
|
||||
this.ok = ok;
|
||||
}
|
||||
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
public void setErrorMessage(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
}
|
@ -1,148 +0,0 @@
|
||||
package info.bukova.isspst.signapi;
|
||||
|
||||
import info.bukova.isspst.Constants;
|
||||
import info.bukova.isspst.SessionData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
|
||||
@Controller
|
||||
public class SigningController {
|
||||
|
||||
@Autowired
|
||||
private SessionData sessionData;
|
||||
@Autowired
|
||||
private JnlpGenerator jnlpGenerator;
|
||||
@Autowired
|
||||
private ServletContext context;
|
||||
|
||||
@RequestMapping(value="/sign/data", method= RequestMethod.GET)
|
||||
public void dataForSign(HttpServletResponse response, HttpServletRequest request) {
|
||||
SignData data = (SignData) sessionData.getProperty(Constants.KEY_SIGN_DATA);
|
||||
ObjectOutputStream os = null;
|
||||
|
||||
try {
|
||||
os = new ObjectOutputStream(response.getOutputStream());
|
||||
response.setContentType("application/x-java-serialized-object");
|
||||
os.writeObject(data);
|
||||
os.flush();
|
||||
os.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (os != null) {
|
||||
try {
|
||||
os.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value="/sign/data", method= RequestMethod.POST)
|
||||
public void signedData(HttpServletRequest request, HttpServletResponse response) {
|
||||
ObjectInputStream ois = null;
|
||||
ObjectOutputStream os = null;
|
||||
String error = null;
|
||||
|
||||
try {
|
||||
ois = new ObjectInputStream(request.getInputStream());
|
||||
SignData data = (SignData) ois.readObject();
|
||||
sessionData.setProperty(Constants.KEY_SIGN_DATA, data);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
error = "IO error";
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
error = "Loading error";
|
||||
}
|
||||
|
||||
try {
|
||||
SignUploadResponse resp = new SignUploadResponse();
|
||||
|
||||
if (error == null) {
|
||||
resp.setOk(true);
|
||||
} else {
|
||||
resp.setOk(false);
|
||||
resp.setErrorMessage(error);
|
||||
}
|
||||
|
||||
os = new ObjectOutputStream(response.getOutputStream());
|
||||
response.setContentType("application/x-java-serialized-object");
|
||||
os.writeObject(resp);
|
||||
os.flush();
|
||||
os.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value="/sign/signer.jnlp", method= RequestMethod.GET)
|
||||
public void jnlp(HttpServletResponse response) {
|
||||
byte[] data = jnlpGenerator.generate();
|
||||
sendByte(response, data, "application/x-java-jnlp-file");
|
||||
}
|
||||
|
||||
@RequestMapping(value="/sign/pdfsigner.jar", method= RequestMethod.GET)
|
||||
public void pdfsigner(HttpServletResponse response) {
|
||||
sendJar(response, "Linux");
|
||||
}
|
||||
|
||||
@RequestMapping(value="/sign/pdfsignerWin.jar", method= RequestMethod.GET)
|
||||
public void pdfsignerWin(HttpServletResponse response) {
|
||||
sendJar(response, "Windows");
|
||||
}
|
||||
|
||||
private void sendJar(HttpServletResponse response, String os) {
|
||||
File inputJar;
|
||||
|
||||
if (os.startsWith("Windows")) {
|
||||
inputJar = new File(context.getRealPath("/WEB-INF/signer/PDFSignerWin.jar"));
|
||||
} else {
|
||||
inputJar = new File(context.getRealPath("/WEB-INF/signer/PDFSigner.jar"));
|
||||
}
|
||||
|
||||
try {
|
||||
byte[] data = new byte[(int) inputJar.length()];
|
||||
FileInputStream is = new FileInputStream(inputJar);
|
||||
is.read(data);
|
||||
sendByte(response, data, "application/java-archive");
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void sendByte(HttpServletResponse response, byte[] data, String contentType) {
|
||||
ServletOutputStream os = null;
|
||||
|
||||
try {
|
||||
os = response.getOutputStream();
|
||||
response.setContentType(contentType);
|
||||
response.setContentLength(data.length);
|
||||
os.write(data);
|
||||
os.flush();
|
||||
os.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package info.bukova.isspst.storage;
|
||||
|
||||
import info.bukova.isspst.data.SignedDocumentItem;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public interface ReportFileStorage extends FileStorage<SignedDocumentItem> {
|
||||
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
package info.bukova.isspst.storage;
|
||||
|
||||
import info.bukova.isspst.data.SignedDocumentItem;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Pepa Rokos
|
||||
*/
|
||||
public class ReportFileStorageImpl extends AbstractFileStorage<SignedDocumentItem> implements ReportFileStorage {
|
||||
|
||||
private String rootPath;
|
||||
|
||||
public void setRootPath(String rootPath) {
|
||||
this.rootPath = rootPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRootPath() {
|
||||
return this.rootPath;
|
||||
}
|
||||
|
||||
private String getFilePath(String fileName) {
|
||||
return rootPath + "/" + fileName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveFile(byte[] data, SignedDocumentItem signedDocumentItem) {
|
||||
String fileName = signedDocumentItem.getFileName();
|
||||
|
||||
if (fileName == null) {
|
||||
fileName = UUID.randomUUID().toString() + ".pdf";
|
||||
}
|
||||
|
||||
saveFileDataToPath(data, getFilePath(fileName));
|
||||
signedDocumentItem.setFileName(fileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveFile(File file, SignedDocumentItem fileId) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFile(SignedDocumentItem signedDocumentItem) {
|
||||
removeFileByPath(getFilePath(signedDocumentItem.getFileName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveFile(String source, String destination) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createDirectory(String dir) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] fileData(SignedDocumentItem signedDocumentItem) {
|
||||
return fileDataFromPath(getFilePath(signedDocumentItem.getFileName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public File file(SignedDocumentItem signedDocumentItem) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dirExists(String path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serverPath(SignedDocumentItem signedDocumentItem) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
package info.bukova.isspst.ui;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.zkoss.bind.BindContext;
|
||||
import org.zkoss.bind.Converter;
|
||||
import org.zkoss.util.Locales;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.Locale;
|
||||
|
||||
public class BigDecimalFilterConverter implements Converter<String, BigDecimal, Component>
|
||||
{
|
||||
private final static Logger log = LoggerFactory.getLogger(BigDecimalFilterConverter.class.getName());
|
||||
|
||||
@Override
|
||||
public BigDecimal coerceToBean(String str, Component component, BindContext cx)
|
||||
{
|
||||
// BigDecimal val = BigDecimal.ZERO;
|
||||
BigDecimal val = null;
|
||||
|
||||
if (str != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Locale loc = Locales.getCurrent();
|
||||
DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance(loc);
|
||||
format.setParseBigDecimal(true);
|
||||
val = (BigDecimal) format.parse(str);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
log.warn(str, e);
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
log.warn(str, e);
|
||||
}
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String coerceToUi(BigDecimal val, Component component, BindContext cx)
|
||||
{
|
||||
Locale loc = Locales.getCurrent();
|
||||
|
||||
if (val == null)
|
||||
{
|
||||
return "";
|
||||
//val = BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
val = val.setScale(2, BigDecimal.ROUND_DOWN);
|
||||
|
||||
DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance(loc);
|
||||
format.setMaximumFractionDigits(2);
|
||||
format.setMinimumFractionDigits(0);
|
||||
format.setGroupingUsed(true);
|
||||
format.setGroupingSize(3);
|
||||
String formatted = format.format(val);
|
||||
return formatted;
|
||||
}
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package info.bukova.isspst.ui;
|
||||
|
||||
import org.zkoss.bind.annotation.Init;
|
||||
|
||||
public class BindingViewModel<T> extends DocumentViewModel {
|
||||
|
||||
private BindingForm<T> dataForm;
|
||||
|
||||
@Init
|
||||
public void initBindingViewModel() {
|
||||
super.initDocumentViewModel();
|
||||
|
||||
dataForm = new BindingForm<T>();
|
||||
}
|
||||
|
||||
public BindingForm<T> getDataForm() {
|
||||
return this.dataForm;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue