use of com.autentia.tnt.businessobject.ActivityFile in project TNTConcept by autentia.
the class ActivityBean method saveExternalActivity.
public String saveExternalActivity() {
doBeforeSaveExternalActivity();
try {
String fileName = null;
if (uploadFile != null) {
fileName = FileUtil.getFileName(uploadFile.getName());
final ActivityFile file = new ActivityFile();
file.setInsertDate(new Date());
file.setUser(authManager.getCurrentPrincipal().getUser());
file.setExternalActivity(externalActivity);
file.setFile(fileName);
file.setFileMime(uploadFile.getContentType());
externalActivity.getFiles().add(file);
}
if (externalActivity.getId() == null) {
externalActivityManager.insertEntity(externalActivity);
} else {
externalActivityManager.updateEntity(externalActivity);
}
if (uploadFile != null) {
if (uploader.exists(Integer.toString(externalActivity.getId()), fileName)) {
// el fichero ya existe y lo versionamos
uploader.version(Integer.toString(externalActivity.getId()), fileName, uploadFile);
} else {
uploader.store(Integer.toString(externalActivity.getId()), uploadFile);
}
}
// Calls an after save action
String result = super.doAfterSave(NavigationResults.LIST);
return result;
} catch (IOException e) {
log.error("save - exception uploading field file", e);
FacesUtils.addErrorMessage("file", "error.fileTransfer", e.getMessage());
return null;
}
}
use of com.autentia.tnt.businessobject.ActivityFile in project TNTConcept by autentia.
the class ActivityBean method deleteFile.
public String deleteFile() {
UIData table = (UIData) FacesUtils.getComponent("activity:tabExternalActivity:list");
ActivityFile toDelete = (ActivityFile) table.getRowData();
externalActivity.getFiles().remove(toDelete);
return null;
}
Aggregations