本文整理汇总了Java中net.sourceforge.stripes.action.FileBean类的典型用法代码示例。如果您正苦于以下问题:Java FileBean类的具体用法?Java FileBean怎么用?Java FileBean使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileBean类属于net.sourceforge.stripes.action包,在下文中一共展示了FileBean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveUpload
import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
protected void saveUpload(HttpServletRequest req) {
StripesRequestWrapper stripesRequest =
StripesRequestWrapper.findStripesWrapper(req);
final FileBean fileBean = stripesRequest.getFileParameterValue(inputName);
if (fileBean != null) {
try {
newBlob(fileBean);
} catch (IOException e) {
logger.error("Could not read upload", e);
forgetBlob();
blobError = getText("elements.error.field.fileblob.uploadFailed");
try {
fileBean.delete();
} catch (IOException e1) {
logger.error("Could not delete FileBean", e1);
}
}
} else {
logger.debug("An update of a blob was requested, but nothing was uploaded. The previous value will be kept.");
keepOldBlob(req);
}
}
示例2: newBlob
import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
protected void newBlob(final FileBean fileBean) throws IOException {
blob = new Blob(generateNewCode()) {
@Override
public void dispose() {
super.dispose();
try {
fileBean.delete();
} catch (IOException e) {
logger.warn("Could not delete file bean", e);
}
}
};
blob.setInputStream(fileBean.getInputStream());
blob.setFilename(fileBean.getFileName());
blob.setContentType(fileBean.getContentType());
blob.setCreateTimestamp(new DateTime());
blob.setPropertiesLoaded(true);
}
示例3: getFileParameterValue
import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
/**
* Responsible for constructing a FileBean object for the named file parameter. If there is no
* file parameter with the specified name this method should return null.
*
* @param name the name of the file parameter
* @return a FileBean object wrapping the uploaded file
*/
public FileBean getFileParameterValue(String name) {
File file = this.multipart.getFile(name);
if (file != null) {
return new FileBean(file,
this.multipart.getContentType(name),
this.multipart.getOriginalFileName(name),
this.charset);
}
else {
return null;
}
}
示例4: getFileParameterValue
import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
/**
* Returns a FileBean representing an uploaded file with the form field name = "name".
* If the form field was present in the request, but no file was uploaded, this method will
* return null.
*
* @param name the form field name of type file
* @return a FileBean if a file was actually submitted by the user, otherwise null
*/
public FileBean getFileParameterValue(String name) {
if (this.multipart != null) {
return this.multipart.getFileParameterValue(name);
}
else {
return null;
}
}
示例5: getFileParameterValue
import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
/**
* Responsible for constructing a FileBean object for the named file parameter. If there is no
* file parameter with the specified name this method should return null.
*
* @param name the name of the file parameter
* @return a FileBean object wrapping the uploaded file
*/
public FileBean getFileParameterValue(String name) {
final FileItem item = this.files.get(name);
if (item == null
|| ((item.fileName == null || item.fileName.length() == 0) && item.size == 0)) {
return null;
}
else {
// Attempt to ensure the file name is just the basename with no path included
String filename = item.fileName;
int index;
if (WINDOWS_PATH_PREFIX_PATTERN.matcher(filename).find())
index = filename.lastIndexOf('\\');
else
index = filename.lastIndexOf('/');
if (index >= 0 && index + 1 < filename.length() - 1)
filename = filename.substring(index + 1);
// Use an anonymous inner subclass of FileBean that overrides all the
// methods that rely on having a File present, to use the FileItem
// created by commons upload instead.
return new FileBean(null, item.contentType, filename, this.charset) {
@Override
public long getSize() {
return item.size;
}
@Override
public InputStream getInputStream() throws IOException {
return item.contents.getInputStream();
}
@Override
public void delete() throws IOException {
item.contents.dispose();
}
};
}
}
示例6: getFileParameterValue
import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
/**
* Responsible for constructing a FileBean object for the named file parameter. If there is no
* file parameter with the specified name this method should return null.
*
* @param name the name of the file parameter
* @return a FileBean object wrapping the uploaded file
*/
public FileBean getFileParameterValue(String name) {
final FileItem item = this.files.get(name);
if (item == null
|| ((item.getName() == null || item.getName().length() == 0) && item.getSize() == 0)) {
return null;
}
else {
// Attempt to ensure the file name is just the basename with no path included
String filename = item.getName();
int index;
if (WINDOWS_PATH_PREFIX_PATTERN.matcher(filename).find())
index = filename.lastIndexOf('\\');
else
index = filename.lastIndexOf('/');
if (index >= 0 && index + 1 < filename.length() - 1)
filename = filename.substring(index + 1);
// Use an anonymous inner subclass of FileBean that overrides all the
// methods that rely on having a File present, to use the FileItem
// created by commons upload instead.
return new FileBean(null, item.getContentType(), filename, this.charset) {
@Override public long getSize() { return item.getSize(); }
@Override public InputStream getInputStream() throws IOException {
return item.getInputStream();
}
@Override public void save(File toFile) throws IOException {
try {
item.write(toFile);
delete();
}
catch (Exception e) {
if (e instanceof IOException) throw (IOException) e;
else {
IOException ioe = new IOException("Problem saving uploaded file.");
ioe.initCause(e);
throw ioe;
}
}
}
@Override
public void delete() throws IOException { item.delete(); }
};
}
}
示例7: getUpload
import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public FileBean getUpload() {
return upload;
}
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:4,代码来源:FileManagerCKEditorAction.java
示例8: setUpload
import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public void setUpload(FileBean upload) {
this.upload = upload;
}
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:4,代码来源:FileManagerCKEditorAction.java
示例9: getImageFile
import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public FileBean getImageFile() {
return imageFile;
}
示例10: setImageFile
import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public void setImageFile(FileBean imageFile) {
this.imageFile = imageFile;
}
示例11: getItems
import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public List<FileBean> getItems() {
return items;
}
示例12: setItems
import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public void setItems(List<FileBean> fbeans) {
items = fbeans;
}
示例13: upload
import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public Resolution upload() throws Exception {
Invoice invc = null;
capturedCount = 0;
final int nItems = (getItems()==null ? 0 : getItems().size());
if (nItems>0) {
Log.out.debug("InvoiceUpload "+String.valueOf(nItems)+" items found");
try {
connect(getSessionAttribute("nickname"), getSessionAttribute("password"));
Dms oDms = getSession().getDms();
Document rcpt = oDms.getDocument(getRecipientTaxPayer());
String sTaxPayerId = rcpt.type().name().equals("TaxPayer") ? getRecipientTaxPayer() : getSessionAttribute("taxpayer_docid");
TaxPayer txpy = new TaxPayer(getSession().getDms(), sTaxPayerId);
Invoices invs = txpy.invoices(getSession());
invc = invs.create(getSession(), getSessionAttribute("user_uuid"), getServiceFlavor(),
sTaxPayerId, getBillerTaxPayer(), getRecipientTaxPayer());
capureddocid = invc.id();
for (FileBean attachment : getItems()) {
if (attachment != null) {
if (attachment.getSize() > 0) {
InvoicePage page = invc.createPage(getSession(), attachment.getInputStream(), ++capturedCount, attachment.getFileName());
if (capturedCount==1) {
capuredpage1 = page.id();
}
attachment.delete();
} else {
ValidationError error = new SimpleError(attachment.getFileName()+ " is not a valid file." );
getContext().getValidationErrors().add("items" , error);
}
}
} // next
disconnect();
Log.out.debug("Done uploading items");
if (capturedCount>0) {
ThumbnailCreator.createThumbnailFor(capureddocid, capuredpage1);
}
} catch (Exception e) {
Log.out.error("InvoiceUpload.upload() "+e.getClass().getName()+" "+e.getMessage(), e);
getContext().getMessages().add(new SimpleMessage("ERROR "+e.getMessage(), items));
} finally { close(); }
} else {
Log.out.debug("InvoiceUpload no items found");
}
if (invc==null)
return new RedirectResolution("/error.jsp");
if (invc.getServiceFlavor().equals(CaptureServiceFlavor.BASIC))
return new ForwardResolution("EditInvoice.action?id="+invc.id());
else
return new ForwardResolution(FORM);
}
示例14: setItems
import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public void setItems(List<FileBean> fbeans) {
items = fbeans;
}
示例15: upload
import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public Resolution upload() throws Exception {
String sFwd;
Ticket tckt = null;
BillNote bill = null;
setCapturedCount(0);
final int nItems = (getItems()==null ? 0 : getItems().size());
if (nItems>0) {
Log.out.debug("UploadBillNote "+String.valueOf(nItems)+" items found");
try {
connect(getSessionAttribute("nickname"), getSessionAttribute("password"));
TaxPayer txpy = new TaxPayer(getSession().getDms(), getRecipientTaxPayer());
bill = txpy.billnotes(getSession()).forConcept(getSession(), getConcept(), getEmployee());
setCapturedPage1("");
for (FileBean attachment : getItems()) {
if (attachment != null) {
if (attachment.getSize() > 0) {
if (tckt==null) {
tckt = bill.createTicket(getSession(), getAccount());
setId(tckt.id());
FlashScope oFscope = FlashScope.getCurrent(getContext().getRequest(), true);
oFscope.put("ticket_docid", tckt.id());
}
TicketNote note = tckt.createNote(getSession(), attachment.getInputStream(), incCapturedCount(), attachment.getFileName());
if (getCapturedPage1().length()==0) setCapturedPage1(note.id());
attachment.delete();
} else {
ValidationError error = new SimpleError(attachment.getFileName()+ " is not a valid file." );
getContext().getValidationErrors().add("items" , error);
}
}
} // next
disconnect();
if (getCapturedCount()>0)
ThumbnailCreator.createThumbnailFor(getId(), getCapturedPage1());
sFwd = "EditBillNote.action?id="+tckt.id();
} catch (IllegalStateException e) {
Log.out.error("BillNoteUpload.upload() "+e.getClass().getName()+" "+e.getMessage(), e);
getContext().getMessages().add(new SimpleMessage("ERROR "+e.getMessage(), items));
sFwd = "error.jsp?e=couldnotloadticket";
} finally { close(); }
} else {
Log.out.debug("UploadBillNote no items found");
sFwd = "error.jsp?e=couldnotloadticket";
}
return new ForwardResolution(sFwd);
}