| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
package org.kuali.rice.edl.impl.components; |
| 18 |
|
|
| 19 |
|
import java.sql.Timestamp; |
| 20 |
|
import java.text.DateFormat; |
| 21 |
|
import java.util.ArrayList; |
| 22 |
|
import java.util.Collections; |
| 23 |
|
import java.util.Comparator; |
| 24 |
|
import java.util.Date; |
| 25 |
|
import java.util.Iterator; |
| 26 |
|
import java.util.List; |
| 27 |
|
import java.util.StringTokenizer; |
| 28 |
|
import java.util.regex.Matcher; |
| 29 |
|
import java.util.regex.Pattern; |
| 30 |
|
|
| 31 |
|
import javax.xml.parsers.DocumentBuilder; |
| 32 |
|
import javax.xml.parsers.DocumentBuilderFactory; |
| 33 |
|
import javax.xml.transform.Templates; |
| 34 |
|
import javax.xml.transform.TransformerConfigurationException; |
| 35 |
|
import javax.xml.xpath.XPath; |
| 36 |
|
import javax.xml.xpath.XPathConstants; |
| 37 |
|
import javax.xml.xpath.XPathExpressionException; |
| 38 |
|
import javax.xml.xpath.XPathFactory; |
| 39 |
|
|
| 40 |
|
import org.apache.commons.fileupload.FileItem; |
| 41 |
|
import org.apache.commons.lang.StringUtils; |
| 42 |
|
import org.apache.log4j.Logger; |
| 43 |
|
import org.kuali.rice.core.api.config.property.ConfigContext; |
| 44 |
|
import org.kuali.rice.core.api.services.CoreApiServiceLocator; |
| 45 |
|
import org.kuali.rice.core.framework.services.CoreFrameworkServiceLocator; |
| 46 |
|
import org.kuali.rice.core.mail.EmailBcList; |
| 47 |
|
import org.kuali.rice.core.mail.EmailBody; |
| 48 |
|
import org.kuali.rice.core.mail.EmailCcList; |
| 49 |
|
import org.kuali.rice.core.mail.EmailContent; |
| 50 |
|
import org.kuali.rice.core.mail.EmailFrom; |
| 51 |
|
import org.kuali.rice.core.mail.EmailSubject; |
| 52 |
|
import org.kuali.rice.core.mail.EmailToList; |
| 53 |
|
import org.kuali.rice.core.util.RiceConstants; |
| 54 |
|
import org.kuali.rice.core.util.XmlHelper; |
| 55 |
|
import org.kuali.rice.core.util.XmlJotter; |
| 56 |
|
import org.kuali.rice.edl.impl.EDLContext; |
| 57 |
|
import org.kuali.rice.edl.impl.EDLModelComponent; |
| 58 |
|
import org.kuali.rice.edl.impl.EDLXmlUtils; |
| 59 |
|
import org.kuali.rice.edl.impl.RequestParser; |
| 60 |
|
import org.kuali.rice.kew.dto.RouteHeaderDTO; |
| 61 |
|
import org.kuali.rice.kew.exception.WorkflowRuntimeException; |
| 62 |
|
import org.kuali.rice.kew.mail.EmailStyleHelper; |
| 63 |
|
import org.kuali.rice.kew.notes.Attachment; |
| 64 |
|
import org.kuali.rice.kew.notes.CustomNoteAttribute; |
| 65 |
|
import org.kuali.rice.kew.notes.Note; |
| 66 |
|
import org.kuali.rice.kew.notes.service.NoteService; |
| 67 |
|
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
| 68 |
|
import org.kuali.rice.kew.routeheader.service.RouteHeaderService; |
| 69 |
|
import org.kuali.rice.kew.service.KEWServiceLocator; |
| 70 |
|
import org.kuali.rice.kew.service.WorkflowDocument; |
| 71 |
|
import org.kuali.rice.kew.util.KEWConstants; |
| 72 |
|
import org.kuali.rice.kim.bo.Person; |
| 73 |
|
import org.kuali.rice.kim.service.KIMServiceLocator; |
| 74 |
|
import org.w3c.dom.Document; |
| 75 |
|
import org.w3c.dom.Element; |
| 76 |
|
|
| 77 |
|
import com.thoughtworks.xstream.XStream; |
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
@author |
| 84 |
|
|
| 85 |
|
|
|
|
|
| 0% |
Uncovered Elements: 506 (506) |
Complexity: 118 |
Complexity Density: 0.35 |
|
| 86 |
|
public class NoteConfigComponent implements EDLModelComponent { |
| 87 |
|
|
| 88 |
|
private static final Logger LOG = Logger.getLogger(NoteConfigComponent.class); |
| 89 |
|
|
| 90 |
|
private EmailStyleHelper emailStyleHelper = new EmailStyleHelper(); |
| 91 |
|
private String styleName; |
| 92 |
|
private String from; |
| 93 |
|
private List<String> to; |
| 94 |
|
private List<String> cc = new ArrayList<String>(); |
| 95 |
|
private List<String> bc = new ArrayList<String>(); |
| 96 |
|
private static final String DEFAULT_EMAIL_FROM_ADDRESS = CoreFrameworkServiceLocator.getParameterService().getParameterValueAsString(KEWConstants.KEW_NAMESPACE, "Mailer", "FROM_ADDRESS"); |
| 97 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 98 |
0
|
public void updateDOM(Document dom, Element configElement, EDLContext edlContext) {... |
| 99 |
0
|
NoteForm noteForm = new NoteForm(edlContext.getRequestParser()); |
| 100 |
0
|
WorkflowDocument document = (WorkflowDocument)edlContext.getRequestParser().getAttribute(RequestParser.WORKFLOW_DOCUMENT_SESSION_KEY); |
| 101 |
0
|
try { |
| 102 |
|
|
| 103 |
0
|
if (document != null) { |
| 104 |
0
|
noteForm.setDocId(document.getRouteHeaderId()); |
| 105 |
|
} |
| 106 |
0
|
establishNotes(noteForm, edlContext, dom); |
| 107 |
0
|
addNotes(dom, noteForm); |
| 108 |
|
} catch (Exception e) { |
| 109 |
0
|
throw new WorkflowRuntimeException("Caught exception processing notes", e); |
| 110 |
|
} |
| 111 |
|
|
| 112 |
|
} |
| 113 |
|
|
|
|
|
| 0% |
Uncovered Elements: 35 (35) |
Complexity: 9 |
Complexity Density: 0.47 |
|
| 114 |
0
|
public void establishNotes(NoteForm form, EDLContext edlContext, Document dom) throws Exception {... |
| 115 |
|
|
| 116 |
0
|
form.setCurrentUserName(edlContext.getUserSession().getPerson().getName()); |
| 117 |
0
|
form.setCurrentDate(getCurrentDate()); |
| 118 |
0
|
String methodToCall = form.getMethodToCall(); |
| 119 |
0
|
if (!org.apache.commons.lang.StringUtils.isEmpty(methodToCall)) { |
| 120 |
0
|
if ("save".equalsIgnoreCase(methodToCall)) { |
| 121 |
0
|
this.saveNote(form, edlContext, dom); |
| 122 |
0
|
} else if ("edit".equalsIgnoreCase(methodToCall)) { |
| 123 |
0
|
this.editNote(form); |
| 124 |
0
|
} else if ("add".equalsIgnoreCase(methodToCall)) { |
| 125 |
0
|
this.addNote(form); |
| 126 |
0
|
} else if ("cancel".equalsIgnoreCase(methodToCall)) { |
| 127 |
0
|
this.cancelEdit(form); |
| 128 |
0
|
} else if ("delete".equalsIgnoreCase(methodToCall)) { |
| 129 |
0
|
this.deleteNote(form); |
| 130 |
0
|
} else if ("sort".equalsIgnoreCase(methodToCall)) { |
| 131 |
0
|
this.sortNotes(form); |
| 132 |
0
|
} else if ("deleteAttachment".equalsIgnoreCase(methodToCall)) { |
| 133 |
0
|
this.deleteAttachment(form); |
| 134 |
|
} |
| 135 |
|
} |
| 136 |
0
|
retrieveNoteList(form, edlContext); |
| 137 |
|
|
| 138 |
|
} |
| 139 |
|
|
| 140 |
|
|
| 141 |
|
|
| 142 |
|
@param |
| 143 |
|
@param |
| 144 |
|
@throws |
| 145 |
|
|
| 146 |
|
|
|
|
|
| 0% |
Uncovered Elements: 55 (55) |
Complexity: 13 |
Complexity Density: 0.37 |
|
| 147 |
0
|
private void retrieveNoteList(NoteForm form, EDLContext edlContext) throws Exception {... |
| 148 |
0
|
if (form.getDocId() != null) { |
| 149 |
0
|
List allNotes = getNoteService().getNotesByRouteHeaderId(form.getDocId()); |
| 150 |
0
|
CustomNoteAttribute customNoteAttribute = null; |
| 151 |
0
|
DocumentRouteHeaderValue routeHeader = getRouteHeaderService().getRouteHeader(form.getDocId()); |
| 152 |
0
|
boolean canAddNotes = false; |
| 153 |
0
|
if (routeHeader != null) { |
| 154 |
0
|
customNoteAttribute = routeHeader.getCustomNoteAttribute(); |
| 155 |
0
|
if (customNoteAttribute != null) { |
| 156 |
0
|
customNoteAttribute.setUserSession(edlContext.getUserSession()); |
| 157 |
0
|
canAddNotes = customNoteAttribute.isAuthorizedToAddNotes(); |
| 158 |
|
} |
| 159 |
|
} |
| 160 |
0
|
Iterator notesIter = allNotes.iterator(); |
| 161 |
0
|
while (notesIter.hasNext()) { |
| 162 |
0
|
Note singleNote = (Note) notesIter.next(); |
| 163 |
0
|
singleNote.setNoteCreateLongDate(new Long(singleNote.getNoteCreateDate().getTime())); |
| 164 |
0
|
getAuthorData(singleNote); |
| 165 |
0
|
boolean canEditNote = false; |
| 166 |
0
|
if (customNoteAttribute != null) { |
| 167 |
0
|
canEditNote = customNoteAttribute.isAuthorizedToEditNote(singleNote); |
| 168 |
|
} |
| 169 |
0
|
singleNote.setAuthorizedToEdit(Boolean.valueOf(canEditNote)); |
| 170 |
0
|
if (form.getNoteIdNumber() != null && (form.getNoteIdNumber().intValue() == singleNote.getNoteId().intValue())) { |
| 171 |
0
|
singleNote.setEditingNote(Boolean.TRUE); |
| 172 |
|
} |
| 173 |
|
} |
| 174 |
0
|
if (form.getSortNotes() != null && form.getSortNotes().booleanValue()) { |
| 175 |
0
|
if (KEWConstants.Sorting.SORT_SEQUENCE_DSC.equalsIgnoreCase(form.getSortOrder())) { |
| 176 |
0
|
form.setSortOrder(KEWConstants.Sorting.SORT_SEQUENCE_ASC); |
| 177 |
0
|
form.setSortNotes(Boolean.FALSE); |
| 178 |
|
} else { |
| 179 |
0
|
form.setSortOrder(KEWConstants.Sorting.SORT_SEQUENCE_DSC); |
| 180 |
0
|
form.setSortNotes(Boolean.FALSE); |
| 181 |
|
} |
| 182 |
|
} else { |
| 183 |
0
|
form.setSortOrder(form.getSortOrder()); |
| 184 |
|
} |
| 185 |
0
|
form.setNoteList(sortNotes(allNotes, form.getSortOrder())); |
| 186 |
0
|
form.setNumberOfNotes(new Integer(allNotes.size())); |
| 187 |
0
|
form.setAuthorizedToAdd(new Boolean(canAddNotes)); |
| 188 |
0
|
form.setShowAdd(Boolean.TRUE); |
| 189 |
0
|
if (! canAddNotes) { |
| 190 |
0
|
form.setShowAdd(Boolean.FALSE); |
| 191 |
0
|
} else if (form.getNoteList().size() == 0) { |
| 192 |
|
|
| 193 |
|
} |
| 194 |
|
} |
| 195 |
|
} |
| 196 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 197 |
0
|
public void editNote(NoteForm form) throws Exception {... |
| 198 |
0
|
form.setShowEdit("yes"); |
| 199 |
|
|
| 200 |
|
|
| 201 |
|
|
| 202 |
0
|
form.getNote().setNoteCreateLongDate(new Long(form.getNote().getNoteCreateDate().getTime())); |
| 203 |
0
|
form.getNote().setNoteText(form.getNoteText()); |
| 204 |
|
|
| 205 |
|
} |
| 206 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 207 |
0
|
public void addNote(NoteForm form) throws Exception {... |
| 208 |
0
|
form.setShowEdit("no"); |
| 209 |
0
|
form.setNoteIdNumber(null); |
| 210 |
0
|
form.setShowAdd(Boolean.TRUE); |
| 211 |
|
|
| 212 |
|
|
| 213 |
|
} |
| 214 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 215 |
0
|
public void cancelEdit(NoteForm form) throws Exception{... |
| 216 |
0
|
form.setShowEdit("no"); |
| 217 |
0
|
form.setNote(new Note()); |
| 218 |
0
|
form.setNoteIdNumber(null); |
| 219 |
|
|
| 220 |
|
} |
| 221 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 222 |
0
|
public void deleteNote(NoteForm form) throws Exception{... |
| 223 |
0
|
Note noteToDelete = getNoteService().getNoteByNoteId(form.getNoteIdNumber()); |
| 224 |
0
|
getNoteService().deleteNote(noteToDelete); |
| 225 |
0
|
form.setShowEdit("no"); |
| 226 |
|
|
| 227 |
0
|
form.setNote(new Note()); |
| 228 |
0
|
form.setNoteIdNumber(null); |
| 229 |
|
} |
| 230 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 231 |
0
|
public void sortNotes(NoteForm form) throws Exception{... |
| 232 |
0
|
form.setShowEdit("no"); |
| 233 |
|
} |
| 234 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 235 |
0
|
public void deleteAttachment(NoteForm form) throws Exception{... |
| 236 |
0
|
Note note = getNoteService().getNoteByNoteId(form.getNoteIdNumber()); |
| 237 |
0
|
getNoteService().deleteAttachment((Attachment)note.getAttachments().remove(0)); |
| 238 |
|
} |
| 239 |
|
|
|
|
|
| 0% |
Uncovered Elements: 135 (135) |
Complexity: 34 |
Complexity Density: 0.36 |
|
| 240 |
0
|
public void saveNote(NoteForm form, EDLContext edlContext, Document dom) throws Exception {... |
| 241 |
0
|
Note noteToSave = null; |
| 242 |
0
|
if (form.getShowEdit()!= null && form.getShowEdit().equals("yes")) { |
| 243 |
|
|
| 244 |
0
|
noteToSave = getNoteService().getNoteByNoteId(form.getNoteIdNumber()); |
| 245 |
0
|
String noteText = form.getNoteText(); |
| 246 |
0
|
if (noteText != null){ |
| 247 |
0
|
noteToSave.setNoteText(noteText); |
| 248 |
|
} |
| 249 |
|
|
| 250 |
|
|
| 251 |
|
|
| 252 |
|
} else { |
| 253 |
0
|
noteToSave = new Note(); |
| 254 |
0
|
noteToSave.setNoteId(null); |
| 255 |
0
|
noteToSave.setRouteHeaderId(form.getDocId()); |
| 256 |
0
|
noteToSave.setNoteCreateDate(new Timestamp((new Date()).getTime())); |
| 257 |
0
|
noteToSave.setNoteAuthorWorkflowId(edlContext.getUserSession().getPrincipalId()); |
| 258 |
0
|
noteToSave.setNoteText(form.getAddText()); |
| 259 |
|
} |
| 260 |
0
|
CustomNoteAttribute customNoteAttribute = null; |
| 261 |
0
|
DocumentRouteHeaderValue routeHeader = getRouteHeaderService().getRouteHeader(noteToSave.getRouteHeaderId()); |
| 262 |
0
|
boolean canEditNote = false; |
| 263 |
0
|
boolean canAddNotes = false; |
| 264 |
0
|
if (routeHeader != null) { |
| 265 |
0
|
customNoteAttribute = routeHeader.getCustomNoteAttribute(); |
| 266 |
0
|
if (customNoteAttribute != null) { |
| 267 |
0
|
customNoteAttribute.setUserSession(edlContext.getUserSession()); |
| 268 |
0
|
canAddNotes = customNoteAttribute.isAuthorizedToAddNotes(); |
| 269 |
0
|
canEditNote = customNoteAttribute.isAuthorizedToEditNote(noteToSave); |
| 270 |
|
} |
| 271 |
|
} |
| 272 |
0
|
if ((form.getShowEdit()!=null && form.getShowEdit().equals("yes") && canEditNote) || |
| 273 |
|
((form.getShowEdit() == null || ! form.getShowEdit().equals("yes")) && canAddNotes)) { |
| 274 |
0
|
FileItem uploadedFile = (FileItem)form.getFile(); |
| 275 |
0
|
if (uploadedFile != null && org.apache.commons.lang.StringUtils.isNotBlank(uploadedFile.getName())) { |
| 276 |
0
|
Attachment attachment = new Attachment(); |
| 277 |
0
|
attachment.setAttachedObject(uploadedFile.getInputStream()); |
| 278 |
0
|
String internalFileIndicator=uploadedFile.getName(); |
| 279 |
0
|
int indexOfSlash = internalFileIndicator.lastIndexOf("/"); |
| 280 |
0
|
int indexOfBackSlash=internalFileIndicator.lastIndexOf("\\"); |
| 281 |
0
|
if(indexOfSlash>=0){ |
| 282 |
0
|
internalFileIndicator=internalFileIndicator.substring(indexOfSlash+1); |
| 283 |
|
}else{ |
| 284 |
0
|
if (indexOfBackSlash>=0){ |
| 285 |
0
|
internalFileIndicator=internalFileIndicator.substring(indexOfBackSlash+1); |
| 286 |
|
} |
| 287 |
|
} |
| 288 |
0
|
attachment.setFileName(internalFileIndicator); |
| 289 |
0
|
LOG.debug(internalFileIndicator); |
| 290 |
0
|
attachment.setMimeType(uploadedFile.getContentType()); |
| 291 |
0
|
attachment.setNote(noteToSave); |
| 292 |
0
|
noteToSave.getAttachments().add(attachment); |
| 293 |
|
} |
| 294 |
0
|
if(org.apache.commons.lang.StringUtils.isEmpty(noteToSave.getNoteText())&¬eToSave.getAttachments().size()==0){ |
| 295 |
0
|
if (form.getShowEdit()!=null && form.getShowEdit().equals("yes")) { |
| 296 |
0
|
form.setNote(new Note()); |
| 297 |
|
} else { |
| 298 |
0
|
form.setAddText(null); |
| 299 |
|
} |
| 300 |
0
|
form.setShowEdit("no"); |
| 301 |
0
|
form.setNoteIdNumber(null); |
| 302 |
|
|
| 303 |
0
|
EDLXmlUtils.addGlobalErrorMessage(dom, "Note has empty content"); |
| 304 |
0
|
return; |
| 305 |
|
} |
| 306 |
0
|
getNoteService().saveNote(noteToSave); |
| 307 |
|
|
| 308 |
|
|
| 309 |
|
|
| 310 |
0
|
boolean sendEmailOnNoteSave = false; |
| 311 |
|
|
| 312 |
0
|
Document edlDom = KEWServiceLocator.getEDocLiteService() |
| 313 |
|
.getDefinitionXml(edlContext.getEdocLiteAssociation()); |
| 314 |
0
|
XPath xpath = XPathFactory.newInstance().newXPath(); |
| 315 |
0
|
String xpathExpression = "//config/param[@name='sendEmailOnNoteSave']"; |
| 316 |
0
|
try { |
| 317 |
0
|
String match = (String) xpath.evaluate(xpathExpression, edlDom, XPathConstants.STRING); |
| 318 |
0
|
if (!StringUtils.isBlank(match) && match.equals("true")) { |
| 319 |
0
|
sendEmailOnNoteSave = true; |
| 320 |
|
} |
| 321 |
|
} catch (XPathExpressionException e) { |
| 322 |
0
|
throw new WorkflowRuntimeException( |
| 323 |
|
"Unable to evaluate sendEmailOnNoteSave xpath expression in NoteConfigComponent saveNote method" |
| 324 |
|
+ xpathExpression, e); |
| 325 |
|
} |
| 326 |
|
|
| 327 |
0
|
if (sendEmailOnNoteSave) { |
| 328 |
0
|
xpathExpression = "//data/version[@current='true']/field[@name='emailTo']/value"; |
| 329 |
0
|
String emailTo = xpath.evaluate(xpathExpression, dom); |
| 330 |
0
|
if (StringUtils.isBlank(emailTo)) { |
| 331 |
0
|
EDLXmlUtils.addGlobalErrorMessage(dom,"No email notifications were sent because EmailTo field was empty."); |
| 332 |
0
|
return; |
| 333 |
|
} |
| 334 |
|
|
| 335 |
0
|
if (isProduction()) { |
| 336 |
0
|
this.to = stringToList(emailTo); |
| 337 |
|
} else { |
| 338 |
0
|
String testAddress = getTestAddress(edlDom); |
| 339 |
0
|
if (StringUtils.isBlank(testAddress)) { |
| 340 |
0
|
EDLXmlUtils.addGlobalErrorMessage( |
| 341 |
|
dom, |
| 342 |
|
"No email notifications were sent because testAddress edl param was empty or not specified in a non production environment"); |
| 343 |
0
|
return; |
| 344 |
|
} |
| 345 |
0
|
this.to = stringToList(getTestAddress(edlDom)); |
| 346 |
|
} |
| 347 |
0
|
if (!isEmailListValid(this.to)) { |
| 348 |
0
|
EDLXmlUtils.addGlobalErrorMessage( |
| 349 |
|
dom, |
| 350 |
|
"No email notifications were sent because emailTo field contains invalid email address."); |
| 351 |
0
|
return; |
| 352 |
|
} |
| 353 |
0
|
String noteEmailStylesheet = ""; |
| 354 |
0
|
xpathExpression = "//config/param[@name='noteEmailStylesheet']"; |
| 355 |
0
|
try { |
| 356 |
0
|
noteEmailStylesheet = (String) xpath.evaluate( |
| 357 |
|
xpathExpression, edlDom, XPathConstants.STRING); |
| 358 |
0
|
if (StringUtils.isBlank(noteEmailStylesheet)) { |
| 359 |
0
|
EDLXmlUtils.addGlobalErrorMessage( |
| 360 |
|
dom, |
| 361 |
|
"No email notifications were sent because noteEmailStylesheet edl param was empty or not specified."); |
| 362 |
0
|
return; |
| 363 |
|
} |
| 364 |
|
} catch (XPathExpressionException e) { |
| 365 |
0
|
throw new WorkflowRuntimeException( |
| 366 |
|
"Unable to evaluate noteEmailStylesheet xpath expression in NoteConfigComponent method" |
| 367 |
|
+ xpathExpression, e); |
| 368 |
|
} |
| 369 |
0
|
this.styleName = noteEmailStylesheet; |
| 370 |
0
|
this.from = DEFAULT_EMAIL_FROM_ADDRESS; |
| 371 |
0
|
Document document = generateXmlInput(form, edlContext, edlDom); |
| 372 |
0
|
if (LOG.isDebugEnabled()) { |
| 373 |
0
|
LOG.debug("XML input for email tranformation:\n" + XmlJotter.jotNode(document)); |
| 374 |
|
} |
| 375 |
0
|
Templates style = loadStyleSheet(styleName); |
| 376 |
0
|
EmailContent emailContent = emailStyleHelper |
| 377 |
|
.generateEmailContent(style, document); |
| 378 |
0
|
if (!this.to.isEmpty()) { |
| 379 |
0
|
KEWServiceLocator.getMailer().sendEmail( |
| 380 |
|
new EmailFrom(from), new EmailToList(this.to), |
| 381 |
|
new EmailSubject(emailContent.getSubject()), |
| 382 |
|
new EmailBody(emailContent.getBody()), |
| 383 |
|
new EmailCcList(this.cc), new EmailBcList(this.bc), |
| 384 |
|
emailContent.isHtml()); |
| 385 |
|
} |
| 386 |
|
} |
| 387 |
|
|
| 388 |
|
|
| 389 |
|
} |
| 390 |
0
|
if (form.getShowEdit()!=null && form.getShowEdit().equals("yes")) { |
| 391 |
0
|
form.setNote(new Note()); |
| 392 |
|
} else { |
| 393 |
0
|
form.setAddText(null); |
| 394 |
|
} |
| 395 |
0
|
form.setShowEdit("no"); |
| 396 |
0
|
form.setNoteIdNumber(null); |
| 397 |
|
} |
| 398 |
|
|
| 399 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 400 |
0
|
protected String getTestAddress(Document edlDom) {... |
| 401 |
0
|
String testAddress = ""; |
| 402 |
0
|
XPath xpath = XPathFactory.newInstance().newXPath(); |
| 403 |
0
|
String xpathExpression = "//config/param[@name='testAddress']"; |
| 404 |
0
|
try { |
| 405 |
0
|
testAddress = (String) xpath.evaluate(xpathExpression, edlDom, XPathConstants.STRING); |
| 406 |
|
} catch (XPathExpressionException e) { |
| 407 |
0
|
throw new WorkflowRuntimeException("Unable to evaluate testAddressAttributeFound xpath expression in NoteConfigComponent getTestAddress method" + xpathExpression, e); |
| 408 |
|
} |
| 409 |
0
|
return testAddress; |
| 410 |
|
} |
| 411 |
|
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
|
| 412 |
0
|
protected Document generateXmlInput(NoteForm form, EDLContext edlContext, Document dom) throws Exception {... |
| 413 |
0
|
DocumentBuilder db = getDocumentBuilder(true); |
| 414 |
0
|
Document doc = db.newDocument(); |
| 415 |
0
|
Element emailNodeElem = doc.createElement("emailNode"); |
| 416 |
0
|
doc.appendChild(emailNodeElem); |
| 417 |
0
|
WorkflowDocument document = (WorkflowDocument)edlContext.getRequestParser().getAttribute(RequestParser.WORKFLOW_DOCUMENT_SESSION_KEY); |
| 418 |
|
|
| 419 |
|
|
| 420 |
|
|
| 421 |
0
|
RouteHeaderDTO routeHeaderVO = document.getRouteHeader(); |
| 422 |
0
|
XStream xstream = new XStream(); |
| 423 |
0
|
Element docElem = XmlHelper.readXml(xstream.toXML(routeHeaderVO)).getDocumentElement(); |
| 424 |
0
|
emailNodeElem.appendChild(doc.importNode(docElem, true)); |
| 425 |
0
|
emailNodeElem.appendChild(doc.importNode(dom.getDocumentElement(), true)); |
| 426 |
0
|
Element dConElem = XmlHelper.readXml(document.getDocumentContent().getApplicationContent()).getDocumentElement(); |
| 427 |
0
|
emailNodeElem.appendChild(doc.importNode(dConElem, true)); |
| 428 |
0
|
return doc; |
| 429 |
|
} |
| 430 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 431 |
0
|
protected DocumentBuilder getDocumentBuilder(boolean coalesce) throws Exception {... |
| 432 |
0
|
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); |
| 433 |
0
|
dbf.setCoalescing(coalesce); |
| 434 |
0
|
return dbf.newDocumentBuilder(); |
| 435 |
|
} |
| 436 |
|
|
| 437 |
|
|
| 438 |
|
|
| 439 |
|
|
| 440 |
|
|
| 441 |
|
|
| 442 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 443 |
0
|
protected boolean isProduction() {... |
| 444 |
0
|
return ConfigContext.getCurrentContextConfig().getProperty(KEWConstants.PROD_DEPLOYMENT_CODE).equalsIgnoreCase( |
| 445 |
|
ConfigContext.getCurrentContextConfig().getEnvironment()); |
| 446 |
|
} |
| 447 |
|
|
|
|
|
| 0% |
Uncovered Elements: 32 (32) |
Complexity: 5 |
Complexity Density: 0.21 |
|
| 448 |
0
|
protected boolean isEmailListValid(List<String> emailList) {... |
| 449 |
0
|
Pattern p = Pattern.compile("^\\.|^\\@"); |
| 450 |
0
|
Matcher m = null; |
| 451 |
0
|
for (String emailAddress : emailList) { |
| 452 |
0
|
m = p.matcher(emailAddress); |
| 453 |
0
|
if (m.find()) { |
| 454 |
|
|
| 455 |
0
|
return false; |
| 456 |
|
} |
| 457 |
|
} |
| 458 |
0
|
p = Pattern.compile("^www\\."); |
| 459 |
0
|
for (String emailAddress : emailList) { |
| 460 |
0
|
m = p.matcher(emailAddress); |
| 461 |
0
|
if (m.find()) { |
| 462 |
|
|
| 463 |
0
|
return false; |
| 464 |
|
} |
| 465 |
|
} |
| 466 |
|
|
| 467 |
0
|
p = Pattern.compile("[^A-Za-z0-9\\.\\@_\\-~#]+"); |
| 468 |
0
|
for (String emailAddress : emailList) { |
| 469 |
|
|
| 470 |
0
|
String e2 = stripComma(emailAddress); |
| 471 |
0
|
m = p.matcher(e2); |
| 472 |
0
|
if (m.find()) { |
| 473 |
|
|
| 474 |
0
|
return false; |
| 475 |
|
} |
| 476 |
|
} |
| 477 |
|
|
| 478 |
0
|
p = Pattern.compile("^([a-zA-Z0-9_\\-\\.]+)\\@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5})$"); |
| 479 |
0
|
for (String emailAddress : emailList) { |
| 480 |
0
|
String e2 = stripComma(emailAddress); |
| 481 |
0
|
m = p.matcher(e2); |
| 482 |
0
|
if (!m.find()) { |
| 483 |
|
|
| 484 |
0
|
return false; |
| 485 |
|
} |
| 486 |
|
} |
| 487 |
0
|
return true; |
| 488 |
|
} |
| 489 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 490 |
0
|
protected String stripComma(String s) {... |
| 491 |
0
|
String sNew = ""; |
| 492 |
0
|
if (s.endsWith(",")) { |
| 493 |
0
|
int x = s.length() -1; |
| 494 |
0
|
sNew = s.substring(0, x); |
| 495 |
|
} else { |
| 496 |
0
|
sNew = s; |
| 497 |
|
} |
| 498 |
0
|
return sNew; |
| 499 |
|
} |
| 500 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 501 |
0
|
protected List<String> stringToList(String to) {... |
| 502 |
0
|
List<String> recipientAddresses = new ArrayList<String>(); |
| 503 |
0
|
StringTokenizer st = new StringTokenizer(to, " ", false); |
| 504 |
0
|
while (st.hasMoreTokens()) { |
| 505 |
0
|
recipientAddresses.add(st.nextToken()); |
| 506 |
|
} |
| 507 |
0
|
return recipientAddresses; |
| 508 |
|
} |
| 509 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 510 |
0
|
protected Templates loadStyleSheet(String styleName) {... |
| 511 |
0
|
try { |
| 512 |
0
|
Templates style = CoreApiServiceLocator.getStyleService().getStyleAsTranslet(styleName); |
| 513 |
0
|
if (style == null) { |
| 514 |
0
|
throw new WorkflowRuntimeException("Failed to locate stylesheet with name '" + styleName + "'"); |
| 515 |
|
} |
| 516 |
0
|
return style; |
| 517 |
|
} catch (TransformerConfigurationException tce) { |
| 518 |
0
|
throw new WorkflowRuntimeException("Failed to load stylesheet with name '" + styleName + "'"); |
| 519 |
|
} |
| 520 |
|
} |
| 521 |
|
|
|
|
|
| 0% |
Uncovered Elements: 111 (111) |
Complexity: 22 |
Complexity Density: 0.32 |
|
| 522 |
0
|
public static void addNotes(Document doc, NoteForm form) {... |
| 523 |
0
|
Element noteForm = EDLXmlUtils.getOrCreateChildElement(doc.getDocumentElement(), "NoteForm", true); |
| 524 |
0
|
if (form.getShowEdit() != null) { |
| 525 |
0
|
Element showEdit = EDLXmlUtils.getOrCreateChildElement(noteForm, "showEdit", true); |
| 526 |
0
|
showEdit.appendChild(doc.createTextNode(form.getShowEdit().toLowerCase())); |
| 527 |
|
} else { |
| 528 |
0
|
Element showEdit = EDLXmlUtils.getOrCreateChildElement(noteForm, "showEdit", true); |
| 529 |
0
|
showEdit.appendChild(doc.createTextNode("no")); |
| 530 |
|
} |
| 531 |
0
|
if (form.getShowAdd() != null) { |
| 532 |
0
|
Element showAdd = EDLXmlUtils.getOrCreateChildElement(noteForm, "showAdd", true); |
| 533 |
0
|
showAdd.appendChild(doc.createTextNode(form.getShowAdd().toString().toLowerCase())); |
| 534 |
|
} |
| 535 |
0
|
if (form.getCurrentUserName() != null) { |
| 536 |
0
|
Element currentUserName = EDLXmlUtils.getOrCreateChildElement(noteForm, "currentUserName", true); |
| 537 |
0
|
currentUserName.appendChild(doc.createTextNode(form.getCurrentUserName())); |
| 538 |
|
} |
| 539 |
0
|
if (form.getCurrentDate() != null) { |
| 540 |
0
|
Element currentDate = EDLXmlUtils.getOrCreateChildElement(noteForm, "currentDate", true); |
| 541 |
0
|
currentDate.appendChild(doc.createTextNode(form.getCurrentDate())); |
| 542 |
|
} |
| 543 |
0
|
if (form.getNoteIdNumber() != null) { |
| 544 |
0
|
Element noteIdNumber = EDLXmlUtils.getOrCreateChildElement(noteForm, "noteIdNumber", true); |
| 545 |
0
|
noteIdNumber.appendChild(doc.createTextNode(form.getNoteIdNumber().toString())); |
| 546 |
|
} |
| 547 |
0
|
if (form.getDocId() != null) { |
| 548 |
0
|
Element docId = EDLXmlUtils.getOrCreateChildElement(noteForm, "docId", true); |
| 549 |
0
|
docId.appendChild(doc.createTextNode((form.getDocId().toString()))); |
| 550 |
|
} |
| 551 |
0
|
if (form.getSortNotes() != null) { |
| 552 |
0
|
Element sortNotes = EDLXmlUtils.getOrCreateChildElement(noteForm, "sortNotes", true); |
| 553 |
0
|
sortNotes.appendChild(doc.createTextNode(form.getSortNotes().toString().toLowerCase())); |
| 554 |
|
} |
| 555 |
0
|
if (form.getSortOrder() != null) { |
| 556 |
0
|
Element sortOrder = EDLXmlUtils.getOrCreateChildElement(noteForm, "sortOrder", true); |
| 557 |
0
|
sortOrder.appendChild(doc.createTextNode(form.getSortOrder().toUpperCase())); |
| 558 |
|
} |
| 559 |
0
|
if (form.getNumberOfNotes() != null) { |
| 560 |
0
|
Element numberOfNotes = EDLXmlUtils.getOrCreateChildElement(noteForm, "numberOfNotes", true); |
| 561 |
0
|
numberOfNotes.appendChild(doc.createTextNode(form.getNumberOfNotes().toString())); |
| 562 |
|
} |
| 563 |
0
|
if (form.getAuthorizedToAdd() != null) { |
| 564 |
0
|
Element authorizedToAdd = EDLXmlUtils.getOrCreateChildElement(noteForm, "authorizedToAdd", true); |
| 565 |
0
|
authorizedToAdd.appendChild(doc.createTextNode(form.getAuthorizedToAdd().toString().toLowerCase())); |
| 566 |
|
} |
| 567 |
0
|
if (form.getNumberOfNotes().intValue() > 0) { |
| 568 |
0
|
Element notes = EDLXmlUtils.getOrCreateChildElement(noteForm, "Notes", true); |
| 569 |
0
|
for (Iterator i = form.getNoteList().iterator(); i.hasNext();) { |
| 570 |
0
|
Note noteObj = (Note) i.next(); |
| 571 |
0
|
Element note = notes.getOwnerDocument().createElement("Note"); |
| 572 |
0
|
notes.appendChild(note); |
| 573 |
|
|
| 574 |
|
|
| 575 |
0
|
if (noteObj.getNoteId() != null) { |
| 576 |
0
|
Element noteId = EDLXmlUtils.getOrCreateChildElement(note, "noteId", true); |
| 577 |
0
|
noteId.appendChild(doc.createTextNode(noteObj.getNoteId().toString())); |
| 578 |
|
} |
| 579 |
0
|
if (noteObj.getFormattedCreateDate() != null) { |
| 580 |
0
|
Element formattedCreateDate = EDLXmlUtils.getOrCreateChildElement(note, "formattedCreateDate", true); |
| 581 |
0
|
formattedCreateDate.appendChild(doc.createTextNode(noteObj.getFormattedCreateDate())); |
| 582 |
|
} |
| 583 |
0
|
if (noteObj.getFormattedCreateTime() != null) { |
| 584 |
0
|
Element formattedCreateTime = EDLXmlUtils.getOrCreateChildElement(note, "formattedCreateTime", true); |
| 585 |
0
|
formattedCreateTime.appendChild(doc.createTextNode(noteObj.getFormattedCreateTime())); |
| 586 |
|
} |
| 587 |
0
|
if (noteObj.getNoteAuthorFullName() != null) { |
| 588 |
0
|
Element noteAuthorFullName = EDLXmlUtils.getOrCreateChildElement(note, "noteAuthorFullName", true); |
| 589 |
0
|
noteAuthorFullName.appendChild(doc.createTextNode(noteObj.getNoteAuthorFullName())); |
| 590 |
|
} |
| 591 |
0
|
if (noteObj.getNoteText() != null) { |
| 592 |
0
|
Element noteText = EDLXmlUtils.getOrCreateChildElement(note, "noteText", true); |
| 593 |
0
|
noteText.appendChild(doc.createTextNode(noteObj.getNoteText())); |
| 594 |
|
} |
| 595 |
0
|
if (noteObj.getEditingNote() != null) { |
| 596 |
0
|
Element editingNote = EDLXmlUtils.getOrCreateChildElement(note, "editingNote", true); |
| 597 |
0
|
editingNote.appendChild(doc.createTextNode(noteObj.getEditingNote().toString())); |
| 598 |
|
} |
| 599 |
0
|
if (noteObj.getAuthorizedToEdit() != null) { |
| 600 |
0
|
Element authorizedToEdit = EDLXmlUtils.getOrCreateChildElement(note, "authorizedToEdit", true); |
| 601 |
0
|
authorizedToEdit.appendChild(doc.createTextNode(noteObj.getAuthorizedToEdit().toString())); |
| 602 |
|
} |
| 603 |
0
|
if (!noteObj.getAttachments().isEmpty()) { |
| 604 |
0
|
Element attachments = EDLXmlUtils.getOrCreateChildElement(note, "attachments", true); |
| 605 |
0
|
for (Iterator j = noteObj.getAttachments().iterator(); j.hasNext();) { |
| 606 |
0
|
Attachment attachmentObj = (Attachment) j.next(); |
| 607 |
0
|
Element attachment = EDLXmlUtils.getOrCreateChildElement(attachments, "attachment", true); |
| 608 |
0
|
Element attachmentId = EDLXmlUtils.getOrCreateChildElement(attachment, "attachmentId", true); |
| 609 |
0
|
attachmentId.appendChild(doc.createTextNode(attachmentObj.getAttachmentId().toString())); |
| 610 |
0
|
Element fileName = EDLXmlUtils.getOrCreateChildElement(attachment, "fileName", true); |
| 611 |
0
|
fileName.appendChild(doc.createTextNode(attachmentObj.getFileName())); |
| 612 |
|
} |
| 613 |
|
} |
| 614 |
|
} |
| 615 |
|
} |
| 616 |
|
|
| 617 |
|
} |
| 618 |
|
|
|
|
|
| 0% |
Uncovered Elements: 98 (98) |
Complexity: 42 |
Complexity Density: 0.82 |
|
| 619 |
|
private static class NoteForm { |
| 620 |
|
private String showEdit; |
| 621 |
|
private Boolean showAdd; |
| 622 |
|
private Long noteIdNumber; |
| 623 |
|
private Integer numberOfNotes = new Integer(0); |
| 624 |
|
private String sortOrder = "DESCENDING"; |
| 625 |
|
private Boolean sortNotes; |
| 626 |
|
private String currentUserName; |
| 627 |
|
private String currentDate; |
| 628 |
|
private Boolean authorizedToAdd; |
| 629 |
|
private List noteList; |
| 630 |
|
private String addText; |
| 631 |
|
private Long idInEdit; |
| 632 |
|
private Note note; |
| 633 |
|
private String noteText; |
| 634 |
|
private Long docId; |
| 635 |
|
private String methodToCall; |
| 636 |
|
private FileItem file; |
| 637 |
|
|
|
|
|
| 0% |
Uncovered Elements: 29 (29) |
Complexity: 8 |
Complexity Density: 0.47 |
|
| 638 |
0
|
public NoteForm(RequestParser requestParser) {... |
| 639 |
|
|
| 640 |
0
|
showEdit = requestParser.getParameterValue("showEdit"); |
| 641 |
0
|
if (!org.apache.commons.lang.StringUtils.isEmpty(requestParser.getParameterValue("showAdd"))) { |
| 642 |
0
|
showAdd = Boolean.valueOf(requestParser.getParameterValue("showAdd")); |
| 643 |
|
} |
| 644 |
0
|
if (!org.apache.commons.lang.StringUtils.isEmpty(requestParser.getParameterValue("noteIdNumber"))) { |
| 645 |
0
|
noteIdNumber = Long.valueOf(requestParser.getParameterValue("noteIdNumber")); |
| 646 |
|
} |
| 647 |
0
|
methodToCall = requestParser.getParameterValue("methodToCall"); |
| 648 |
0
|
sortOrder = "DESCENDING"; |
| 649 |
0
|
if (!org.apache.commons.lang.StringUtils.isEmpty(requestParser.getParameterValue("sortNotes"))) { |
| 650 |
0
|
sortNotes = Boolean.valueOf(requestParser.getParameterValue("sortNotes")); |
| 651 |
|
} |
| 652 |
0
|
addText = requestParser.getParameterValue("addText"); |
| 653 |
0
|
noteText = requestParser.getParameterValue("noteText"); |
| 654 |
0
|
if (!org.apache.commons.lang.StringUtils.isEmpty(requestParser.getParameterValue("idInEdit"))) { |
| 655 |
0
|
idInEdit = Long.valueOf(requestParser.getParameterValue("idInEdit")); |
| 656 |
|
} |
| 657 |
0
|
if (noteIdNumber != null) { |
| 658 |
0
|
note = KEWServiceLocator.getNoteService().getNoteByNoteId(noteIdNumber); |
| 659 |
|
} |
| 660 |
0
|
if (requestParser.getUploadList() != null && ! requestParser.getUploadList().isEmpty()) { |
| 661 |
0
|
file = (FileItem)requestParser.getUploadList().get(0); |
| 662 |
|
} |
| 663 |
|
} |
| 664 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 665 |
0
|
public String getAddText() {... |
| 666 |
0
|
return addText; |
| 667 |
|
} |
| 668 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 669 |
0
|
public void setAddText(String addText) {... |
| 670 |
0
|
this.addText = addText; |
| 671 |
|
} |
| 672 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 673 |
0
|
public Boolean getAuthorizedToAdd() {... |
| 674 |
0
|
return authorizedToAdd; |
| 675 |
|
} |
| 676 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 677 |
0
|
public void setAuthorizedToAdd(Boolean authorizedToAdd) {... |
| 678 |
0
|
this.authorizedToAdd = authorizedToAdd; |
| 679 |
|
} |
| 680 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 681 |
0
|
public String getCurrentDate() {... |
| 682 |
0
|
return currentDate; |
| 683 |
|
} |
| 684 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 685 |
0
|
public void setCurrentDate(String currentDate) {... |
| 686 |
0
|
this.currentDate = currentDate; |
| 687 |
|
} |
| 688 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 689 |
0
|
public String getCurrentUserName() {... |
| 690 |
0
|
return currentUserName; |
| 691 |
|
} |
| 692 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 693 |
0
|
public void setCurrentUserName(String currentUserName) {... |
| 694 |
0
|
this.currentUserName = currentUserName; |
| 695 |
|
} |
| 696 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 697 |
0
|
public Long getIdInEdit() {... |
| 698 |
0
|
return idInEdit; |
| 699 |
|
} |
| 700 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 701 |
0
|
public void setIdInEdit(Long idInEdit) {... |
| 702 |
0
|
this.idInEdit = idInEdit; |
| 703 |
|
} |
| 704 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 705 |
0
|
public Note getNote() {... |
| 706 |
0
|
return note; |
| 707 |
|
} |
| 708 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 709 |
0
|
public void setNote(Note note) {... |
| 710 |
0
|
this.note = note; |
| 711 |
|
} |
| 712 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 713 |
0
|
public Long getNoteIdNumber() {... |
| 714 |
0
|
return noteIdNumber; |
| 715 |
|
} |
| 716 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 717 |
0
|
public void setNoteIdNumber(Long noteIdNumber) {... |
| 718 |
0
|
this.noteIdNumber = noteIdNumber; |
| 719 |
|
} |
| 720 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 721 |
0
|
public List getNoteList() {... |
| 722 |
0
|
return noteList; |
| 723 |
|
} |
| 724 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 725 |
0
|
public void setNoteList(List noteList) {... |
| 726 |
0
|
this.noteList = noteList; |
| 727 |
|
} |
| 728 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 729 |
0
|
public String getNoteText() {... |
| 730 |
0
|
return noteText; |
| 731 |
|
} |
| 732 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 733 |
0
|
public void setNoteText(String noteText) {... |
| 734 |
0
|
this.noteText = noteText; |
| 735 |
|
} |
| 736 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 737 |
0
|
public Integer getNumberOfNotes() {... |
| 738 |
0
|
return numberOfNotes; |
| 739 |
|
} |
| 740 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 741 |
0
|
public void setNumberOfNotes(Integer numberOfNotes) {... |
| 742 |
0
|
this.numberOfNotes = numberOfNotes; |
| 743 |
|
} |
| 744 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 745 |
0
|
public Boolean getShowAdd() {... |
| 746 |
0
|
return showAdd; |
| 747 |
|
} |
| 748 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 749 |
0
|
public void setShowAdd(Boolean showAdd) {... |
| 750 |
0
|
this.showAdd = showAdd; |
| 751 |
|
} |
| 752 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 753 |
0
|
public String getShowEdit() {... |
| 754 |
0
|
return showEdit; |
| 755 |
|
} |
| 756 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 757 |
0
|
public void setShowEdit(String showEdit) {... |
| 758 |
0
|
this.showEdit = showEdit; |
| 759 |
|
} |
| 760 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 761 |
0
|
public Boolean getSortNotes() {... |
| 762 |
0
|
return sortNotes; |
| 763 |
|
} |
| 764 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 765 |
0
|
public void setSortNotes(Boolean sortNotes) {... |
| 766 |
0
|
this.sortNotes = sortNotes; |
| 767 |
|
} |
| 768 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 769 |
0
|
public String getSortOrder() {... |
| 770 |
0
|
return sortOrder; |
| 771 |
|
} |
| 772 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 773 |
0
|
public void setSortOrder(String sortOrder) {... |
| 774 |
0
|
this.sortOrder = sortOrder; |
| 775 |
|
} |
| 776 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 777 |
0
|
public Long getDocId() {... |
| 778 |
0
|
return docId; |
| 779 |
|
} |
| 780 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 781 |
0
|
public void setDocId(Long docId) {... |
| 782 |
0
|
this.docId = docId; |
| 783 |
|
} |
| 784 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 785 |
0
|
public String getMethodToCall() {... |
| 786 |
0
|
return methodToCall; |
| 787 |
|
} |
| 788 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 789 |
0
|
public void setMethodToCall(String methodToCall) {... |
| 790 |
0
|
this.methodToCall = methodToCall; |
| 791 |
|
} |
| 792 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 793 |
0
|
public FileItem getFile() {... |
| 794 |
0
|
return file; |
| 795 |
|
} |
| 796 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 797 |
0
|
public void setFile(FileItem file) {... |
| 798 |
0
|
this.file = file; |
| 799 |
|
} |
| 800 |
|
} |
| 801 |
|
|
| 802 |
|
|
| 803 |
|
|
| 804 |
|
@param |
| 805 |
|
@param |
| 806 |
|
@return |
| 807 |
|
|
| 808 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 809 |
0
|
private List sortNotes(List allNotes, String sortOrder) {... |
| 810 |
0
|
final int returnCode = KEWConstants.Sorting.SORT_SEQUENCE_DSC.equalsIgnoreCase(sortOrder) ? -1 : 1; |
| 811 |
|
|
| 812 |
0
|
try { |
| 813 |
0
|
Collections.sort(allNotes, |
| 814 |
|
new Comparator() { |
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 815 |
0
|
public int compare(Object o1, Object o2) {... |
| 816 |
0
|
Timestamp date1 = ((Note) o1).getNoteCreateDate(); |
| 817 |
0
|
Timestamp date2 = ((Note) o2).getNoteCreateDate(); |
| 818 |
|
|
| 819 |
0
|
if (date1.before(date2)) { |
| 820 |
0
|
return returnCode * -1; |
| 821 |
0
|
} else if (date1.after(date2)) { |
| 822 |
0
|
return returnCode; |
| 823 |
|
} else { |
| 824 |
0
|
return 0; |
| 825 |
|
} |
| 826 |
|
} |
| 827 |
|
}); |
| 828 |
|
} catch (Throwable e) { |
| 829 |
0
|
LOG.error(e.getMessage(), e); |
| 830 |
|
} |
| 831 |
0
|
return allNotes; |
| 832 |
|
} |
| 833 |
|
|
| 834 |
|
|
| 835 |
|
|
| 836 |
|
@param |
| 837 |
|
@throws |
| 838 |
|
|
| 839 |
|
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 5 |
Complexity Density: 0.42 |
|
| 840 |
0
|
private void getAuthorData(Note note) throws Exception {... |
| 841 |
0
|
Person workflowUser = null; |
| 842 |
0
|
String id = ""; |
| 843 |
0
|
if (note != null && note.getNoteAuthorWorkflowId() != null && ! "".equalsIgnoreCase(note.getNoteAuthorWorkflowId())) { |
| 844 |
0
|
workflowUser = KIMServiceLocator.getPersonService().getPerson(note.getNoteAuthorWorkflowId()); |
| 845 |
0
|
id = note.getNoteAuthorWorkflowId(); |
| 846 |
|
} |
| 847 |
0
|
if (workflowUser != null) { |
| 848 |
0
|
note.setNoteAuthorFullName(workflowUser.getName()); |
| 849 |
0
|
note.setNoteAuthorEmailAddress(workflowUser.getEmailAddress()); |
| 850 |
0
|
note.setNoteAuthorNetworkId(workflowUser.getPrincipalName()); |
| 851 |
|
} else { |
| 852 |
0
|
note.setNoteAuthorFullName(id + " (Name not Available)"); |
| 853 |
0
|
note.setNoteAuthorEmailAddress("Not Available"); |
| 854 |
0
|
note.setNoteAuthorNetworkId("Not Available"); |
| 855 |
|
} |
| 856 |
|
} |
| 857 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 858 |
0
|
public String getCurrentDate() {... |
| 859 |
0
|
Date currentDate = new Date(); |
| 860 |
0
|
DateFormat dateFormat = RiceConstants.getDefaultDateFormat(); |
| 861 |
0
|
return dateFormat.format(currentDate); |
| 862 |
|
} |
| 863 |
|
|
| 864 |
|
|
| 865 |
|
|
| 866 |
|
@return |
| 867 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 868 |
0
|
private NoteService getNoteService() {... |
| 869 |
0
|
return (NoteService) KEWServiceLocator.getService(KEWServiceLocator.NOTE_SERVICE); |
| 870 |
|
} |
| 871 |
|
|
| 872 |
|
|
| 873 |
|
|
| 874 |
|
@return |
| 875 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 876 |
0
|
private RouteHeaderService getRouteHeaderService() {... |
| 877 |
0
|
return (RouteHeaderService) KEWServiceLocator.getService(KEWServiceLocator.DOC_ROUTE_HEADER_SRV); |
| 878 |
|
} |
| 879 |
|
} |