summaryrefslogtreecommitdiffstats
path: root/task1/ehrclient.h
diff options
context:
space:
mode:
authormanuel <manuel@nc8430.lan>2009-10-31 16:11:26 +0100
committermanuel <manuel@nc8430.lan>2009-10-31 16:11:26 +0100
commit1d8445b8461f558987067d870f0f11cdc84b4f35 (patch)
tree146d7d02dddf1a403392ac4b86c19bca4a3c6f75 /task1/ehrclient.h
downloadselinux-1d8445b8461f558987067d870f0f11cdc84b4f35.tar.gz
selinux-1d8445b8461f558987067d870f0f11cdc84b4f35.tar.bz2
selinux-1d8445b8461f558987067d870f0f11cdc84b4f35.zip
pushing task1 to repo
Diffstat (limited to 'task1/ehrclient.h')
-rw-r--r--task1/ehrclient.h164
1 files changed, 164 insertions, 0 deletions
diff --git a/task1/ehrclient.h b/task1/ehrclient.h
new file mode 100644
index 0000000..2654000
--- /dev/null
+++ b/task1/ehrclient.h
@@ -0,0 +1,164 @@
1/**
2 * $Id: ehrclient.h 2 2009-10-31 02:48:23Z l0728348 $
3 *
4 * Copyright 2009
5 *
6 * @author Manuel Mausz (0728348)
7 * @brief implements the main routines of the console application
8 */
9
10#ifndef EHRCLIENT_H
11#define EHRCLIENT_H
12
13#include <string>
14#include <vector>
15#include <utility>
16#include <stdexcept>
17#include <Ice/Ice.h>
18#include "ehr.h"
19#include "security.h"
20
21/**
22 * implements the main routines of the console application
23 */
24class EhrClient
25: virtual public Ice::Application
26{
27 public:
28 /**
29 * @brief exception thrown by EhrClient
30 */
31 class runtime_error : public std::runtime_error {
32 public:
33 /**
34 * @brief Default exception ctor
35 * @param what message to pass along
36 */
37 runtime_error(const std::string& what)
38 : std::runtime_error(what)
39 {}
40 };
41
42 /**
43 * @brief main routine
44 * gets called by Ice after internal setup
45 * @param argc argc from main
46 * @param argv argv from main
47 */
48 virtual int run(int argc, char *argv[]);
49
50 /**
51 * @brief retrieves and returns documentlist from server
52 * @return list of documents
53 */
54 Ehr::DocumentList getDocumentList();
55
56 /**
57 * @brief search for documents using parameters
58 * @param hasFrom set true to consider from parameter
59 * @param from value for from parameter
60 * @param hasTill set true to consider till parameter
61 * @param till value for till parameter
62 * @param doctype document type to search for
63 * @param docid document id to search for
64 * @return list of documents
65 * @throw Ehr::EhrException
66 */
67 Ehr::DocumentList searchDocument(const bool hasFrom = false, const long from = 0,
68 const bool hasTill = false, const long till = 0,
69 const Ehr::DocumentType doctype = Ehr::DOCANY, const long docid = 0);
70
71 /**
72 * @brief overloaded method for searching for documents
73 * @param from value for from parameter
74 * @param till value for till parameter
75 * @return list of documents
76 * @throw Ehr::EhrException
77 */
78 Ehr::DocumentList searchDocument(const long from, const long till)
79 {
80 return searchDocument(true, from, true, till);
81 }
82
83 /**
84 * @brief overloaded method for searching for documents
85 * @param doctype document type to search for
86 * @return list of documents
87 * @throw Ehr::EhrException
88 */
89 Ehr::DocumentList searchDocument(const Ehr::DocumentType doctype)
90 {
91 return searchDocument(false, 0, false, 0, doctype);
92 }
93
94 /**
95 * @brief overloaded method for searching for documents
96 * @param docid document id to search for
97 * @return list of documents
98 * @throw Ehr::EhrException
99 */
100 Ehr::DocumentList searchDocument(const long docid)
101 {
102 return searchDocument(false, 0, false, 0, Ehr::DOCANY, docid);
103 }
104
105 /**
106 * @brief list all document on server on console output
107 */
108 void listDocuments();
109
110 /**
111 * @brief retrieves document with documentid, generates a pdf document
112 * and stores it as output on disc
113 * @param docid document id
114 * @param output filename to store the pdf document
115 * @throw EhrClient::runtime_error
116 */
117 void saveDocument(const long docid, const std::string& output);
118
119 /**
120 * @brief get current time in milliseconds
121 * @return current time in milliseconds
122 */
123 long getTime();
124
125 /**
126 * @brief generate date string
127 * @param msecs time in milliseconds since 01.01.1900 00:00
128 * @return string containing the date. syntax: dd.mm.yyyy
129 */
130 std::string getDate(long msecs);
131
132 /**
133 * @brief generate date string
134 * @param date date in Ehr::Date format
135 * @return string containing the date. syntax: dd.mm.yyyy
136 */
137 std::string getDate(const Ehr::Date& date);
138
139 /**
140 * @brief convert ice request to bytestream
141 * @param request ice request to convert
142 * @return converted bytestream containing the request
143 */
144 std::vector<Ice::Byte> convertToByteStream(const Ice::ObjectPtr& request);
145
146 /**
147 * @brief split commonname (syntax user @ domain) of certificate
148 * into user and domain
149 * @param cert certificate which contains the commonname
150 * @return pair of user and domain
151 * @throw EhrClient::runtime_error
152 */
153 std::pair<std::string, std::string> splitCN(const std::string& cert);
154
155 private:
156 Ehr::ProviderPrx m_provider;
157 Security *m_security;
158 std::string m_ownercert;
159 std::string m_requestorcert;
160};
161
162#endif
163
164/* vim: set et sw=2 ts=2: */