Hallo !
Wer kann bitte bei folgendem Probem helfen
??
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Hashtable;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import lotus.domino.Database;
import lotus.domino.Document;
import lotus.domino.DocumentCollection;
import lotus.domino.NotesException;
import lotus.domino.NotesFactory;
import lotus.domino.NotesThread;
import lotus.domino.Session;
import org.apache.xmlrpc.XmlRpcServer;
public class DominoRpc extends HttpServlet {
private static final long serialVersionUID = -8023493465312843423L;
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
public void destroy() {
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
XmlRpcServer xmlrpc = new XmlRpcServer();
xmlrpc.addHandler("domino-rpc", this);
InputStream is = request.getInputStream();
byte[] result = xmlrpc.execute(is);
response.setContentType("text/xml");
response.setContentLength(result.length);
OutputStream out = response.getOutputStream();
out.write(result);
out.flush();
}
public Hashtable getVoipOp(String Account) throws Exception {
Hashtable htreturn = new Hashtable();
Hashtable ht = new Hashtable();
NotesThread.sinitThread();
try {
Session s = NotesFactory.createSession();
Database db = s.getDatabase("", "av/mnvertrag.nsf");
if (Account.equals("All")) {
String S0 = "Line1UserName != \"\" & (Form = \"OP\" | Form = \"Voip\")";
DocumentCollection dc = db.search(S0, null, 0);
for (int i = 1; i <= dc.getCount(); i++) {
Document doc = dc.getNthDocument(i);
Account = doc.getItemValueString("Line1UserName");
// Variante Hashtable is OK
Hashtable userht = null;
if (ht.get(Account) == null) {
userht = new Hashtable();
userht.put("Kunde", doc.getItemValueString("Kunde"));
userht.put("Kundennummer", doc.getItemValueString("Kundennummer"));
userht.put("Account", Account);
userht.put("OP", new Double(0));
}else{
userht = (Hashtable)ht.get(Account);
}
Double du = (Double) userht.get("OP");
if (doc.getItemValueString("Form").toLowerCase().equals("voip")) {
userht.put("OP", new Double(doc.getItemValueDouble("Preis") + du.doubleValue()));
}
if (doc.getItemValueString("Form").toLowerCase().equals("op")) {
userht.put("OP", new Double(doc.getItemValueDouble("SZahlung") + du.doubleValue()));
}
doc.recycle();
ht.put(Account, userht);
// End Variante Hashtable
// Variante Object geht nicht
// XML-RPC Error 0: org.apache.xmlrpc.XmlRpcException:
// java.lang.RuntimeException: unsupported Java type: class voipOPObj
voipOPObj userObj = null;
if (ht.get(Account) == null) {
userObj = new voipOPObj();
userObj.Kunde = doc.getItemValueString("Kunde");
userObj.Kundennummer = doc.getItemValueString("Kundennummer");
userObj.Account = Account;
}else{
userObj = (voipOPObj)ht.get(Account);
}
if (doc.getItemValueString("Form").toLowerCase().equals("voip")) {
userObj.OP = new Double(doc.getItemValueDouble("Preis") + userObj.OP.doubleValue());
}
if (doc.getItemValueString("Form").toLowerCase().equals("op")) {
userObj.OP = new Double(doc.getItemValueDouble("SZahlung") + userObj.OP.doubleValue());
}
doc.recycle();
ht.put(Account, userObj);
// End Variante Object
} // end for
htreturn.put("User", ht);
htreturn.put("Status", "success");
dc.recycle();
} else {
String S0 = "Line1UserName = \"" + Account + "\" & (Form = \"OP\" | Form = \"Voip\")";
DocumentCollection dc = db.search(S0, null, 0);
double su = 0;
Hashtable userht = new Hashtable();
for (int i = 1; i <= dc.getCount(); i++) {
Document doc = dc.getNthDocument(i);
userht.put("Kunde", doc.getItemValueString("Kunde"));
userht.put("Kundennummer", doc.getItemValueString("Kundennummer"));
userht.put("Account", Account);
if (doc.getItemValueString("Form").toLowerCase().equals("voip")) {
su = su + doc.getItemValueDouble("Preis");
}
if (doc.getItemValueString("Form").toLowerCase().equals("op")) {
su = su + doc.getItemValueDouble("SZahlung");
}
userht.put("OP", new Double(su));
doc.recycle();
} // end for
ht.put(Account, userht);
htreturn.put("User", ht);
htreturn.put("Status", "success");
dc.recycle();
}
db.recycle();
s.recycle();
} catch (NotesException ne) {
System.out.println(ne.id + " " + ne.text);
} finally {
NotesThread.stermThread();
}
return htreturn;
}
}
public class voipOPObj {
public String Kunde;
public String Kundennummer;
public String Account;
public Double OP;
voipOPObj() {
Kunde = null;
Kundennummer = null;
Account = null;
OP = new Double(0);
}
Danke für die Mühe im Voraus