Domino 9 und frühere Versionen > ND9: Entwicklung

OSGI Tasklet Development auf dem Domino Server security problems

<< < (2/5) > >>

Sven Hasselbach:
Probier mal


--- Code: ---import com.ibm.domino.osgi.core.context.ContextInfo;

Session session = ContextInfo.getUserSession();
--- Ende Code ---

Thomas Schulte:

--- Zitat von: Sven Hasselbach am 05.02.16 - 09:55:38 ---Probier mal


--- Code: ---import com.ibm.domino.osgi.core.context.ContextInfo;

Session session = ContextInfo.getUserSession();
--- Ende Code ---

--- Ende Zitat ---
Ok das funktioniert für den ersten Teil der Frage. Danke Sven.
Damit läuft das schon mal mit den Rechten des jeweiligen Benutzers.

Bleibt nur noch das zweite Problem.

Sven Hasselbach:
Zum zweiten Teil:
Wie greifst Du denn auf das Dokument zu? Wie sieht dein Code aus?

Thomas Schulte:
Class Definition der base class

--- Code: ---public class SimpleServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private NamesDirectory namesDir;
private DominoConnection domConnection;
private String dbUNID;

public SimpleServlet() {

--- Ende Code ---
....
Calling Function ...

--- Code: ---/*  Execute and action, based on the Parameters passed to the servlet from the URL;  */
private void executeParams(HttpServletRequest req, PrintWriter pw) {
try
{
....

Code
pw.println("List the usernames for this session.<BR>") ;
pw.println(" Value for database parameter was: " + parameterNames.get("databaseunid") + "<BR>");
this.dbUNID = parameterNames.get("databaseunid");
this.domConnection = new DominoConnection(this.dbUNID, pw);
--> hier knallt es this.domConnection.DominoGetUserName(pw);

--- Ende Code ---

die Domino Connection ist in einer eigenen Klasse definiert. Und zwar bei zwei von drei Methoden die ich in dieser Klasse aufrufe.
Bei dieser Funktion hier auch

--- Code: ---pw.println("List the data for a single project.<BR>") ;
pw.println(" Value for database parameter was: " + parameterNames.get("databaseunid") + "<BR>");
this.dbUNID = parameterNames.get("databaseunid");
this.domConnection = new DominoConnection(this.dbUNID, pw);
this.domConnection.DominoGetView("(ProjectsByCode)", pw); // -->> der Call hier der in dieselbe Klasse reinschaut funktioniert komischerweise
pw.println("check if the view is still available.<BR>") ;
pw.println(this.domConnection.notesViewHashMap.get("(ProjectsByCode)").getName());
pw.println("... rows in view =  "  + Integer.toString(this.domConnection.notesViewHashMap.get("(ProjectsByCode)").getEntryCount() ));
--> hier auch this.domConnection.DominoGetDocumentByKey("(ProjectsByCode)",parameterNames.get("projectid"), pw);

--- Ende Code ---

Das hier ist die Klasse.

--- Code: ---public class DominoConnection {
private Session notesS;
private DbDirectory notesDbDirectory;
private Database notesDatabase;
private View notesView;
public HashMap<String, View> notesViewHashMap = new HashMap();
private Document notesDocument;
public HashMap<String, Document> notesDocumentHashMap = new HashMap();

--- Ende Code ---
....

und das hier die aufgerufenen Funktion

--- Code: ---/public void DominoGetDocumentByKey(String viewName, String keyID, PrintWriter pw) {
try {
pw.println("Debug001");
if (notesViewHashMap.containsKey(viewName)) {
pw.println("View found viewName = " + this.notesViewHashMap.get(viewName).getName() + "<BR>");
notesDocument = this.notesViewHashMap.get(viewName).getDocumentByKey(keyID);
if (!notesDocumentHashMap.containsKey(notesDocument.getUniversalID())) {
notesDocumentHashMap.put(notesDocument.getUniversalID(), notesDocument);
pw.println("document Size = " + notesDocument.getSize() + "<BR>");
}
}
}
catch (NotesException n) {
pw.println("NotesException DominoGetdocumentByKey<BR>");
pw.println(n.toString()+ "<BR>");
} //catch block

}
//Check the user
public void DominoGetUserName(PrintWriter pw) {
try {

pw.println("Common UserName = " + notesS.getCommonUserName() + "<BR>");
pw.println("Effective UserName = " + notesS.getEffectiveUserName() + "<BR>");

}
catch (NotesException n) {
pw.println("NotesException DominoGetView<BR>");
pw.println(n.toString()+ "<BR>");
} //catch block


}


--- Ende Code ---

Und das hier ist das Teil das funktioniert wenn ich es aufrufe

--- Code: --- //connect and open the specified view in that database add the view to a hash map for further use
public void DominoGetView(String viewName, PrintWriter pw) {
try {
if (!notesViewHashMap.containsKey(viewName)) {
notesView = this.notesDatabase.getView(viewName);
if (notesView != null) {
notesViewHashMap.put(viewName, notesView);
pw.println("viewName = " + notesView.getName() + "<BR>");
}
}
}
catch (NotesException n) {
pw.println("NotesException DominoGetView<BR>");
pw.println(n.toString()+ "<BR>");
} //catch block


}

--- Ende Code ---

Ich weis das ich etwas übersehe. Ich weis nur nicht was.

Sven Hasselbach:
Wo liegt denn Dein Code (Klasse "DominoConnection")? (Pfad etc.)?

Navigation

[0] Themen-Index

[#] Nächste Seite

[*] Vorherige Sete

Zur normalen Ansicht wechseln