SupportFacadeHome supportFacade = (SupportFacadeHome)CVUtility.getHomeObject(
"com.centraview.support.supportfacade.SupportFacadeHome", "SupportFacade");
request.setAttribute(SupportConstantKeys.TYPEOFSUBMODULE, "Knowledgebase");
KnowledgeVO kVO = new KnowledgeVO();
SupportFacade remote = null;
int kbId = -1;
try {
String rowId = request.getParameter("rowId");
if (rowId != null) {
if (rowId.indexOf("*") > -1) {
String elements[] = rowId.split("\\*");
if (elements.length != 2)
throw new Exception("No row selected.");
kbId = Integer.parseInt(elements[0]);
} else {
kbId = Integer.parseInt(rowId);
}
} else {
throw new Exception("No row selected.");
}
remote = supportFacade.create();
remote.setDataSource(dataSource);
kVO = remote.getKB(individualID, kbId);
ArrayList categoryList = remote.getAllCategory(individualID);
request.setAttribute("CATEGORYVOARRAY", categoryList);
} catch (Exception e) {
logger.error("[Exception] [ViewKnowledgebaseHandler.execute Calling SupportFacade] ", e);
}
int ownerID = 0;
if (kVO != null) {
kbForm.setTitle(kVO.getTitle());
kbForm.setDetail(kVO.getDetail().replaceAll("\n","<br/>"));
kbForm.setCategory(new Integer(kVO.getCatid()).toString());
kbForm.setRowId(new Integer(kbId).toString());
kbForm.setParentcategory(new Integer(kVO.getParent()).toString());
kbForm.setStatus(kVO.getStatus());
kbForm.setPublishToCustomerView(kVO.getPublishToCustomerView());
ownerID = kVO.getOwner();
// Condition if the record status is Publish then Only Owner can update
// it.
// Other user can't update it.
// thats why we will disable the Edit button
boolean editFlag = false;
if (kVO.getStatus() != null && kVO.getStatus().equals("PUBLISH")) {
AuthorizationHome homeAuthorization = (AuthorizationHome)CVUtility.getHomeObject(
"com.centraview.administration.authorization.AuthorizationHome", "Authorization");
try {
Authorization remoteAuthorization = homeAuthorization.create();
remoteAuthorization.setDataSource(dataSource);
editFlag = remoteAuthorization.canPerformRecordOperation(individualID, "KnowledgeBase",
kbId, ModuleFieldRightMatrix.UPDATE_RIGHT);
} catch (Exception e) {
logger.error("[Exception] [ViewKnowledgebaseHandler.execute Calling Authorization] ", e);
}
} else if (individualID == ownerID) {
editFlag = true;
}
request.setAttribute("showEditRecordButton", new Boolean(editFlag));
}
request.setAttribute("showPermissionButton", new Boolean("true"));
String show = (String)request.getAttribute("show");
String typeOfOperation = (String)request.getAttribute(Constants.TYPEOFOPERATION);
if (typeOfOperation == null)
typeOfOperation = request.getParameter(Constants.TYPEOFOPERATION);
if (typeOfOperation != null) {
if (typeOfOperation.equalsIgnoreCase("editkb")) {
FORWARD_final = ".view.support.knowledgebase.edit";
if (show != null) {
kbForm.setTitle("");
kbForm.setDetail("");
}
// Get all categories and recurively process them for there parent/child
// relationships.
ArrayList flatList = remote.getAllCategory(individualID);
ArrayList categoryList = new ArrayList();
categoryList.add(new DDNameValue(1, "Knowledgebase"));
Iterator iter = flatList.iterator();
while (iter.hasNext()) {