Examples of RedirectException


Examples of org.apache.wiki.api.exceptions.RedirectException

        if( !m_stopAtFirstMatch ) {
            Integer score = ( Integer )context.getVariable( ATTR_SPAMFILTER_SCORE );

            if( score != null && score.intValue() >= m_scoreLimit ) {
                throw new RedirectException( "Herb says you got too many points", getRedirectPage( context ) );
            }
        }

        log( context, ACCEPT, "-", change.toString() );
        return content;
View Full Code Here

Examples of org.apache.wiki.api.exceptions.RedirectException

        return content;
    }

    private void checkStrategy( WikiContext context, String error, String message ) throws RedirectException {
        if( m_stopAtFirstMatch ) {
            throw new RedirectException( message, getRedirectPage( context ) );
        }

        Integer score = ( Integer )context.getVariable( ATTR_SPAMFILTER_SCORE );
        if( score != null ) {
            score = score + 1;
View Full Code Here

Examples of org.apache.wiki.api.exceptions.RedirectException

        {
            Integer score = (Integer)context.getVariable(ATTR_SPAMFILTER_SCORE);

            if( score != null && score.intValue() >= m_scoreLimit )
            {
                throw new RedirectException( "Herb says you got too many points",
                                             getRedirectPage(context) );
            }
        }

        log( context, ACCEPT, "-", change.toString() );
View Full Code Here

Examples of org.apache.wiki.api.exceptions.RedirectException

    private void checkStrategy( WikiContext context, String error, String message )
        throws RedirectException
    {
        if( m_stopAtFirstMatch )
        {
            throw new RedirectException( message, getRedirectPage(context) );
        }

        Integer score = (Integer)context.getVariable( ATTR_SPAMFILTER_SCORE );

        if( score != null )
View Full Code Here

Examples of org.apache.wiki.api.exceptions.RedirectException

        String progressId = req.getParameter( "progressid" );

        // Check that we have a file upload request
        if( !ServletFileUpload.isMultipartContent(req) )
        {
            throw new RedirectException( "Not a file upload", errorPage );
        }
       
        try
        {
            FileItemFactory factory = new DiskFileItemFactory();
           
            // Create the context _before_ Multipart operations, otherwise
            // strict servlet containers may fail when setting encoding.
            WikiContext context = m_engine.createContext( req, WikiContext.ATTACH );

            UploadListener pl = new UploadListener();

            m_engine.getProgressManager().startProgress( pl, progressId );

            ServletFileUpload upload = new ServletFileUpload(factory);
            upload.setHeaderEncoding("UTF-8");
            if( !context.hasAdminPermissions() )
            {
                upload.setFileSizeMax( m_maxSize );
            }
            upload.setProgressListener( pl );
            List<FileItem> items = upload.parseRequest( req );
           
            String   wikipage   = null;
            String   changeNote = null;
            FileItem actualFile = null;
           
            for( FileItem item : items )
            {
                if( item.isFormField() )
                {
                    if( item.getFieldName().equals("page") )
                    {
                        //
                        // FIXME: Kludge alert.  We must end up with the parent page name,
                        //        if this is an upload of a new revision
                        //

                        wikipage = item.getString("UTF-8");
                        int x = wikipage.indexOf("/");

                        if( x != -1 ) wikipage = wikipage.substring(0,x);
                    }
                    else if( item.getFieldName().equals("changenote") )
                    {
                        changeNote = item.getString("UTF-8");
                        if (changeNote != null)
                        {
                            changeNote = TextUtil.replaceEntities(changeNote);
                        }
                    }
                    else if( item.getFieldName().equals( "nextpage" ) )
                    {
                        nextPage = validateNextPage( item.getString("UTF-8"), errorPage );
                    }
                }
                else
                {
                    actualFile = item;
                }
            }

            if( actualFile == null )
                throw new RedirectException( "Broken file upload", errorPage );
           
            //
            // FIXME: Unfortunately, with Apache fileupload we will get the form fields in
            //        order.  This means that we have to gather all the metadata from the
            //        request prior to actually touching the uploaded file itself.  This
View Full Code Here

Examples of org.apache.wiki.api.exceptions.RedirectException

        }
        catch( WikiException e )
        {
            // this is a kludge, the exception that is caught here contains the i18n key
            // here we have the context available, so we can internationalize it properly :
            throw new RedirectException (Preferences.getBundle( context, InternationalizationManager.CORE_BUNDLE )
                                                    .getString( e.getMessage() ), errorPage );
        }
       
        //
        //  FIXME: This has the unfortunate side effect that it will receive the
        //  contents.  But we can't figure out the page to redirect to
        //  before we receive the file, due to the stupid constructor of MultipartRequest.
        //

        if( !context.hasAdminPermissions() )
        {
            if( contentLength > m_maxSize )
            {
                // FIXME: Does not delete the received files.
                throw new RedirectException( "File exceeds maximum size ("+m_maxSize+" bytes)",
                                             errorPage );
            }

            if( !isTypeAllowed(filename) )
            {
                throw new RedirectException( "Files of this type may not be uploaded to this wiki",
                                             errorPage );
            }
        }

        Principal user    = context.getCurrentUser();

        AttachmentManager mgr = m_engine.getAttachmentManager();

        log.debug("file="+filename);

        if( data == null )
        {
            log.error("File could not be opened.");

            throw new RedirectException("File could not be opened.",
                                        errorPage);
        }

        //
        //  Check whether we already have this kind of a page.
        //  If the "page" parameter already defines an attachment
        //  name for an update, then we just use that file.
        //  Otherwise we create a new attachment, and use the
        //  filename given.  Incidentally, this will also mean
        //  that if the user uploads a file with the exact
        //  same name than some other previous attachment,
        //  then that attachment gains a new version.
        //

        Attachment att = mgr.getAttachmentInfo( context.getPage().getName() );

        if( att == null )
        {
            att = new Attachment( m_engine, parentPage, filename );
            created = true;
        }
        att.setSize( contentLength );

        //
        //  Check if we're allowed to do this?
        //

        Permission permission = PermissionFactory.getPagePermission( att, "upload" );
        if( m_engine.getAuthorizationManager().checkPermission( context.getWikiSession(),
                                                                permission ) )
        {
            if( user != null )
            {
                att.setAuthor( user.getName() );
            }

            if( changenote != null && changenote.length() > 0 )
            {
                att.setAttribute( WikiPage.CHANGENOTE, changenote );
            }
           
            try
            {
                m_engine.getAttachmentManager().storeAttachment( att, data );
            }
            catch( ProviderException pe )
            {
                // this is a kludge, the exception that is caught here contains the i18n key
                // here we have the context available, so we can internationalize it properly :
                throw new ProviderException( Preferences.getBundle( context, InternationalizationManager.CORE_BUNDLE )
                                                        .getString( pe.getMessage() ) );
            }

            log.info( "User " + user + " uploaded attachment to " + parentPage +
                      " called "+filename+", size " + att.getSize() );
        }
        else
        {
            throw new RedirectException( "No permission to upload a file", errorPage );
        }

        return created;
    }
View Full Code Here

Examples of org.apache.wiki.filters.RedirectException

        String progressId = req.getParameter( "progressid" );

        // Check that we have a file upload request
        if( !ServletFileUpload.isMultipartContent(req) )
        {
            throw new RedirectException( "Not a file upload", errorPage );
        }
       
        try
        {
            FileItemFactory factory = new DiskFileItemFactory();
           
            // Create the context _before_ Multipart operations, otherwise
            // strict servlet containers may fail when setting encoding.
            WikiContext context = m_engine.createContext( req, WikiContext.ATTACH );

            UploadListener pl = new UploadListener();

            m_engine.getProgressManager().startProgress( pl, progressId );

            ServletFileUpload upload = new ServletFileUpload(factory);
            upload.setHeaderEncoding("UTF-8");
            if( !context.hasAdminPermissions() )
            {
                upload.setFileSizeMax( m_maxSize );
            }
            upload.setProgressListener( pl );
            List<FileItem> items = upload.parseRequest( req );
           
            String   wikipage   = null;
            String   changeNote = null;
            FileItem actualFile = null;
           
            for( FileItem item : items )
            {
                if( item.isFormField() )
                {
                    if( item.getFieldName().equals("page") )
                    {
                        //
                        // FIXME: Kludge alert.  We must end up with the parent page name,
                        //        if this is an upload of a new revision
                        //

                        wikipage = item.getString("UTF-8");
                        int x = wikipage.indexOf("/");

                        if( x != -1 ) wikipage = wikipage.substring(0,x);
                    }
                    else if( item.getFieldName().equals("changenote") )
                    {
                        changeNote = item.getString("UTF-8");
                        if (changeNote != null)
                        {
                            changeNote = TextUtil.replaceEntities(changeNote);
                        }
                    }
                    else if( item.getFieldName().equals( "nextpage" ) )
                    {
                        nextPage = validateNextPage( item.getString("UTF-8"), errorPage );
                    }
                }
                else
                {
                    actualFile = item;
                }
            }

            if( actualFile == null )
                throw new RedirectException( "Broken file upload", errorPage );
           
            //
            // FIXME: Unfortunately, with Apache fileupload we will get the form fields in
            //        order.  This means that we have to gather all the metadata from the
            //        request prior to actually touching the uploaded file itself.  This
View Full Code Here

Examples of org.exoplatform.social.client.api.auth.RedirectException

      } else if (statusCode == 301) {
        /** handle redirect */
        Header[] headers = response.getHeaders("Location");
        if (headers != null && headers.length != 0) {
          String newUrl = headers[headers.length - 1].getValue();
          throw new RedirectException(newUrl);
        }
        throw new ServiceException(response.getStatusLine().toString());
      } else {
        throw new ServiceException(response.getStatusLine().toString());
      }
View Full Code Here

Examples of org.jboss.seam.faces.RedirectException

        ExternalContext ctx = FacesContext.getCurrentInstance().getExternalContext();
        try {
            log.debug("redirecting to URL: " + url);
            ctx.redirect(ctx.encodeResourceURL(url));
        } catch (IOException ioe) {
            throw new RedirectException(ioe);
        }
        FacesContext.getCurrentInstance().responseComplete();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.