use of org.apache.struts.upload.FormFile in project head by mifos.
the class PictureFormFile method addFile.
@TransactionDemarcate(joinToken = true)
public ActionForward addFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
ClientCustActionForm actionForm = (ClientCustActionForm) form;
FormFile file = actionForm.getSelectedFile();
String fileName = actionForm.getSelectedFile().getFileName();
String fileContentType = actionForm.getSelectedFile().getContentType();
Integer fileSize = actionForm.getSelectedFile().getFileSize();
String fileDescription = actionForm.getSelectedFileDescription();
if (file != null) {
actionForm.getFiles().add(file);
actionForm.getFilesMetadata().add(new UploadedFileDto(fileName, fileContentType, fileSize, fileDescription));
}
return mapping.findForward(ActionForwards.load_success.toString());
}
use of org.apache.struts.upload.FormFile in project head by mifos.
the class ClientCustActionForm method clearMostButNotAllFieldsOnActionForm.
public void clearMostButNotAllFieldsOnActionForm() {
setDefaultFees(new ArrayList<ApplicableAccountFeeDto>());
setAdditionalFees(new ArrayList<ApplicableAccountFeeDto>());
setCustomFields(new ArrayList<CustomFieldDto>());
setFamilyNames(new ArrayList<ClientNameDetailDto>());
setFamilyDetails(new ArrayList<ClientFamilyDetailDto>());
setFamilyRelationship(new ArrayList<Short>());
setFamilyFirstName(new ArrayList<String>());
setFamilyMiddleName(new ArrayList<String>());
setFamilyLastName(new ArrayList<String>());
setFamilySecondLastName(new ArrayList<String>());
setFamilyDateOfBirthDD(new ArrayList<String>());
setFamilyDateOfBirthMM(new ArrayList<String>());
setFamilyDateOfBirthYY(new ArrayList<String>());
setFamilyGender(new ArrayList<Short>());
setFamilyLivingStatus(new ArrayList<Short>());
initializeFamilyMember();
addFamilyMember();
setAddress(new Address());
setDisplayName(null);
setDateOfBirthDD(null);
setDateOfBirthMM(null);
setDateOfBirthYY(null);
setGovernmentId(null);
setMfiJoiningDate(null);
setGlobalCustNum(null);
setCustomerId(null);
setExternalId(null);
setLoanOfficerId(null);
setLoanOfficerName("");
setFormedByPersonnel(null);
setTrained(null);
setTrainedDate(null);
setClientName(new ClientNameDetailDto());
setSpouseName(new ClientNameDetailDto());
setClientDetailView(new ClientPersonalDetailDto());
setNextOrPreview("next");
setQuestionGroups(null);
for (int i = 0; i < getSelectedOfferings().size(); i++) {
getSelectedOfferings().set(i, null);
}
setFiles(new ArrayList<FormFile>());
setFilesMetadata(new ArrayList<UploadedFileDto>());
}
use of org.apache.struts.upload.FormFile in project head by mifos.
the class BirtAdminDocumentUploadAction method upload.
@SuppressWarnings("unchecked")
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward upload(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
BirtAdminDocumentUploadActionForm uploadForm = (BirtAdminDocumentUploadActionForm) form;
FormFile formFile = uploadForm.getFile();
uploadFile(formFile);
AdminDocumentBO admindocBO = createOrUpdateAdminDocument(uploadForm.getAdminiDocumentTitle(), Short.valueOf("1"), formFile.getFileName());
AdminDocAccStateMixBO admindocaccstatemixBO = new AdminDocAccStateMixBO();
if (Short.valueOf(uploadForm.getAccountTypeId()).shortValue() <= 2) {
List<AccountStateEntity> masterList = (List<AccountStateEntity>) SessionUtils.getAttribute("SelectedStatus", request);
for (AccountStateEntity acc : masterList) {
admindocaccstatemixBO = new AdminDocAccStateMixBO();
admindocaccstatemixBO.setAccountStateID(acc);
admindocaccstatemixBO.setAdminDocumentID(admindocBO);
legacyAdminDocAccStateMixDao.createOrUpdate(admindocaccstatemixBO);
}
} else {
List<AccountActionEntity> masterList = (List<AccountActionEntity>) SessionUtils.getAttribute("SelectedStatus", request);
for (AccountActionEntity accountActionEntity : masterList) {
AdminDocAccActionMixBO adminDocAccActionMixBO = new AdminDocAccActionMixBO();
adminDocAccActionMixBO.setAccountAction(accountActionEntity);
adminDocAccActionMixBO.setAdminDocument(admindocBO);
legacyAdminDocumentDao.createOrUpdate(adminDocAccActionMixBO);
}
}
request.setAttribute("report", admindocBO);
return getViewBirtAdminDocumentPage(mapping, form, request, response);
}
use of org.apache.struts.upload.FormFile in project head by mifos.
the class BirtAdminDocumentUploadAction method uploadFile.
private void uploadFile(FormFile formFile) throws FileNotFoundException, IOException {
File dir = new File(viewOrganizationSettingsServiceFacade.getAdminDocumentStorageDirectory());
dir.mkdirs();
File file = new File(dir, formFile.getFileName());
InputStream is = formFile.getInputStream();
OutputStream os;
/*
* for test purposes, if the real path does not exist (if we're operating outside a deployed environment) the
* file is just written to a ByteArrayOutputStream which is not actually stored. !! This does not produce any
* sort of file that can be retirieved. !! it only allows us to perform the upload action.
*/
if (getServletRoot(getServlet()) != null) {
os = new FileOutputStream(file);
} else {
os = new ByteArrayOutputStream();
}
byte[] buffer = new byte[4096];
int bytesRead = 0;
while ((bytesRead = is.read(buffer, 0, 4096)) != -1) {
os.write(buffer, 0, bytesRead);
}
os.close();
is.close();
formFile.destroy();
}
use of org.apache.struts.upload.FormFile in project head by mifos.
the class BirtReportsUploadAction method uploadFile.
private void uploadFile(FormFile formFile) throws FileNotFoundException, IOException {
File dir = new File(getCustomReportStorageDirectory());
dir.mkdirs();
File file = new File(dir, formFile.getFileName());
InputStream is = formFile.getInputStream();
OutputStream os;
/*
* for test purposes, if the real path does not exist (if we're
* operating outside a deployed environment) the file is just written to
* a ByteArrayOutputStream which is not actually stored. !! This does
* not produce any sort of file that can be retirieved. !! it only
* allows us to perform the upload action.
*/
if (getServletRoot(getServlet()) != null) {
os = new FileOutputStream(file);
} else {
os = new ByteArrayOutputStream();
}
byte[] buffer = new byte[4096];
int bytesRead = 0;
while ((bytesRead = is.read(buffer, 0, 4096)) != -1) {
os.write(buffer, 0, bytesRead);
}
os.close();
is.close();
formFile.destroy();
}
Aggregations