当前位置: 首页>>代码示例>>Java>>正文


Java FileBean.getSize方法代码示例

本文整理汇总了Java中net.sourceforge.stripes.action.FileBean.getSize方法的典型用法代码示例。如果您正苦于以下问题:Java FileBean.getSize方法的具体用法?Java FileBean.getSize怎么用?Java FileBean.getSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sourceforge.stripes.action.FileBean的用法示例。


在下文中一共展示了FileBean.getSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
}
 
开发者ID:sergiomt,项目名称:zesped,代码行数:55,代码来源:UploadInvoice.java

示例2: 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);
}
 
开发者ID:sergiomt,项目名称:zesped,代码行数:51,代码来源:UploadBillNote.java


注:本文中的net.sourceforge.stripes.action.FileBean.getSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。