/** * Description of the Method * * @param context Description of the Parameter * @return Description of the Return Value */ public String executeCommandAdd(ActionContext context) { Exception errorMessage = null; // Load project Connection db = null; try { FileFolder thisFolder = (FileFolder) context.getFormBean(); thisFolder.setParentId(context.getRequest().getParameter("parentId")); db = getConnection(context); // Load the ticket and the organization Ticket thisTicket = addTicket(context, db); int ticketId = thisTicket.getId(); // Check access permission to organization record if (!isRecordAccessPermitted(context, db, thisTicket.getOrgId())) { return ("PermissionError"); } // Build array of folder trails ProjectManagementFileFolders.buildHierarchy(db, context); context.getRequest().setAttribute("fileFolder", thisFolder); } catch (Exception e) { errorMessage = e; } finally { this.freeConnection(context, db); } if (errorMessage == null) { return ("AddOK"); } else { context.getRequest().setAttribute("Error", errorMessage); return ("SystemError"); } }
/** * Description of the Method * * @param context Description of the Parameter * @return Description of the Return Value */ public String executeCommandSave(ActionContext context) { Connection db = null; int resultCount = 0; boolean recordInserted = false; boolean isValid = false; try { db = this.getConnection(context); // Load the ticket and the organization Ticket thisTicket = addTicket(context, db); int ticketId = thisTicket.getId(); // Check access permission to organization record if (!isRecordAccessPermitted(context, db, thisTicket.getOrgId())) { return ("PermissionError"); } // Insert or update the folder FileFolder thisFolder = (FileFolder) context.getFormBean(); boolean newFolder = (thisFolder.getId() == -1); if (newFolder) { thisFolder.setEnteredBy(getUserId(context)); } thisFolder.setModifiedBy(getUserId(context)); thisFolder.setLinkModuleId(Constants.DOCUMENTS_TICKETS); thisFolder.setLinkItemId(ticketId); if (newFolder) { isValid = this.validateObject(context, db, thisFolder); if (isValid) { recordInserted = thisFolder.insert(db); } } else { isValid = this.validateObject(context, db, thisFolder); if (isValid) { resultCount = thisFolder.update(db); } } // Build array of folder trails ProjectManagementFileFolders.buildHierarchy(db, context); } catch (Exception e) { context.getRequest().setAttribute("Error", e); return ("SystemError"); } finally { this.freeConnection(context, db); } if (recordInserted) { return ("InsertOK"); } else if (resultCount == 1) { return ("UpdateOK"); } return (executeCommandAdd(context)); }