Deleting project from Front End of BCC
Note: This shall delete project along with project's associated process, assets, history.
To delete projects from front end of BCC, perform following steps.
1. Include the following jsp in custom BCC module's war.
File Name: delete-process.jsp
<%@ taglib uri="/dspTaglib" prefix="dsp" %>
<dsp:page>
<%@page import = "atg.epub.project.*" %>
<%@page import = "atg.dtm.*" %>
<%@page import = "atg.nucleus.*" %>
<%@page import = "javax.transaction.*" %>
<link href="style.css" type="text/css" rel="stylesheet"/>
<div style = "padding: 5px;">
<% boolean rollback = true;
TransactionManager tm=(TransactionManager)Nucleus.getGlobalNucleus().resolveName("/atg/dynamo/transaction/TransactionManager");
TransactionDemarcation td= new TransactionDemarcation();
try {
td.begin(tm);
atg.deployment.server.SecurityManager.becomeTheSuperDood();
ProcessHome processHome = ((ProcessHome) ProjectConstants.getPersistentHomes().getProcessHome());
String processId = request.getParameter("process_id");
if (processId == null) {
out.println("TRYING HYPNOSIS TO GUESS PROCESS ID..... FAILED. Try explicitly specifying a process_id request parameter. ");
return;
}
atg.epub.project.Process process =processHome.findById(processId);
if (process == null) {
out.println("wrong process_id parameter; not such process");
return;
}
Project project = process.getProject();
if (project == null) {
process.delete();
rollback = false;
out.println("Process was found but there was no project associated with it. Process was deleted successfully.");
return;
}
project.delete("publishing");
out.println("Process with id " + processId + " was found and deleted successfully.");
%>
<br/> <input type = "button"
onclick = "window.close()"
value = "Cancel/Close"
style = "font-size: 10px; background-color: #C3593C; color: white;"/> <% rollback = false;
} catch (Throwable t) {
t.printStackTrace(System.out);
out.println(t);
} finally {
atg.deployment.server.SecurityManager.becomeNOTTheSuperDood();
try {
if (td != null) td.end(rollback);
} catch (TransactionDemarcationException e) {
e.printStackTrace();
}
}
%>
</div>
</dsp:page>
<%@page import = "atg.epub.project.*" %>
<%@page import = "atg.dtm.*" %>
<%@page import = "atg.nucleus.*" %>
<%@page import = "javax.transaction.*" %>
<link href="style.css" type="text/css" rel="stylesheet"/>
<div style = "padding: 5px;">
<% boolean rollback = true;
TransactionManager tm=(TransactionManager)Nucleus.getGlobalNucleus().resolveName("/atg/dynamo/transaction/TransactionManager");
TransactionDemarcation td= new TransactionDemarcation();
try {
td.begin(tm);
atg.deployment.server.SecurityManager.becomeTheSuperDood();
ProcessHome processHome = ((ProcessHome) ProjectConstants.getPersistentHomes().getProcessHome());
String processId = request.getParameter("process_id");
if (processId == null) {
out.println("TRYING HYPNOSIS TO GUESS PROCESS ID..... FAILED. Try explicitly specifying a process_id request parameter. ");
return;
}
atg.epub.project.Process process =processHome.findById(processId);
if (process == null) {
out.println("wrong process_id parameter; not such process");
return;
}
Project project = process.getProject();
if (project == null) {
process.delete();
rollback = false;
out.println("Process was found but there was no project associated with it. Process was deleted successfully.");
return;
}
project.delete("publishing");
out.println("Process with id " + processId + " was found and deleted successfully.");
%>
<br/> <input type = "button"
onclick = "window.close()"
value = "Cancel/Close"
style = "font-size: 10px; background-color: #C3593C; color: white;"/> <% rollback = false;
} catch (Throwable t) {
t.printStackTrace(System.out);
out.println(t);
} finally {
atg.deployment.server.SecurityManager.becomeNOTTheSuperDood();
try {
if (td != null) td.end(rollback);
} catch (TransactionDemarcationException e) {
e.printStackTrace();
}
}
%>
</div>
</dsp:page>
2. Identify the process id from DB using the following query.
select process_id from epub_process where display_name='name_of_project';
3. Hit the delete process URL, and pass the process id through request header.
<BCC_URL_Including_HTTP_PORT>/<context-root>/delete-process.jsp?process_id=<process_id>
ex: http://localhost:7005/mybcc/delete-process.jsp?process_id=prc162001
4. Following message confirms that the entire project is deleted.
Awsome
ReplyDeletewe can also delete the project by running delete queries.
ReplyDeleteIs there any difference between these processes.
There is not much difference. Deleting project using front end would be useful to Business users, who are not comfort in SQL queries and also for those who dont have access to DB.
DeleteRegards,
Iranna