本文整理汇总了Java中org.richfaces.model.UploadedFile类的典型用法代码示例。如果您正苦于以下问题:Java UploadedFile类的具体用法?Java UploadedFile怎么用?Java UploadedFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UploadedFile类属于org.richfaces.model包,在下文中一共展示了UploadedFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyUploadedFile
import org.richfaces.model.UploadedFile; //导入依赖的package包/类
/**
* Copy uploaded file to byte array.
*
* @param uploadedFile
* @return byte array
* @throws IOException
*/
public static byte[] copyUploadedFile(UploadedFile uploadedFile) throws IOException {
InputStream in = uploadedFile.getInputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
int b;
while ((b = in.read()) != -1) {
out.write(b);
}
} finally {
out.close();
in.close();
}
return out.toByteArray();
}
示例2: setCustLogoImageImpl
import org.richfaces.model.UploadedFile; //导入依赖的package包/类
private void setCustLogoImageImpl(UploadedFile uploadedFile) {
removeLogoImage();
GluuImage newLogoImage = imageService.constructImage(currentPerson, uploadedFile);
newLogoImage.setStoreTemporary(true);
newLogoImage.setLogo(true);
try {
if (imageService.createImageFiles(newLogoImage)) {
this.curLogoImage = newLogoImage;
}
this.organization.setLogoImage(imageService.getXMLFromGluuImage(newLogoImage));
} catch (Exception ex) {
log.error("Failed to store icon image: '{0}'", ex, newLogoImage);
}
}
示例3: setFaviconImageImpl
import org.richfaces.model.UploadedFile; //导入依赖的package包/类
public void setFaviconImageImpl(UploadedFile uploadedFile) {
removeFaviconImage();
GluuImage newFaviconImage = imageService.constructImage(currentPerson, uploadedFile);
newFaviconImage.setStoreTemporary(true);
newFaviconImage.setLogo(false);
try {
if (imageService.createFaviconImageFiles(newFaviconImage)) {
this.curFaviconImage = newFaviconImage;
}
this.organization.setFaviconImage(imageService.getXMLFromGluuImage(newFaviconImage));
} catch (Exception ex) {
log.error("Failed to store favicon image: '{0}'", ex, newFaviconImage);
}
}
示例4: uploadImage
import org.richfaces.model.UploadedFile; //导入依赖的package包/类
public void uploadImage(FileUploadEvent event) {
UploadedFile uploadedFile = event.getUploadedFile();
this.uploadedImage = null;
try {
GluuImage image = imageService.constructImage((GluuCustomPerson) Component.getInstance("currentPerson"), uploadedFile);
image.setStoreTemporary(true);
if (imageService.createImageFiles(image)) {
this.uploadedImage = image;
}
} finally {
try {
uploadedFile.delete();
} catch (IOException ex) {
log.error("Failed to remove temporary image", ex);
}
}
}
示例5: updateCert
import org.richfaces.model.UploadedFile; //导入依赖的package包/类
private void updateCert(UploadedFile item) {
InputStream is = null;
OutputStream os = null;
try {
is = item.getInputStream();
os = new FileOutputStream(getTempCertDir() + this.uploadMarker);
BufferedOutputStream bos = new BufferedOutputStream(os);
IOUtils.copy(is, bos);
bos.flush();
} catch (IOException ex) {
log.error("Failed to upload certicicate", ex);
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(os);
}
}
示例6: updateTrsutStoreCert
import org.richfaces.model.UploadedFile; //导入依赖的package包/类
private void updateTrsutStoreCert(UploadedFile item) {
InputStream is = null;
try {
is = item.getInputStream();
String certificate = IOUtils.toString(is);
this.trustStoreCertificateUploadMarker.setCertificate(certificate);
this.trustStoreCertificateUploadMarker.setAddedAt(new Date());
this.trustStoreCertificateUploadMarker.setAddedBy(currentPerson.getDn());
} catch (IOException ex) {
log.error("Failed to upload key", ex);
} finally {
IOUtils.closeQuietly(is);
}
}
示例7: updateKey
import org.richfaces.model.UploadedFile; //导入依赖的package包/类
private void updateKey(UploadedFile item) {
InputStream is = null;
OutputStream os = null;
try {
is = item.getInputStream();
os = new FileOutputStream(getTempCertDir() + this.uploadMarker.replace("crt", "key"));
BufferedOutputStream bos = new BufferedOutputStream(os);
IOUtils.copy(is, bos);
bos.flush();
} catch (IOException ex) {
log.error("Failed to upload key", ex);
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(os);
}
}
示例8: uploadFile
import org.richfaces.model.UploadedFile; //导入依赖的package包/类
@Restrict("#{s:hasPermission('trust', 'access')}")
public String uploadFile(FileUploadEvent event) {
log.info("uploadFile() call for IDP");
try {
UploadedFile uploadedFile = event.getUploadedFile();
String filepath = asimbaService.saveIDPMetadataFile(uploadedFile, idp);
idp.setMetadataFile(filepath);
idp.setMetadataUrl("");
facesMessages.add(StatusMessage.Severity.INFO, "File uploaded");
} catch (Exception e) {
log.error("IDP metadata - uploadFile() exception", e);
facesMessages.add(StatusMessage.Severity.ERROR, "Requestor metadata - uploadFile exception", e);
return OxTrustConstants.RESULT_FAILURE;
}
return OxTrustConstants.RESULT_SUCCESS;
}
示例9: uploadFile
import org.richfaces.model.UploadedFile; //导入依赖的package包/类
@Restrict("#{s:hasPermission('trust', 'access')}")
public String uploadFile(FileUploadEvent event) {
log.info("uploadFile() Requestor", spRequestor);
try {
UploadedFile uploadedFile = event.getUploadedFile();
String filepath = asimbaService.saveSPRequestorMetadataFile(uploadedFile);
spRequestor.setMetadataFile(filepath);
spRequestor.setMetadataUrl("");
facesMessages.add(StatusMessage.Severity.INFO, "File uploaded");
} catch (Exception e) {
log.error("Requestor metadata - uploadFile() exception", e);
facesMessages.add(StatusMessage.Severity.ERROR, "Requestor metadata - uploadFile exception", e);
return OxTrustConstants.RESULT_FAILURE;
}
return OxTrustConstants.RESULT_SUCCESS;
}
示例10: copyUploadedFile
import org.richfaces.model.UploadedFile; //导入依赖的package包/类
/**
* Copy uploaded file to byte array.
*
* @param uploadedFile
* @return byte array
* @throws IOException
*/
public byte[] copyUploadedFile(UploadedFile uploadedFile) throws IOException {
InputStream in = uploadedFile.getInputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
int b;
while ((b = in.read()) != -1) {
out.write(b);
}
} finally {
out.close();
in.close();
}
return out.toByteArray();
}
示例11: setCustLogoImageImpl
import org.richfaces.model.UploadedFile; //导入依赖的package包/类
private void setCustLogoImageImpl(UploadedFile uploadedFile) {
removeLogoImage();
GluuImage newLogoImage = imageService.constructImage(currentPerson, uploadedFile);
newLogoImage.setStoreTemporary(true);
newLogoImage.setLogo(true);
try {
if (imageService.createImageFiles(newLogoImage)) {
this.curLogoImage = newLogoImage;
}
this.organization.setLogoImage(imageService.getXMLFromGluuImage(newLogoImage));
} catch (Exception ex) {
log.error("Failed to store icon image: '{}'", newLogoImage, ex);
}
}
示例12: setFaviconImageImpl
import org.richfaces.model.UploadedFile; //导入依赖的package包/类
public void setFaviconImageImpl(UploadedFile uploadedFile) {
removeFaviconImage();
GluuImage newFaviconImage = imageService.constructImage(currentPerson, uploadedFile);
newFaviconImage.setStoreTemporary(true);
newFaviconImage.setLogo(false);
try {
if (imageService.createFaviconImageFiles(newFaviconImage)) {
this.curFaviconImage = newFaviconImage;
}
this.organization.setFaviconImage(imageService.getXMLFromGluuImage(newFaviconImage));
} catch (Exception ex) {
log.error("Failed to store favicon image: '{}'", newFaviconImage, ex);
}
}
示例13: uploadImage
import org.richfaces.model.UploadedFile; //导入依赖的package包/类
public void uploadImage(FileUploadEvent event) {
UploadedFile uploadedFile = event.getUploadedFile();
this.uploadedImage = null;
try {
GluuImage image = imageService.constructImage(identity.getUser(), uploadedFile);
image.setStoreTemporary(true);
if (imageService.createImageFiles(image)) {
this.uploadedImage = image;
}
} finally {
try {
uploadedFile.delete();
} catch (IOException ex) {
log.error("Failed to remove temporary image", ex);
}
}
}
示例14: processFileUpload
import org.richfaces.model.UploadedFile; //导入依赖的package包/类
@Override
public void processFileUpload(FileUploadEvent event)
{
UploadedFile uploadedFile = event.getUploadedFile();
try
{
String content = IOUtils.toString(uploadedFile.getInputStream());
FileInfo fileInfo = new FileInfo();
fileInfo.setName(uploadedFile.getName());
fileInfo.setContent(content);
fileInfo.setSessionId(sessionId);
fileInfo.setUser(sessionUser);
fileInfoEvent.fire(fileInfoService.create(fileInfo));
}
catch (IOException e)
{
// TODO: proper error handling
return;
}
}
示例15: constructImage
import org.richfaces.model.UploadedFile; //导入依赖的package包/类
/**
* Creates GluuImage object from uploaded file
*
* @param creator
* person uploading the file
* @param uploadedFile
* uploaded file
* @return GluuImage object
*/
public GluuImage constructImage(GluuCustomPerson creator, UploadedFile uploadedFile) {
GluuImage image = new GluuImage();
image.setUuid(RepositoryUtility.generateUUID());
image.setCreationDate(new Date());
image.setCreator(creator.getDn());
image.setSourceName(FilenameUtils.getName(uploadedFile.getName()));
image.setSourceContentType(uploadedFile.getContentType());
image.setSize(uploadedFile.getSize());
image.setData(uploadedFile.getData());
return image;
}