aboutsummaryrefslogtreecommitdiff
path: root/DocumentService/src/eu/stork/documentservice/model
diff options
context:
space:
mode:
authorAlexander Marsalek <amarsalek@iaik.tugraz.at>2014-06-04 18:50:50 +0200
committerAlexander Marsalek <amarsalek@iaik.tugraz.at>2014-06-04 18:56:07 +0200
commitf81b3716ac27094ab1845668cb38a1fe6a2d5f8c (patch)
tree933cd9ae96e6c7c01b78aea37b904b31419b1b0f /DocumentService/src/eu/stork/documentservice/model
parent31c8bad4214bfee45eef0ca98faf3f6f32fe5b23 (diff)
downloadmoa-id-spss-f81b3716ac27094ab1845668cb38a1fe6a2d5f8c.tar.gz
moa-id-spss-f81b3716ac27094ab1845668cb38a1fe6a2d5f8c.tar.bz2
moa-id-spss-f81b3716ac27094ab1845668cb38a1fe6a2d5f8c.zip
added DocumentService
Diffstat (limited to 'DocumentService/src/eu/stork/documentservice/model')
-rw-r--r--DocumentService/src/eu/stork/documentservice/model/DocumentModel.java122
-rw-r--r--DocumentService/src/eu/stork/documentservice/model/RequestModel.java106
-rw-r--r--DocumentService/src/eu/stork/documentservice/model/TempDocumentModel.java118
3 files changed, 346 insertions, 0 deletions
diff --git a/DocumentService/src/eu/stork/documentservice/model/DocumentModel.java b/DocumentService/src/eu/stork/documentservice/model/DocumentModel.java
new file mode 100644
index 000000000..10ae8a189
--- /dev/null
+++ b/DocumentService/src/eu/stork/documentservice/model/DocumentModel.java
@@ -0,0 +1,122 @@
+package eu.stork.documentservice.model;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+
+import eu.stork.documentservice.exceptions.ModelException;
+
+/**
+ * The document model class
+ * @author sveinbjorno
+ *
+ */
+public class DocumentModel {
+ private String docid;
+ private byte[] document;
+ private String filename;
+ private String mimetype;
+ private String reicevercert;
+ private String enckey;
+ private String enciv;
+ private Date created;
+ private Date updated;
+ private Date deleted;
+
+ public String getDocid() {
+ return docid;
+ }
+ public void setDocid(String docid) {
+ this.docid = docid;
+ }
+ public byte[] getDocument() {
+ return document;
+ }
+ public void setDocument(byte[] document) {
+ this.document = document;
+ }
+ public String getFilename() {
+ return filename;
+ }
+ public void setFilename(String filename) {
+ this.filename = filename;
+ }
+ public String getMimetype() {
+ return mimetype;
+ }
+ public void setMimetype(String mimetype) {
+ this.mimetype = mimetype;
+ }
+ public String getReicevercert() {
+ return reicevercert;
+ }
+ public void setReicevercert(String reicevercert) {
+ this.reicevercert = reicevercert;
+ }
+ public String getEnckey() {
+ return enckey;
+ }
+ public void setEnckey(String enckey) {
+ this.enckey = enckey;
+ }
+ public String getEnciv() {
+ return enciv;
+ }
+ public void setEnciv(String enciv) {
+ this.enciv = enciv;
+ }
+ public Date getCreated() {
+ return created;
+ }
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+ public Date getUpdated() {
+ return updated;
+ }
+ public void setUpdated(Date updated) {
+ this.updated = updated;
+ }
+ public Date getDeleted() {
+ return deleted;
+ }
+ public void setDeleted(Date deleted) {
+ this.deleted = deleted;
+ }
+
+ public InputStream getDataStream()
+ {
+ if (this.document != null)
+ return new ByteArrayInputStream(this.document);
+ else
+ return null;
+ }
+
+ public void setDataStream(InputStream stream) throws ModelException
+ {
+ try {
+ this.document = new byte[stream.available()];
+ stream.read(this.document);
+ } catch (IOException e) {
+ throw new ModelException("Unable to parse stream.", e);
+ }
+ }
+
+ public void insertValidate() throws ModelException
+ {
+ if (this.docid == null || this.docid.isEmpty())
+ throw new ModelException("Document ID is null or empty");
+ if (this.document == null)
+ throw new ModelException("Document is null");
+ if (this.mimetype == null || this.mimetype.isEmpty())
+ throw new ModelException("MIME type is null or empty.");
+ }
+
+ public void updateValidate() throws ModelException
+ {
+ this.insertValidate();
+ if (this.created == null)
+ throw new ModelException("Created is null");
+ }
+}
diff --git a/DocumentService/src/eu/stork/documentservice/model/RequestModel.java b/DocumentService/src/eu/stork/documentservice/model/RequestModel.java
new file mode 100644
index 000000000..638af419e
--- /dev/null
+++ b/DocumentService/src/eu/stork/documentservice/model/RequestModel.java
@@ -0,0 +1,106 @@
+package eu.stork.documentservice.model;
+
+import java.util.Date;
+
+import eu.stork.documentservice.exceptions.ModelException;
+
+/**
+ * The request model class
+ * @author sveinbjorno
+ *
+ */
+public class RequestModel {
+
+ private String requestid;
+ private String docid;
+ private String destcountry;
+ private String spcountry;
+ private String spid;
+ private String xmlrequest;
+ private String xmlresponse;
+ private Date reqtimestamp;
+ private Date restimestamp;
+
+ public String getRequestid() {
+ return requestid;
+ }
+ public void setRequestid(String requestid) {
+ this.requestid = requestid;
+ }
+ public String getDocid() {
+ return docid;
+ }
+ public void setDocid(String docid) {
+ this.docid = docid;
+ }
+ public String getDestcountry() {
+ return destcountry;
+ }
+ public void setDestcountry(String destcountry) {
+ this.destcountry = destcountry;
+ }
+ public String getSpcountry() {
+ return spcountry;
+ }
+ public void setSpcountry(String spcountry) {
+ this.spcountry = spcountry;
+ }
+ public String getSpid() {
+ return spid;
+ }
+ public void setSpid(String spid) {
+ this.spid = spid;
+ }
+ public String getXmlrequest() {
+ return xmlrequest;
+ }
+ public void setXmlrequest(String xmlrequest) {
+ this.xmlrequest = xmlrequest;
+ }
+ public String getXmlresponse() {
+ return xmlresponse;
+ }
+ public void setXmlresponse(String xmlresponse) {
+ this.xmlresponse = xmlresponse;
+ }
+ public Date getReqtimestamp() {
+ return reqtimestamp;
+ }
+ public void setReqtimestamp(Date reqtimestamp) {
+ this.reqtimestamp = reqtimestamp;
+ }
+ public Date getRestimestamp() {
+ return restimestamp;
+ }
+ public void setRestimestamp(Date restimestamp) {
+ this.restimestamp = restimestamp;
+ }
+
+ public String getFullDocID()
+ {
+ return this.spcountry + "/" + this.destcountry + "/" + this.docid;
+ }
+
+ public void insertValidate() throws ModelException
+ {
+ if (this.requestid == null || this.requestid.isEmpty())
+ throw new ModelException("Request ID is null or empty");
+ if (this.destcountry == null || this.destcountry.isEmpty())
+ throw new ModelException("Destination country is null or empty.");
+ if (this.spcountry == null || this.spcountry.isEmpty())
+ throw new ModelException("SP country is null or empty.");
+ if (this.destcountry == null || this.destcountry.isEmpty())
+ throw new ModelException("Destination country is null or empty.");
+ if (this.xmlrequest== null || this.xmlrequest.isEmpty())
+ throw new ModelException("XML request is null or empty.");
+ }
+
+ public void updateValidate() throws ModelException
+ {
+ this.insertValidate();
+ if (this.docid == null || this.docid.isEmpty())
+ throw new ModelException("Document ID is null or empty");
+ if (this.reqtimestamp == null)
+ throw new ModelException("Request timestamp is null or empty");
+ }
+}
diff --git a/DocumentService/src/eu/stork/documentservice/model/TempDocumentModel.java b/DocumentService/src/eu/stork/documentservice/model/TempDocumentModel.java
new file mode 100644
index 000000000..7c28cc0f7
--- /dev/null
+++ b/DocumentService/src/eu/stork/documentservice/model/TempDocumentModel.java
@@ -0,0 +1,118 @@
+package eu.stork.documentservice.model;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+
+import eu.stork.documentservice.exceptions.ModelException;
+
+public class TempDocumentModel {
+ private String docid;
+ private byte[] document;
+ private String spid;
+ private String mimetype;
+ private String reicevercert;
+ private String enckey;
+ private String enciv;
+ private Date created;
+ private Date fetched;
+ private Date deleted;
+
+ public String getDocid() {
+ return docid;
+ }
+ public void setDocid(String docid) {
+ this.docid = docid;
+ }
+ public byte[] getDocument() {
+ return document;
+ }
+ public void setDocument(byte[] document) {
+ this.document = document;
+ }
+ public String getSpid() {
+ return spid;
+ }
+ public void setSpid(String spid) {
+ this.spid = spid;
+ }
+ public String getMimetype() {
+ return mimetype;
+ }
+ public void setMimetype(String mimetype) {
+ this.mimetype = mimetype;
+ }
+
+ public String getReicevercert() {
+ return reicevercert;
+ }
+ public void setReicevercert(String reicevercert) {
+ this.reicevercert = reicevercert;
+ }
+ public String getEnckey() {
+ return enckey;
+ }
+ public void setEnckey(String enckey) {
+ this.enckey = enckey;
+ }
+ public String getEnciv() {
+ return enciv;
+ }
+ public void setEnciv(String enciv) {
+ this.enciv = enciv;
+ }
+ public Date getCreated() {
+ return created;
+ }
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+ public Date getFetched() {
+ return fetched;
+ }
+ public void setFetched(Date fetched) {
+ this.fetched = fetched;
+ }
+ public Date getDeleted() {
+ return deleted;
+ }
+ public void setDeleted(Date deleted) {
+ this.deleted = deleted;
+ }
+
+ public InputStream getDataStream()
+ {
+ if (this.document != null)
+ return new ByteArrayInputStream(this.document);
+ else
+ return null;
+ }
+
+ public void setDataStream(InputStream stream) throws ModelException
+ {
+ try {
+ this.document = new byte[stream.available()];
+ stream.read(this.document);
+ } catch (IOException e) {
+ throw new ModelException("Unable to parse stream.", e);
+ }
+ }
+
+ public void insertValidate() throws ModelException
+ {
+ if (this.docid == null || this.docid.isEmpty())
+ throw new ModelException("Document ID is null or empty");
+ if (this.document == null)
+ throw new ModelException("Document is null");
+ if (this.spid == null || this.spid.isEmpty())
+ throw new ModelException("SPId is null or empty.");
+ }
+
+ public void updateValidate() throws ModelException
+ {
+ this.insertValidate();
+ if (this.created == null)
+ throw new ModelException("Created is null");
+ }
+}