本文整理汇总了Java中org.apache.wicket.util.resource.ResourceStreamNotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java ResourceStreamNotFoundException类的具体用法?Java ResourceStreamNotFoundException怎么用?Java ResourceStreamNotFoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResourceStreamNotFoundException类属于org.apache.wicket.util.resource包,在下文中一共展示了ResourceStreamNotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResource
import org.apache.wicket.util.resource.ResourceStreamNotFoundException; //导入依赖的package包/类
@Override
public IResource getResource() {
ConcatBundleResource bundleResource = new ConcatBundleResource(getProvidedResources()) {
@Override
protected byte[] readAllResources(List<IResourceStream> resources)
throws IOException, ResourceStreamNotFoundException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
for (IResourceStream curStream : resources) {
IOUtils.copy(curStream.getInputStream(), output);
output.write(";".getBytes());
}
byte[] bytes = output.toByteArray();
if (getCompressor() != null) {
String nonCompressed = new String(bytes, "UTF-8");
bytes = getCompressor().compress(nonCompressed).getBytes("UTF-8");
}
return bytes;
}
};
ITextResourceCompressor compressor = getCompressor();
if (compressor != null) {
bundleResource.setCompressor(compressor);
}
return bundleResource;
}
示例2: getResourceStream
import org.apache.wicket.util.resource.ResourceStreamNotFoundException; //导入依赖的package包/类
@Override
public IResourceStream getResourceStream() {
final InputStream byteStream = initStream();
if (byteStream == null) {
return null;
}
IResourceStream resourceStream = new AbstractResourceStream(){
private static final long serialVersionUID = 1L;
@Override
public String getContentType() {
return contentType;
}
@Override
public InputStream getInputStream() throws ResourceStreamNotFoundException {
return byteStream;
}
@Override
public void close() throws IOException {
byteStream.close();
}
};
return resourceStream;
}
示例3: notFound
import org.apache.wicket.util.resource.ResourceStreamNotFoundException; //导入依赖的package包/类
public static FileStoreResourceStream notFound() {
return new FileStoreResourceStream(new File("")) {
private static final long serialVersionUID = 1L;
@Override
public InputStream getInputStream() throws ResourceStreamNotFoundException {
throw new ResourceStreamNotFoundException();
}
};
}
示例4: getInputStream
import org.apache.wicket.util.resource.ResourceStreamNotFoundException; //导入依赖的package包/类
@Override
@Nullable
public InputStream getInputStream() {
try {
return new FilterInputStream(resourceStream.getInputStream()) {
@Override
public void close() throws IOException {
resourceStream.close(); // The wicket way: close the resource stream, not the input stream
}
};
} catch (ResourceStreamNotFoundException e) {
LOGGER.error("Error while getting a resource for CSS parsing", e);
return null; // The phloc way: return null, do not throw exceptions
}
}
示例5: getInputStream
import org.apache.wicket.util.resource.ResourceStreamNotFoundException; //导入依赖的package包/类
@Override
public InputStream getInputStream()
throws ResourceStreamNotFoundException {
try {
execute();
return responseEntity.getContent();
} catch (Exception e) {
throw new ResourceStreamNotFoundException(e);
}
}
示例6: getResourceStream
import org.apache.wicket.util.resource.ResourceStreamNotFoundException; //导入依赖的package包/类
/**
* Hook method providing the actual resource stream.
*
* @return the stream.
*/
protected IResourceStream getResourceStream()
{
return new AbstractResourceStream() {
private static final long serialVersionUID1 = 1L;
InputStream inStream;
@Override
public InputStream getInputStream()
throws ResourceStreamNotFoundException
{
try {
inStream = new FileInputStream(fileName);
}
catch (IOException e) {
throw new ResourceStreamNotFoundException(e);
}
return inStream;
}
@Override
public void close() throws IOException {
inStream.close();
inStream = null;
FileUtils.forceDelete(new File(fileName));
}
};
}
示例7: getInputStream
import org.apache.wicket.util.resource.ResourceStreamNotFoundException; //导入依赖的package包/类
@Override
public InputStream getInputStream() throws ResourceStreamNotFoundException {
try {
return new Base64InputStream(new ReaderInputStream(reader, "utf-8"), false);
} catch (UnsupportedEncodingException e) {
throw new OntopiaRuntimeException(e);
}
}
示例8: getImageData
import org.apache.wicket.util.resource.ResourceStreamNotFoundException; //导入依赖的package包/类
@Override
protected byte[] getImageData(Attributes attributes) {
Long attrUserId = getUserId(attributes);
int attrMaxSize = getMaxDimension(attributes);
try {
BufferedImage im;
BufferedImage thumb;
Path userPicturePath = UserProfilePictureUploadHelper.getUserPicturePath(attrUserId);
if (attrUserId != null && userPicturePath != null) {
im = ImageIO.read(userPicturePath.toFile());
setLastModifiedTime(Time.millis(userPicturePath.toFile().lastModified()));
} else {
setLastModifiedTime(Time.millis(75675677));
im = ImageIO.read(defaultProfilePictureRef.getCacheableResourceStream().getInputStream());
}
if (im.getWidth() > attrMaxSize || im.getHeight() > attrMaxSize) {
// TODO add caching, currently every request scales the image!!
thumb = Scalr.resize(im, Scalr.Method.ULTRA_QUALITY, Scalr.Mode.AUTOMATIC, attrMaxSize);
} else {
thumb = im;
}
byte[] bytes;
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
ImageIO.write(thumb, "PNG", baos);
bytes = baos.toByteArray();
}
return bytes;
} catch (IOException | ResourceStreamNotFoundException ignored) {
}
return null;
}
示例9: getInputStream
import org.apache.wicket.util.resource.ResourceStreamNotFoundException; //导入依赖的package包/类
@Override
public InputStream getInputStream()
throws ResourceStreamNotFoundException {
return inputStream == null
? new ByteArrayInputStream(new byte[0])
: inputStream;
}
示例10: openResourceStream
import org.apache.wicket.util.resource.ResourceStreamNotFoundException; //导入依赖的package包/类
protected InputStream openResourceStream(IResourceStream rstream) {
if (rstream == null)
return null;
try {
return rstream.getInputStream();
} catch (ResourceStreamNotFoundException rsnfx) {
return null;
}
}
示例11: getInputStream
import org.apache.wicket.util.resource.ResourceStreamNotFoundException; //导入依赖的package包/类
@Override
public InputStream getInputStream() throws ResourceStreamNotFoundException {
return stream;
}
示例12: makeDownloadBehavior
import org.apache.wicket.util.resource.ResourceStreamNotFoundException; //导入依赖的package包/类
private Behavior makeDownloadBehavior(final String aKey1, final String aKey2)
{
return new AjaxEventBehavior("click")
{
private static final long serialVersionUID = 1L;
@Override
protected void onEvent(AjaxRequestTarget aTarget)
{
AJAXDownload download = new AJAXDownload() {
private static final long serialVersionUID = 1L;
@Override
protected IResourceStream getResourceStream()
{
return new AbstractResourceStream() {
private static final long serialVersionUID = 1L;
@Override
public InputStream getInputStream()
throws ResourceStreamNotFoundException
{
try {
AgreementResult result = AgreementTable.this.getModelObject()
.getStudy(aKey1, aKey2);
switch (settings.getObject().exportFormat) {
case CSV:
return AgreementUtils.generateCsvReport(result);
case DEBUG:
return generateDebugReport(result);
default:
throw new IllegalStateException("Unknown export format ["
+ settings.getObject().exportFormat + "]");
}
}
catch (Exception e) {
// FIXME Is there some better error handling here?
LOG.error("Unable to generate agreement report", e);
throw new ResourceStreamNotFoundException(e);
}
}
@Override
public void close()
throws IOException
{
// Nothing to do
}
};
}
};
getComponent().add(download);
download.initiate(aTarget,
"agreement" + settings.getObject().exportFormat.getExtension());
}
};
}
示例13: downloadHtopTable
import org.apache.wicket.util.resource.ResourceStreamNotFoundException; //导入依赖的package包/类
private void downloadHtopTable(Item<UIUserForList> item, final UIUserForList user) {
Link<Void> downloadHotpTableLink = new Link<Void>("download-hotp-table") {
@Override
public void onClick() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
hotpProvider.outputSequenceForDownload(user.getUsername(), os);
} catch (IOException e) {
throw new IllegalStateException(e);
}
final byte[] bytes = os.toByteArray();
IResourceStream resourceStream = new AbstractResourceStream() {
@Override
public Time lastModifiedTime() {
return Time.now();
}
@Override
public Bytes length() {
return Bytes.bytes(bytes.length);
}
@Override
public InputStream getInputStream() throws ResourceStreamNotFoundException {
return new ByteArrayInputStream(bytes);
}
@Override
public String getContentType() {
return "application/vnd.ms-excel";
}
@Override
public void close() throws IOException {
}
};
getRequestCycle().replaceAllRequestHandlers(new ResourceStreamRequestHandler(resourceStream,
hotpProvider.getSequenceForDownloadFileName(user.getUsername())));
}
};
downloadHotpTableLink.setVisible(hotpProvider.outputsSequenceForDownload());
item.add(downloadHotpTableLink);
}
示例14: getInputStream
import org.apache.wicket.util.resource.ResourceStreamNotFoundException; //导入依赖的package包/类
public InputStream getInputStream() throws ResourceStreamNotFoundException
{
return new ByteArrayInputStream(content);
}
示例15: getInputStream
import org.apache.wicket.util.resource.ResourceStreamNotFoundException; //导入依赖的package包/类
public InputStream getInputStream() throws ResourceStreamNotFoundException {
return (new ByteArrayInputStream(content));
}