Commit dd46d53f by Antti Tonkyra

Merge branch 'master' of dev.insomnia.fi:/data/bortal

2 parents eb014086 943d0c49
package fi.insomnia.bortal.model;
import java.io.IOException;
import java.io.Serializable;
import java.io.StringReader;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.bouncycastle.openssl.PEMReader;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
/**
* Entity implementation class for Entity: Certificate
*
*/
@Entity
@Table(name = "certificate")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class Certificate extends GenericEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "common_name")
private String commonName;
private String certificate;
public Certificate() {
super();
}
public String getCommonName() {
return this.commonName;
}
public void setCommonName(String commonName) {
this.commonName = commonName;
}
public String getCertificate() {
return this.certificate;
}
public X509Certificate getX509Certificate() throws CertificateException, IOException {
StringReader sr = new StringReader(this.certificate);
PEMReader pemReader = new PEMReader(sr);
X509Certificate cert = (X509Certificate) pemReader.readObject();
return cert;
}
public void setCertificate(String certificate) {
this.certificate = certificate;
}
public void set509Certificate(X509Certificate cert) {
}
}
...@@ -58,9 +58,15 @@ public abstract class GenericIntegerEntityConverter<T extends ModelInterface<Int ...@@ -58,9 +58,15 @@ public abstract class GenericIntegerEntityConverter<T extends ModelInterface<Int
T ret = null; T ret = null;
Integer id = null; Integer id = null;
if (value != null) { if (value != null) {
id = Integer.parseInt(value); try {
if (id != null) { id = Integer.parseInt(value);
ret = find(id); if (id != null) {
ret = find(id);
}
} catch (NumberFormatException nfe) {
if (value == null || !value.equals("null")) {
throw nfe;
}
} }
} }
logger.debug("Converted String {} to Integer {} became object {}", new Object[] { value, id, ret }); logger.debug("Converted String {} to Integer {} became object {}", new Object[] { value, id, ret });
...@@ -78,6 +84,10 @@ public abstract class GenericIntegerEntityConverter<T extends ModelInterface<Int ...@@ -78,6 +84,10 @@ public abstract class GenericIntegerEntityConverter<T extends ModelInterface<Int
ret = entity.getId().toString(); ret = entity.getId().toString();
} }
} }
if (ret == null)
{
ret = "null";
}
return ret; return ret;
} }
// //
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!