protected void initializeNotePaseUserNames(List<CoiDisclosureNotepad> notepads) { for (CoiDisclosureNotepad notePad : notepads) { Person person = this.getPersonService().getPersonByPrincipalName(notePad.getUpdateUser()); notePad.setUpdateUserFullName( person == null ? String.format(PERSON_NOT_FOUND_FORMAT_STRING, notePad.getUpdateUser()) : person.getName()); if (StringUtils.isNotBlank(notePad.getCreateUser())) { Person creator = this.getPersonService().getPersonByPrincipalName(notePad.getCreateUser()); notePad.setCreateUserFullName( creator == null ? String.format(PERSON_NOT_FOUND_FORMAT_STRING, notePad.getCreateUser()) : creator.getName()); } else { notePad.setCreateUserFullName(""); } } }
public String getDisplayName() { if (isUserRequest()) { Person person = getPerson(); if (person != null) { return person.getName(); } } else if (isGroupRequest()) { Group group = getGroup(); if (group != null) { return group.getName(); } else { return getGroupId(); } } else if (isRoleRequest()) { return getRoleName(); } return ""; }
/** * build the descriptive information of the given account. The information includes account name * and project director's name if any * * @param chartOfAccountsCode the given chart of accounts code * @param accountNumber the given account number * @return the descriptive information of the given account */ public static String buildAccountInfo(Account account) { if (ObjectUtils.isNull(account)) { return KFSConstants.EMPTY_STRING; } String projectDirectorName = KFSConstants.EMPTY_STRING; try { ContractsAndGrantsModuleService contractsAndGrantsModuleService = SpringContext.getBean(ContractsAndGrantsModuleService.class); Person projectDirector = contractsAndGrantsModuleService.getProjectDirectorForAccount(account); projectDirectorName = projectDirector != null ? MessageFormat.format(" ({0})", projectDirector.getName()) : KFSConstants.EMPTY_STRING; } catch (Exception e) { LOG.error("Cannot find a project director for the account:" + account); } return MessageFormat.format("{0}{1}", account.getAccountName(), projectDirectorName); }
/** * This method returns the full name of the update user. * * @return */ public String getUpdateUserName() { Person updateUser = KraServiceLocator.getService(PersonService.class) .getPersonByPrincipalName(this.getUpdateUser()); return updateUser != null ? updateUser.getName() : this.getUpdateUser(); }
/** * @see * org.kuali.kfs.sys.batch.service.BatchInputFileSetService#save(org.kuali.rice.kim.api.identity.Person, * org.kuali.kfs.sys.batch.BatchInputFileSetType, java.lang.String, java.util.Map) */ public Map<String, String> save( Person user, BatchInputFileSetType inputType, String fileUserIdentifier, Map<String, InputStream> typeToStreamMap) throws AuthorizationException, FileStorageException { // add a step for file directory checking prepareDirectories(getRequiredDirectoryNames()); Date creationDate = SpringContext.getBean(DateTimeService.class).getCurrentDate(); // check user is authorized to upload a file for the batch type Map<String, File> typeToTempFiles = copyStreamsToTemporaryDirectory( user, inputType, fileUserIdentifier, typeToStreamMap, creationDate); // null the map, because it's full of exhausted input streams that are useless typeToStreamMap = null; if (!inputType.validate(typeToTempFiles)) { deleteTempFiles(typeToTempFiles); LOG.error( "Upload file validation failed for user " + user.getName() + " identifier " + fileUserIdentifier); throw new ValidationException( "File validation failed: " + GlobalVariables.getMessageMap().getErrorMessages()); } byte[] buf = new byte[1024]; Map<String, String> typeToFileNames = new LinkedHashMap<String, String>(); Map<String, File> typeToFiles = new LinkedHashMap<String, File>(); try { for (String fileType : inputType.getFileTypes()) { File tempFile = typeToTempFiles.get(fileType); String saveFileName = inputType.getDirectoryPath(fileType) + File.separator + tempFile.getName(); try { InputStream fileContents = new FileInputStream(tempFile); File fileToSave = new File(saveFileName); copyInputStreamToFile(fileContents, fileToSave, buf); fileContents.close(); typeToFileNames.put(fileType, saveFileName); typeToFiles.put(fileType, fileToSave); } catch (IOException e) { LOG.error("unable to save contents to file " + saveFileName, e); throw new RuntimeException("errors encountered while writing file " + saveFileName, e); } } } finally { deleteTempFiles(typeToTempFiles); } String doneFileName = inputType.getDoneFileDirectoryPath() + File.separator + inputType.getDoneFileName(user, fileUserIdentifier, creationDate); File doneFile = new File(doneFileName); try { doneFile.createNewFile(); typeToFiles.put(KFSConstants.DONE_FILE_TYPE, doneFile); } catch (IOException e) { LOG.error("unable to create done file", e); throw new RuntimeException("unable to create done file", e); } inputType.process(typeToFiles); return typeToFileNames; }