Project and Portfolio Management Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Tracking Who Deleted Requests

Highlighted
eps414
Regular Collector

Tracking Who Deleted Requests

We are trying to find a way to track who is deleting requests in our system. Has anyone developed any method whether it be at the database level (i.e. tigger) or file system level (i.e. javascript) to write a log line or to a table who deletes a request and when?

 

Currently I have been trying with a trigger but the problem is at the db level there is no way to capture the username actually logged into PPM clicking the button.

 

Any ideas?

 

DROP TRIGGER PPMDEV.KCRT_REQUEST_DELETE

/

 

CREATE OR REPLACE TRIGGER PPMDEV.KCRT_REQUEST_DELETE

before  delete

on     kcrt_requests

REFERENCING NEW AS New OLD AS Old

for    each row

declare

  l_sysdate DATE;

 

begin

  SELECT CURRENT_DATE

  INTO   l_sysdate

  FROM   sys.dual;

 

 

    INSERT into REQUEST_DELETES

    SELECT :old.request_id,

           :old.last_update_date,

           :old.last_updated_by,

           :new.last_updated_by,

           :old.request_type_id,

           :old.description,

           :old.status_id,

           l_sysdate

          

    FROM   sys.dual;

  end;

/

12 REPLIES
penoles
Regular Collector

Re: Tracking Who Deleted Requests

If you work on PPM8 or 9, A configuration file named EventListener.xml which you can find in conf directory.

To track who delete the requests, a sample configuration as following

<?xml version="1.0" encoding="UTF-8"?>

<event-listeners-config>
<request-listener type="penoles.project.ppm.DemoListener">
<event-type>DELETE</event-type>
</request-listener>
</event-listeners-config>

 

All the next thing you need to do is code a listener, sample code as following

public class DemoListener extends BaseRequestEventListener {

@Override

public void onDelete(final RequestEventContext context) throws AppException {
Integer userid = context.getServerConnection().getUserID();
String username = context.getServerConnection().getUsername();
Integer reqid = context.getRequestId();
System.out.println("username=" + username + ";user id=" + userid + "reqid" + reqid.toString());
// 

// do something here to log the user and request id

//
}

}

 

I'm not sure whether it is a supported implementation, you must take your own risk if you want to do that way

eps414
Regular Collector

Re: Tracking Who Deleted Requests

Penoles,

 

Could you help me with this a bit more. I understand the entry into the xml file, but the rest I don't get.

 

1. Your entry in the request-listener-type: what does that point to?

2. I don't know how to code the listener or where or what type of file to put it in. Can you please help?

 

All I am trying to do is either have PPM right to a log file or to a new db table all requests that were deleted, by who, when, and request ID.

 

thanks a ton.

penoles
Regular Collector

Re: Tracking Who Deleted Requests

request-listener-type should point to the java class you created for  handle the event,

 

please see the attachment for reference , set the event listener xml and  extract the zip, put penoles folder under itg.war/web-inf/classes folder, restart the server, if someone delete the request, you can find error info in log/serverLog.txt


 

the java source file as following, It was a very simple implementation, you can change according to you own requirement.

 

package penoles.project.ppm;

import com.kintana.core.logging.LogManager;
import com.kintana.core.logging.Logger;
import com.kintana.core.server.AppException;
import com.kintana.crt.server.BaseRequestEventListener;
import com.kintana.crt.server.RequestEventContext;

public class DemoListener extends BaseRequestEventListener {
private static Logger logger = LogManager.getLogger(Logger.SERVER_LOGGER);
@Override
public void onDelete(final RequestEventContext context) throws AppException {
logger.info("Entering class:" + DemoListener.class.toString() + ", on method onDelete.");
try{
String username = context.getServerConnection().getUsername();
Integer reqid = context.getRequestId();
logger.error("Catch Request Delete Event:User:[" + username + "] delete request id=[" + reqid.toString()+ "]");

}catch(NullPointerException e)
{
logger.info("NullPointerException catched in class:" + DemoListener.class.toString() + ", on method onDelete.");
}


}

}


 


eps414
Regular Collector

Re: Tracking Who Deleted Requests

Penoles,

 

This is great. I have a couple more questions:

 

1. When I am trying this, when it is writing to the serverLog.txt file the Username is showing up at [null]. Any ideas?

2. Is there a way to have this write to a seperate log file so that these ERRORs can be tracked alone?

3. Where/How can I find all of the different things I could track in the entry, I.E. Request Description, etc...

 

Thanks.

penoles
Regular Collector

Re: Tracking Who Deleted Requests

for question1, I have no idea why the username is showing up with null since I haven't got this. I 'm working on ppm9, maybe we are on  different version. another way to get user name is call context.getServerConnection().getLogonPacket().getUser().getUserName(), this should work.

 

As the code I given is just POC that can track the delete request event, if you have some knowledge of java programming, that's not a question for question 2 and 3, if you haven't , you may need find someone to help you to write a piece of code.

 

 

 

 

eps414
Regular Collector

Re: Tracking Who Deleted Requests

Penoles,

 

I appreciate all your assistance. I did get the new call to work properly for the username. Maybe it is a difference between 8 and 9. I have very limited JAVA experience.

 

If you could just entertain one more question for me on this. Where is it or how do you find all of the calls that can take place in the different contexts. I.E. Is there a file I can look at like a tag library or something in the PPM file system that will tell me all the different items I can pull from context. Example, instead of context.ReqID() can I pull context. ReqDescription().

 

Thanks.

penoles
Regular Collector

Re: Tracking Who Deleted Requests

You could see all the method that you can call from a object with a java IDE( IE: eclipse),

According to you requirement, there's no  ReqDescription method from context, but since you can get request id, 

you can write code to get other request information IE: description from database.

eps414
Regular Collector

Re: Tracking Who Deleted Requests

Which file on the ppm fs do I use to import into Eclipse that contains all the source code?

Jim Esler
Honored Contributor

Re: Tracking Who Deleted Requests

There is a trigger on the knta_user_security table that records all inserts, updates and deletes in the knta_user_security_hist table. The information that is logged includes the user id that performed the function. You may be able to use this trigger as a model for one tracking deletes of requests.

eps414
Regular Collector

Re: Tracking Who Deleted Requests

Jim,

 

Thank you for trying, but just like most of the stuff in the database, HP is taking a short cut. Anytime there is a delete they just default the value to 1, instead of actually capturing who did the delete.

 

Thanks.

penoles
Regular Collector

Re: Tracking Who Deleted Requests

knta_classes.jar, it can be found in itg.war/web-inf/lib, but keep in mind, it does not contain source code but the binary class files; but you can get all the functions which can be called from a class.

eps414
Regular Collector

Re: Tracking Who Deleted Requests

Yes I've gotten pretty far with Eclipse, but I cannot compile anything because the souce code is missing. Where can I find that?

 

 

//Add this to "OnDomLoad" event