use of org.kuali.kfs.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.
the class PaymentApplicationForm method userCanInitiateAppAdjustment.
private boolean userCanInitiateAppAdjustment() {
final Document document = getDocument();
final DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(document);
final Person person = GlobalVariables.getUserSession().getPerson();
return documentAuthorizer.canInitiate(ArConstants.PAYMENT_APPLICATION_ADJUSTMENT_DOCUMENT_TYPE_CODE, person);
}
use of org.kuali.kfs.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method addInvoiceTransmissionNote.
@Override
public void addInvoiceTransmissionNote(ContractsGrantsInvoiceDocument document, String invoiceTransmissionMethod) {
Note note = new Note();
note.setNotePostedTimestampToCurrent();
String transmissionNotePattern = getConfigurationService().getPropertyValueAsString(ArKeyConstants.INVOICE_ADDRESS_TRANSMISSION_NOTE);
note.setNoteText(MessageFormat.format(transmissionNotePattern, GlobalVariables.getUserSession().getPrincipalName(), invoiceTransmissionMethod.toLowerCase(Locale.US)));
note.setNoteTypeCode(document.getNoteType().getCode());
Person systemUser = personService.getPersonByPrincipalName(KFSConstants.SYSTEM_USER);
note = noteService.createNote(note, document.getNoteTarget(), systemUser.getPrincipalId());
noteService.save(note);
document.addNote(note);
}
use of org.kuali.kfs.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.
the class ContractsGrantsInvoiceDocumentServiceImpl method buildAndAddInvoiceNote.
private Long buildAndAddInvoiceNote(ContractsGrantsInvoiceDocument document, byte[] reportStream, String customerAddressName, String outputFileName, String invoiceAddressPdfFinalNote, String watermarkText) throws IOException {
Note note = new Note();
note.setNotePostedTimestampToCurrent();
final String finalNotePattern = getConfigurationService().getPropertyValueAsString(invoiceAddressPdfFinalNote);
note.setNoteText(MessageFormat.format(finalNotePattern, document.getDocumentNumber(), customerAddressName));
note.setNoteTypeCode(KFSConstants.NoteTypeEnum.BUSINESS_OBJECT_NOTE_TYPE.getCode());
Person systemUser = personService.getPersonByPrincipalName(KFSConstants.SYSTEM_USER);
note = noteService.createNote(note, document.getNoteTarget(), systemUser.getPrincipalId());
if (StringUtils.isNotBlank(watermarkText)) {
try {
reportStream = PdfFormFillerUtil.createWatermarkOnFile(reportStream, watermarkText);
} catch (DocumentException e) {
addNoteForInvoiceReportFail(document);
}
}
Attachment attachment = attachmentService.createAttachment(note, outputFileName, ArConstants.TemplateUploadSystem.TEMPLATE_MIME_TYPE, reportStream.length, new ByteArrayInputStream(reportStream), KFSConstants.EMPTY_STRING);
note.setAttachment(attachment);
noteService.save(note);
attachment.setNoteIdentifier(note.getNoteIdentifier());
businessObjectService.save(attachment);
document.addNote(note);
return note.getNoteIdentifier();
}
use of org.kuali.kfs.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.
the class MaintenanceUtils method checkDocumentBlockingDocumentId.
public static void checkDocumentBlockingDocumentId(String blockingDocId, boolean throwExceptionIfLocked) {
// if we got nothing, then no docs are blocking, and we're done
if (StringUtils.isBlank(blockingDocId)) {
return;
}
if (MaintenanceUtils.LOG.isInfoEnabled()) {
MaintenanceUtils.LOG.info("Locking document found: docId = " + blockingDocId + ".");
}
// load the blocking locked document
WorkflowDocument lockedDocument = null;
try {
// occur, even though the exception would be caught here
if (KewApiServiceLocator.getWorkflowDocumentService().doesDocumentExist(blockingDocId)) {
/*
* CU Customization KFSPTS-23120 investigate NPE
* Moved the getPerson to a variable to more clearly see what aspect is causing the NPE
*/
try {
Person person = GlobalVariables.getUserSession().getPerson();
lockedDocument = KewApiServiceLocator.getWorkflowDocumentService().loadWorkflowDocument(blockingDocId, person);
} catch (NullPointerException npe) {
LOG.error("checkDocumentBlockingDocumentId, caught an NPE getting the locked document with blockingDocId: " + blockingDocId, npe);
throw npe;
}
}
} catch (Exception ex) {
// clean up the lock and notify the admins
MaintenanceUtils.LOG.error("Unable to retrieve locking document specified in the maintenance lock " + "table: " + blockingDocId, ex);
cleanOrphanLocks(blockingDocId, ex);
return;
}
if (lockedDocument == null) {
MaintenanceUtils.LOG.warn("Locking document header for " + blockingDocId + "came back null.");
cleanOrphanLocks(blockingDocId, null);
}
// if we can ignore the lock (see method notes), then exit cause we're done
if (lockCanBeIgnored(lockedDocument)) {
return;
}
// build the link URL for the blocking document
Map<String, String> parameters = new HashMap<>();
parameters.put(KRADConstants.PARAMETER_DOC_ID, blockingDocId);
parameters.put(KRADConstants.PARAMETER_COMMAND, KRADConstants.METHOD_DISPLAY_DOC_SEARCH_VIEW);
String blockingUrl = UrlFactory.parameterizeUrl(KRADServiceLocator.getKualiConfigurationService().getPropertyValueAsString(KFSConstants.APPLICATION_URL_KEY) + "/" + KRADConstants.DOC_HANDLER_ACTION, parameters);
if (MaintenanceUtils.LOG.isDebugEnabled()) {
MaintenanceUtils.LOG.debug("blockingUrl = '" + blockingUrl + "'");
MaintenanceUtils.LOG.debug("Maintenance record: " + lockedDocument.getApplicationDocumentId() + "is locked.");
}
String[] errorParameters = { blockingUrl, blockingDocId };
// ErrorMap instead.
if (throwExceptionIfLocked) {
// post an error about the locked document
GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, KFSKeyConstants.ERROR_MAINTENANCE_LOCKED, errorParameters);
throw new ValidationException("Maintenance Record is locked by another document.");
} else {
// Post a warning about the locked document.
GlobalVariables.getMessageMap().putWarning(KRADConstants.GLOBAL_MESSAGES, WARNING_MAINTENANCE_LOCKED, errorParameters);
}
}
Aggregations