public void createRequest(String Uid, String Object, String Admin) {
HashMap map = new HashMap();
map.put("Requests.Object Request Type", "Add");
map.put("Requests.Target Type", "U");
map.put("Requests.Type", "U");
// map.put("Requests.Considated Data Value",
// "<Data><Users><User><UserLogin>TestUser</UserLogin><FirstName>Test</FirstName><LastName>User</LastName></User></Users><Resources><Resource Key=\"109\"><ResourceName>iPlanet User</ResourceName></Resource></Resources></Data>"
// );
long userKey = getUserKey(Uid);
System.out.println("UserKey--->" + userKey);
try {
long reqKey = moreq.createRequest(map);// THIS INITIATES THE rEQUEST
// TO THE
// rEQUESTER(xelsysadm)
System.out.println("ReqKey=" + reqKey);
System.out.println("Request INITIATED");
moreq.addRequestUser(reqKey, userKey);
System.out.println("Added the request user"); // Add the request to
// the User
moreq.addRequestObject(reqKey, getObjectKey(Object), false);
System.out.println("Object Added the request user"); // Add the
// request
// to the
// Object
moreq.completeRequestCreation(reqKey);
System.out.println("Completed and submitted the request"); // Completes
// the
// request
// creation
// and
// waits
// for
// approval
// Approve the request
Thread.sleep(10000);
approveRequest(reqKey, Admin);
System.out.println("Admin has approved the request");
} catch (tcAPIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcAttributeMissingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcInvalidAttributeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcRequestInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcRequestNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcRequestUserInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcRequestObjectInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void approveRequest(long reqKey, String Uid) {
HashMap map = new HashMap();
map.put("Requests.Object Request Type", "Add");
map.put("Requests.Target Type", "U");
map.put("Requests.Type", "U");
long userKey = getUserKey(Uid);// Admin user has to be passed
// (requester---xelsysadm)
try {
moreq.setRequestResponse(reqKey, userKey, "Approve");
System.out.println("completed");
} catch (tcAPIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcInvalidResponseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcAwaitingObjectDataCompletionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcAwaitingApprovalDataCompletionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/*
* try { tcResultSet set;
* set=moreq.getApprovalTasksAssignedToUser(userKey, map); String[]
* coumnName=set.getColumnNames();
*
* for(String cName : coumnName){
*
* System.out.println(cName); System.out.println(set.getRowCount());
*
* for (int i = 0; i < set.getRowCount(); i++) { set.goToRow(i); String
* value = set.getStringValue(cName);
* System.out.println(cName+"---->"+value);
*
* } }
*
* System.out.println("Request Approval Initiated...");
*
* } catch (tcAPIException e) { // TODO Auto-generated catch block
* e.printStackTrace(); }catch (tcUserNotFoundException e) { // TODO
* Auto-generated catch block e.printStackTrace(); } catch
* (tcAttributeNotFoundException e) { // TODO Auto-generated catch block
* e.printStackTrace(); } catch (tcColumnNotFoundException e) { // TODO
* Auto-generated catch block e.printStackTrace(); }
*/
}
HashMap map = new HashMap();
map.put("Requests.Object Request Type", "Add");
map.put("Requests.Target Type", "U");
map.put("Requests.Type", "U");
// map.put("Requests.Considated Data Value",
// "<Data><Users><User><UserLogin>TestUser</UserLogin><FirstName>Test</FirstName><LastName>User</LastName></User></Users><Resources><Resource Key=\"109\"><ResourceName>iPlanet User</ResourceName></Resource></Resources></Data>"
// );
long userKey = getUserKey(Uid);
System.out.println("UserKey--->" + userKey);
try {
long reqKey = moreq.createRequest(map);// THIS INITIATES THE rEQUEST
// TO THE
// rEQUESTER(xelsysadm)
System.out.println("ReqKey=" + reqKey);
System.out.println("Request INITIATED");
moreq.addRequestUser(reqKey, userKey);
System.out.println("Added the request user"); // Add the request to
// the User
moreq.addRequestObject(reqKey, getObjectKey(Object), false);
System.out.println("Object Added the request user"); // Add the
// request
// to the
// Object
moreq.completeRequestCreation(reqKey);
System.out.println("Completed and submitted the request"); // Completes
// the
// request
// creation
// and
// waits
// for
// approval
// Approve the request
Thread.sleep(10000);
approveRequest(reqKey, Admin);
System.out.println("Admin has approved the request");
} catch (tcAPIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcAttributeMissingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcInvalidAttributeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcRequestInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcRequestNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcRequestUserInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcRequestObjectInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void approveRequest(long reqKey, String Uid) {
HashMap map = new HashMap();
map.put("Requests.Object Request Type", "Add");
map.put("Requests.Target Type", "U");
map.put("Requests.Type", "U");
long userKey = getUserKey(Uid);// Admin user has to be passed
// (requester---xelsysadm)
try {
moreq.setRequestResponse(reqKey, userKey, "Approve");
System.out.println("completed");
} catch (tcAPIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcInvalidResponseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcAwaitingObjectDataCompletionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (tcAwaitingApprovalDataCompletionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/*
* try { tcResultSet set;
* set=moreq.getApprovalTasksAssignedToUser(userKey, map); String[]
* coumnName=set.getColumnNames();
*
* for(String cName : coumnName){
*
* System.out.println(cName); System.out.println(set.getRowCount());
*
* for (int i = 0; i < set.getRowCount(); i++) { set.goToRow(i); String
* value = set.getStringValue(cName);
* System.out.println(cName+"---->"+value);
*
* } }
*
* System.out.println("Request Approval Initiated...");
*
* } catch (tcAPIException e) { // TODO Auto-generated catch block
* e.printStackTrace(); }catch (tcUserNotFoundException e) { // TODO
* Auto-generated catch block e.printStackTrace(); } catch
* (tcAttributeNotFoundException e) { // TODO Auto-generated catch block
* e.printStackTrace(); } catch (tcColumnNotFoundException e) { // TODO
* Auto-generated catch block e.printStackTrace(); }
*/
}
No comments:
Post a Comment