Package org.ocpsoft.rewrite.exception

Examples of org.ocpsoft.rewrite.exception.RewriteException


               stream = new BufferedInputStream(new FileInputStream(file));
               log.debug("Streaming from file [" + file + "] to response.");
               Response.write(stream).perform(event, context);
            }
            catch (Exception e) {
               throw new RewriteException("Error streaming file.", e);
            }
            finally
            {
               if (stream != null)
                  try {
                     stream.close();
                  }
                  catch (IOException e) {
                     throw new RewriteException("Error closing stream.", e);
                  }
            }
         }

         @Override
View Full Code Here


               file.delete();
               try {
                  file.createNewFile();
               }
               catch (IOException e) {
                  throw new RewriteException("Could not create file for Stream operation", e);
               }
            }

            Response.withOutputStreamWrappedBy(new ResponseStreamWrapper() {

               @Override
               public OutputStream wrap(HttpServletRewrite rewrite, OutputStream outputStream)
               {
                  try {
                     BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(file));
                     rewrite.getRequest().setAttribute(STREAM_KEY, stream);
                     log.debug("Cloning response OutputStream to file [" + file + "]");
                     return new MultiOutputStream(stream, outputStream);
                  }
                  catch (FileNotFoundException e) {
                     throw new RewriteException("Could not wrap stream", e);
                  }
               }

               @Override
               public void finish(HttpServletRewrite rewrite)
               {
                  try {
                     OutputStream stream = (OutputStream) rewrite.getRequest().getAttribute(STREAM_KEY);
                     if (stream != null)
                     {
                        log.debug("Closing cloned file [" + file + "] OutputStream");
                        stream.flush();
                        stream.close();
                     }

                  }
                  catch (Exception e) {
                     throw new RewriteException("Could not close stream", e);
                  }
               }
            }).perform(event, context);
         }
View Full Code Here

         event.getResponse().setContentLength(contents.length);
         event.getResponse().addHeader("Content-Encoding", "gzip");
      }
      catch (IOException e) {
         throw new RewriteException("Failed to GZIP compress output content: ", e);
      }

   }
View Full Code Here

         GZIPOutputStream stream = new GZIPOutputStream(outputStream);
         rewrite.getRequest().setAttribute(STREAM_KEY, stream);
         return stream;
      }
      catch (IOException e) {
         throw new RewriteException("Could not wrap OutputStream", e);
      }
   }
View Full Code Here

            stream.flush();
            stream.finish();
         }
      }
      catch (IOException e) {
         throw new RewriteException("Could not finish GZip Encoding", e);
      }
   }
View Full Code Here

         try {
            externalContext.redirect(redirectUrl);
            return true;
         }
         catch (IOException e) {
            throw new RewriteException("Could not redirect to [" + redirectUrl + "]", e);
         }
      }

      // outcomes created by Navigate for redirects
      else if (outcome != null && outcome.startsWith(REDIRECT_PREFIX)) {

         // strip the prefix to get the context-relative URL
         String relativeUrl = outcome.substring(REDIRECT_PREFIX.length());

         // add the context path
         String absoluteUrl = prependContextPath(externalContext, relativeUrl);

         // rewrite the URL
         String rewrittenUrl = externalContext.encodeActionURL(absoluteUrl);

         // send the redirect
         try {
            externalContext.redirect(rewrittenUrl);
            return true;
         }
         catch (IOException e) {
            throw new RewriteException("Could not redirect to [" + rewrittenUrl + "]", e);
         }

      }

      return false;
View Full Code Here

               else
                  return false;
            }
         }
         catch (Exception e) {
            throw new RewriteException("Failed to bind value [" + value + "] to binding [" + binding + "]", e);
         }
      }

      for (Operation operation : operations) {
         context.addPreOperation(operation);
View Full Code Here

                     throw new IllegalStateException(
                              "Cannot issue INCLUDE directive within JSF lifecycle. Not supported.");
                  }
               }
               catch (Exception e) {
                  throw new RewriteException("", e);
               }
            }

         }
      });
View Full Code Here

   {
      assertParameterExists(name);
      Parameter<?> result = getParameterStore().get(name, new DefaultParameter(name));
      if (result instanceof ConfigurableParameter)
         return (ConfigurableParameter<?>) result;
      throw new RewriteException("Cannot configure read-only parameter [" + name + "].");
   }
View Full Code Here

                           if (handler.handles(operation.getEvent()))
                              handler.handleResult(operation.getEvent());
                        }
                     }
                     catch (Exception e) {
                        throw new RewriteException("Failed to handle PhaseOperation [" + operation + "]", e);
                     }
                  }

               });
      return flow;
View Full Code Here

TOP

Related Classes of org.ocpsoft.rewrite.exception.RewriteException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.