Package com.ocpsoft.pretty

Examples of com.ocpsoft.pretty.PrettyException


         /*
          * Assert that we have the proper number of parameters.
          */
         if (getParameterCount() != parameters.length)
         {
            throw new PrettyException("Invalid number of path parameters supplied for pattern: " + originalPattern
                     + ", expected <" + getParameterCount() + ">, but got <" + parameters.length + ">");
         }

         /*
          * Build the result URL
          */
         int paramIndex = 0;
         List<String> resultSegments = new ArrayList<String>();
         for (Segment segment : pathSegments)
         {
            String template = segment.getTemplate();
            Matcher parameterMatcher = Segment.getTemplateMatcher(template);

            StringBuffer sb = new StringBuffer();
            while (parameterMatcher.find())
            {
               /*
                * We need to escape $ and \ because they have a special meaning when
                * used in Matcher#appendReplacement(). From the docs:
                *
                * Note that backslashes (\) and dollar signs ($) in the replacement string
                * may cause the results to be different than if it were being treated as a
                * literal replacement string. Dollar signs may be treated as references to
                * captured subsequences as described above, and backslashes are used to
                * escape literal characters in the replacement string.
                */
               String replacement = parameters[paramIndex].toString()
                        .replace("$", "\\$")
                        .replace("\\", "\\\\");

               parameterMatcher.appendReplacement(sb, replacement);
               paramIndex++;
            }
            parameterMatcher.appendTail(sb);
            resultSegments.add(sb.toString());
         }
         result = new URL(resultSegments, urlPattern.getMetadata());
      }
      else if (getParameterCount() > 0)
      {
         throw new PrettyException("Invalid number of parameters supplied: " + originalPattern + ", expected <"
                  + getParameterCount() + ">, got <0>");
      }

      return result;
   }
View Full Code Here


            }
            result += strippedUrl;
         }
         catch (Exception e)
         {
            throw new PrettyException("Error occurred during canonicalization of request <[" + url + "]>", e);
         }
      }
      return result;
   }
View Full Code Here

                     log.warn("Ignoring invalid query parameter: " + pair);
                     continue;
                  }
                  catch (UnsupportedEncodingException e)
                  {
                     throw new PrettyException(
                              "UTF-8 encoding not supported. Something is seriously wrong with your environment.");
                  }
               }
               List<String> list = parameters.get(name);
               if (list == null)
View Full Code Here

         return result.toString();
      }
      catch (UnsupportedEncodingException e)
      {
         throw new PrettyException("Error building query string.", e);
      }
   }
View Full Code Here

               log.trace("Redirecting to mappingId [" + mapping.getId() + "], [" + target + "]");
               encodeURL(externalContext, config, target);
            }
            else
            {
               throw new PrettyException("PrettyFaces: Invalid mapping id supplied to navigation handler: " + action);
            }
            return true;
         }
      }
      catch (IOException e)
View Full Code Here

         HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
         response.sendError(HttpServletResponse.SC_NOT_FOUND);
      }
      catch (IOException e)
      {
         throw new PrettyException(e);
      }
   }
View Full Code Here

            }
            result += strippedUrl;
         }
         catch (Exception e)
         {
            throw new PrettyException("Error occurred during canonicalization of request <[" + url + "]>", e);
         }
      }
      return result;
   }
View Full Code Here

         {
            configParser.parse(builder, is);
         }
         catch (Exception e)
         {
            throw new PrettyException("Failed to parse PrettyFaces configuration from " + DEFAULT_PRETTY_FACES_CONFIG, e);
         }
         finally
         {
            try
            {
View Full Code Here

      }
      catch (Exception e)
      {
         PrettyRedirector prettyRedirector = new PrettyRedirector();
         prettyRedirector.send404(facesContext);
         throw new PrettyException("Could not forward to view: " + viewId + "", e);
      }
   }
View Full Code Here

         log.trace("Setting config into ServletContext");
         servletContext.setAttribute(PrettyContext.CONFIG_KEY, config);
      }
      catch (Exception e)
      {
         throw new PrettyException("Failed to load configuration.", e);
      }
   }
View Full Code Here

TOP

Related Classes of com.ocpsoft.pretty.PrettyException

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.