Java Code Examples for org.apache.wicket.util.resource.ResourceStreamNotFoundException

The following examples show how to use org.apache.wicket.util.resource.ResourceStreamNotFoundException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: yes-cart   Source File: SitemapXmlResource.java    License: Apache License 2.0 6 votes vote down vote up
SitemapResource(final InputStream stream) {
    super(new AbstractResourceStream() {

        /** {@inheritDoc} */
        @Override
        public String getContentType() {
            return "text/xml";
        }

        /** {@inheritDoc} */
        @Override
        public InputStream getInputStream() throws ResourceStreamNotFoundException {
            return stream;
        }

        /** {@inheritDoc} */
        @Override
        public void close() throws IOException {
            stream.close();
        }
    });
}
 
Example 2
Source Project: yes-cart   Source File: RobotsTxtResource.java    License: Apache License 2.0 6 votes vote down vote up
RobotsResource(final InputStream stream) {
    super(new AbstractResourceStream() {

        /** {@inheritDoc} */
        @Override
        public String getContentType() {
            return "text/plain";
        }

        /** {@inheritDoc} */
        @Override
        public InputStream getInputStream() throws ResourceStreamNotFoundException {
            return stream;
        }

        /** {@inheritDoc} */
        @Override
        public void close() throws IOException {
            stream.close();
        }
    });
}
 
Example 3
Source Project: onedev   Source File: CssConcatResourceBundleReference.java    License: MIT License 5 votes vote down vote up
@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("\n".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;
}
 
Example 4
Source Project: onedev   Source File: JavaScriptConcatResourceBundleReference.java    License: MIT License 5 votes vote down vote up
@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(";\n".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;
}
 
Example 5
Source Project: ontopia   Source File: OccurrenceWebResource.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public InputStream getInputStream() throws ResourceStreamNotFoundException {
  try {
    return new Base64InputStream(new ReaderInputStream(reader, "utf-8"), false);
  } catch (UnsupportedEncodingException e) {
    throw new OntopiaRuntimeException(e);
  }
}
 
Example 6
Source Project: syncope   Source File: HttpResourceStream.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public InputStream getInputStream()
        throws ResourceStreamNotFoundException {

    return responseHolder.getInputStream() == null
            ? new ByteArrayInputStream(new byte[0])
            : responseHolder.getInputStream();
}
 
Example 7
Source Project: webanno   Source File: InputStreamResourceStream.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public InputStream getInputStream() throws ResourceStreamNotFoundException
{
    return inputStream;
}
 
Example 8
Source Project: webanno   Source File: PairwiseCodingAgreementTable.java    License: Apache License 2.0 4 votes vote down vote up
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 {
                                CodingAgreementResult result = PairwiseCodingAgreementTable.this
                                        .getModelObject().getStudy(aKey1, aKey2);
                                
                                switch (formatField.getModelObject()) {
                                case CSV:
                                    return AgreementUtils.generateCsvReport(result);
                                case DEBUG:
                                    return generateDebugReport(result);
                                default:
                                    throw new IllegalStateException("Unknown export format ["
                                            + formatField.getModelObject() + "]");
                                }
                            }
                            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" + formatField.getModelObject().getExtension());
        }
    };      
}
 
Example 9
Source Project: webanno   Source File: PairwiseCodingAgreementTable.java    License: Apache License 2.0 4 votes vote down vote up
private IResourceStream exportAllAgreements()
    {
        return new AbstractResourceStream()
        {
            private static final long serialVersionUID = 1L;

            @Override
            public InputStream getInputStream()
                throws ResourceStreamNotFoundException
            {
                AnnotationFeature feature = getModelObject().getFeature();
                DefaultAgreementTraits traits = getModelObject().getTraits();
                
                Map<String, List<CAS>> casMap = casMapSupplier.get();

                List<DiffAdapter> adapters = CasDiff.getDiffAdapters(annotationService,
                        asList(feature.getLayer()));

                CasDiff diff = doDiff(adapters, traits.getLinkCompareBehavior(), casMap);

//                AgreementResult agreementResult = AgreementUtils.makeStudy(diff,
//                        feature.getLayer().getName(), feature.getName(),
//                        pref.excludeIncomplete, casMap);
                // TODO: for the moment, we always include incomplete annotations during this
                // export.
                CodingAgreementResult agreementResult = makeCodingStudy(diff,
                        feature.getLayer().getName(), feature.getName(), false, casMap);
                
                try {
                    return AgreementUtils.generateCsvReport(agreementResult);
                }
                catch (Exception e) {
                    // FIXME Is there some better error handling here?
                    LOG.error("Unable to generate report", e);
                    throw new ResourceStreamNotFoundException(e);
                }
            }

            @Override
            public void close()
                throws IOException
            {
                // Nothing to do
            }
        };
    }
 
Example 10
public InputStream getInputStream() throws ResourceStreamNotFoundException
{
  return new ByteArrayInputStream(content);
}
 
Example 11
public InputStream getInputStream() throws ResourceStreamNotFoundException {
    return (new ByteArrayInputStream(content));
}