Examples of HttpErrorException


Examples of com.ripariandata.timberwolf.mail.exchange.HttpErrorException

        catch (ExchangeRuntimeException e)
        {
            Throwable inner = e.getCause();
            if (inner instanceof HttpErrorException)
            {
                HttpErrorException httpError = (HttpErrorException) inner;
                if (httpError.getErrorCode() == HttpURLConnection.HTTP_UNAUTHORIZED)
                {
                    System.out.println("There was an authentication error connecting to Exchange or HBase.  "
                                       + "See the log for more details.");
                }
                else
                {
                    System.out.println("There was an HTTP " + httpError.getErrorCode()
                                       + " error connection to either Exchange or HBase.  "
                                       + "See the log for more details.");
                }
            }
            else if (inner instanceof ServiceCallException)
View Full Code Here

Examples of de.innovationgate.wgpublisher.webtml.utils.HttpErrorException

            }
           
            this.database = core.openContentDB(database, request, this.masterLogin);
        }
        catch (WGUnavailableException e) {
            throw new HttpErrorException(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "The website is currently unavailable", getDatabaseKey());
        }
        catch (de.innovationgate.wgpublisher.AuthenticationException e) {
            throw new HttpErrorException(HttpServletResponse.SC_UNAUTHORIZED, e.getMessage(), null);
        }
        catch (AccessException e) {
            throw new HttpErrorException(HttpServletResponse.SC_FORBIDDEN, e.getMessage(), null);
        }
       
       
        if (!database.isSessionOpen()) {
            handleLoginFailure(request, response, dispatcher, core);
View Full Code Here

Examples of de.innovationgate.wgpublisher.webtml.utils.HttpErrorException

            UnsupportedEncodingException {

        // Look if there is a login for that domain. If so, user has no
        // access to this db
        if (!core.allowLoginRetry(database, request.getSession())) {
            throw new HttpErrorException(HttpServletResponse.SC_FORBIDDEN, "You have no access to database " + getDatabaseKey(), null);
        }

        // Try to login, if no login for this domain
        String dbAttribHttpLogin = (String) database.getAttribute(WGACore.DBATTRIB_HTTPLOGIN);
        if (dbAttribHttpLogin == null) {
View Full Code Here

Examples of de.innovationgate.wgpublisher.webtml.utils.HttpErrorException

    private void testGeneralAccess(WGDatabase database, javax.servlet.http.HttpServletRequest request) throws HttpErrorException, AdminLoginNeededException {
   
        Boolean updated = (Boolean) database.getAttribute(WGDatabase.ATTRIB_UPDATED);
        if (updated != null) {
            if (updated.booleanValue() == true) {
                throw new HttpErrorException(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "This website is currently being updated. Please try again later.", getDatabaseKey());
            }
        }
       
        boolean allowPublishing = database.getBooleanAttribute(WGACore.DBATTRIB_ALLOW_PUBLISHING, true);
        if (!allowPublishing) {
            throw new HttpErrorException(HttpServletResponse.SC_FORBIDDEN, "The database '" + database.getDbReference() + "' is not published", null);
        }
   
        boolean authoringApp = database.getBooleanAttribute(WGACore.DBATTRIB_AUTHORING_APP, false);
        if (authoringApp && !core.isAuthoringPort(request.getLocalPort())) {
            throw new HttpErrorException(HttpServletResponse.SC_FORBIDDEN, "Access to authoring applications is disabled", null);
        }
       
        boolean adminApp = database.getBooleanAttribute(WGACore.DBATTRIB_ADMIN_APP, false);
        if (adminApp) {
            if (!core.isAdministrativePort(request.getLocalPort())) {
                throw new HttpErrorException(HttpServletResponse.SC_FORBIDDEN, "Access to administrative applications is disabled", null);
            }
           
            if (!core.isAdminLoggedIn(request)) {
                throw new AdminLoginNeededException();
            }
View Full Code Here

Examples of de.innovationgate.wgpublisher.webtml.utils.HttpErrorException

        String redirect = request.getParameter("redirect");
        String referer = request.getHeader("Referer");

        // Some basic validating
        if (domain == null) {
            throw new HttpErrorException(500, "Missing parameter \"domain\". (Hint: Field name must be lower case)", null);
        }
        if (username == null) {
            throw new HttpErrorException(500, "Missing parameter \"username\". (Hint: Field name must be lower case)", null);
        }
        if (password == null) {
            throw new HttpErrorException(500, "Missing parameter \"password\". (Hint: Field name must be lower case)", null);
        }
        if (username == null || password == null) {
            request.setAttribute(WGACore.ATTRIB_LOGINERROR, "Invalid login for domain " + domain + ". Username or password is null.");
            username = "Anonymous";
            password = "";
        }

        boolean isLoginSuccessful = false;
        try {
            if (WGACore.DOMAIN_ADMINLOGINS.equals(domain)) {
                if (!_core.isAdministrativePort(request.getLocalPort())) {
                    throw new HttpErrorException(HttpServletResponse.SC_FORBIDDEN, "Access to administrative applications is disabled", null);
                }

                isLoginSuccessful = _core.doAdminLogin(username, password, request);
            }
            else {
View Full Code Here

Examples of de.innovationgate.wgpublisher.webtml.utils.HttpErrorException

            int iPathType = path.getPathType();

            // Treatment of special URL types
            String dbKey = path.getDatabaseKey();
            if (iPathType == WGPRequestPath.TYPE_INVALID) {
                throw new HttpErrorException(404, "Invalid path: " + path.getBasePath(), dbKey);
            }
            if (iPathType == WGPRequestPath.TYPE_INVALID_DB) {
                throw new HttpErrorException(404, "Specified database '" + dbKey + "' is unknown", null);
            }

            if (iPathType == WGPRequestPath.TYPE_UNKNOWN_CONTENT) {
                sendNoContentNotification(path, request, response, path.getDatabase());
                return;
            }

            if (iPathType == WGPRequestPath.TYPE_GOTO_HOMEPAGE) {
                iPathType = determineHomepage(request, path, iPathType);
            }

            if (iPathType == WGPRequestPath.TYPE_UNAVAILABLE_DB) {
                throw new HttpErrorException(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "The website is currently unavailable", path.getDatabaseKey());
            }

            if (iPathType == WGPRequestPath.TYPE_UNDEFINED_HOMEPAGE) {
                throw new HttpErrorException(HttpServletResponse.SC_NOT_FOUND, "No home page was defined for database '" + path.getDatabaseKey() + "'. Please specify an explicit content path.", path
                        .getDatabaseKey());
            }

            if (iPathType == WGPRequestPath.TYPE_TMLDEBUG) {
                _tmlDebugger.performDebugMode(request, response, session);
                return;
            }

            if (iPathType == WGPRequestPath.TYPE_JOBLOG) {
                sendJobLog(request, response, session);
                return;
            }

            if (iPathType == WGPRequestPath.TYPE_LOGOUT) {
                WGDatabase db = (WGDatabase) _core.getContentdbs().get(dbKey);
                String domain = (String) db.getAttribute(WGACore.DBATTRIB_DOMAIN);
                _core.logout(domain, session);
                removeSessionCookie(response, request.getSession(), db);

                iPathType = WGPRequestPath.TYPE_REDIRECT;
            }

            if (iPathType == WGPRequestPath.TYPE_FAVICON) {
                String faviconPath = determineFavicon(request);
                if (faviconPath != null) {
                    iPathType = WGPRequestPath.TYPE_REDIRECT;
                    path.setResourcePath(faviconPath);
                }
                else {
                    response.sendError(HttpServletResponse.SC_NOT_FOUND, "Favicon not defined");
                    return;
                }
            }

            // Treatment of base URL Types
            if (iPathType == WGPRequestPath.TYPE_REDIRECT) {
                String url = path.getResourcePath();
                if (path.appendQueryString() == true && request.getQueryString() != null && !request.getQueryString().equals("")) {
                    if (url.indexOf("?") != -1) {
                        url += "&" + request.getQueryString();
                    }
                    else {
                        url += "?" + request.getQueryString();
                    }
                }

                if (path.isPermanentRedirect()) {
                    sendPermanentRedirect(response, url);
                }
                else {
                    sendRedirect(response, url);
                }
            }
            else if (iPathType != WGPRequestPath.TYPE_RESOURCE && iPathType != WGPRequestPath.TYPE_STATICTML && !_core.getContentdbs().containsKey(path.getDatabaseKey())) {
                throw new HttpErrorException(404, "Database '" + dbKey + "' is unknown", null);
            }
            else {

                String requestMethod = request.getMethod().toLowerCase();
                switch (iPathType) {
                    case (WGPRequestPath.TYPE_TML):
                    case (WGPRequestPath.TYPE_TITLE_PATH):
                        if (path.isCompletePath() || !(requestMethod.equals("get") || requestMethod.equals("head"))) {

                            if (!path.isCompletePath()) {
                                _log.warn("Received " + request.getMethod() + " request to incomplete URL '" + path.getCompleteURL()
                                        + "' which cannot be redirected. Please use complete URLs on this HTTP method for consistent behaviour.");
                            }

                            dispatchTmlRequest(path, request, response, startDate);
                        }
                        else {
                            sendRedirect(response, path.expandToCompletePath(request));
                        }
                        break;

                    case (WGPRequestPath.TYPE_FILE):
                        dispatchFileRequest(path, request, response);
                        break;

                    case (WGPRequestPath.TYPE_CSS):
                    case (WGPRequestPath.TYPE_JS):
                        dispatchCssjsRequest(path, request, response);
                        break;

                    case (WGPRequestPath.TYPE_RESOURCE):
                        dispatchResourceRequest(path, request, response);
                        break;

                    case (WGPRequestPath.TYPE_STATICTML):
                        dispatchStaticTmlRequest(path, request, response);
                        break;

                    default:
                        throw new HttpErrorException(500, "Invalid url format", dbKey);
                }
            }

            // moved from finally block to ensure errorpage can be displayed
            commitResponse(response);
View Full Code Here

Examples of de.innovationgate.wgpublisher.webtml.utils.HttpErrorException

                return WGPRequestPath.TYPE_REDIRECT;
            }
        }
        catch (WGException e) {
            getCore().getLog().error("Error determining homepage", e);
            throw new HttpErrorException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage(), path.getDatabaseKey());
        }

        return WGPRequestPath.TYPE_UNDEFINED_HOMEPAGE;
    }
View Full Code Here

Examples of de.innovationgate.wgpublisher.webtml.utils.HttpErrorException

        HttpSession session = request.getSession();

        // Fetch the database
        WGDatabase database = path.getDatabase();
        if (database == null) {
            throw new HttpErrorException(404, "No database of key " + path.getDatabaseKey(), null);
        }

        // Determine requested mime type and type key
        String mediaKey = path.getMediaKey();
        if (mediaKey == null) {
            mediaKey = database.getAttribute(WGACore.DBATTRIB_DEFAULT_MEDIAKEY).toString();
        }
        MediaKey mediaKeyObj = _core.getMediaKey(mediaKey);
        String mimeType = mediaKeyObj.getMimeType();
        response.setContentType(mimeType);

        // Look if a session cookie has to be set
        _core.setSessionCookie(request, response, database);

        // Determine the content for this request
        WGContent content = path.getContent();

        // Context request, if content key filled or we have a title path
        if (content != null) {

            if (!content.mayBePublished(isBrowserInterface(session) || isAuthoringMode(database.getDbReference(), session), WGContent.DISPLAYTYPE_NONE)) {
                sendNoContentNotification(path, request, response, database);
                return;
            }

            if (content.isVirtual()) {
                if (isBrowserInterface(session)) {
                    if (!content.getStatus().equals(WGContent.STATUS_DRAFT) && request.getParameter("forceVLink") == null) {

                        String url = getVirtualContentURL(request, database, path, content);
                        sendRedirect(response, url);
                        return;
                    }
                }
                else {
                    sendRedirect(response, buildVirtualLink(content, request, path.getMediaKey(), path.getLayoutKey()));
                    return;
                }
            }

        }

        // Contextless request. We use a dummy content
        else {
            content = database.getDummyContent(path.getRequestLanguage());
        }

        // Test browsability of content
        if (!content.isDummy() && getBrowsingSecurity(database) <= BrowsingSecurity.NO_BROWSING) {
            throw new HttpErrorException(java.net.HttpURLConnection.HTTP_FORBIDDEN, "Browsing not allowed in database '" + path.getDatabaseKey() + "'", path.getDatabaseKey());
        }

        // Drop cache if requested by url param
        if (request.getQueryString() != null && request.getQueryString().toLowerCase().indexOf("dropcache") != -1 && isAdminLoggedIn(request)) {
            content.dropCache();
        }

        // Personalize
        TMLUserProfile tmlUserProfile = null;
        try {
            if (_core.isPersonalisationEnabled()) {
                tmlUserProfile = this.fetchUserProfile(request, response, database, session);
                if (tmlUserProfile != null && !tmlUserProfile.getprofile().isDeleted()) {
                    if (!isBrowserInterface(session)) {
                        this.registerHit(tmlUserProfile.getprofile(), database, content);
                    }
                }
            }
        }
        catch (WGAPIException e) {
            _log.error("Unable to personalize tmlrequest.", e);
        }

        // Set context attributes for tml
        request.setAttribute(WGACore.ATTRIB_MAINCONTEXT, content);
        request.setAttribute(WGACore.ATTRIB_WGPPATH, path.getPublisherURL());
        request.setAttribute(WGACore.ATTRIB_TAGIDS, WGUtils.createSynchronizedMap());
        request.setAttribute(WGACore.ATTRIB_TMLCONTEXTS, WGUtils.createSynchronizedMap());
        request.setAttribute(WGACore.ATTRIB_REQUESTURL, completeUrl);
        request.setAttribute(WGACore.ATTRIB_MIMETYPE, mimeType);
        request.setAttribute(WGACore.ATTRIB_MEDIAKEY, mediaKey);
        request.setAttribute(WGACore.ATTRIB_REQUESTTYPE, REQUESTTYPE_TML);

        if (mediaKeyObj.isBinary()) {
            request.setAttribute(WGACore.ATTRIB_SERVLETRESPONSE, response);
        }

        // Determine tml design for this request
        WGTMLModule tmlLib = null;
        if (path.getLayoutKey() != null) {
            tmlLib = (WGTMLModule) database.getDesignObject(WGDocument.TYPE_TML, path.getLayoutKey(), mediaKey);
            if (tmlLib != null && tmlLib.isDirectAccessAllowed() == false) {
                throw new HttpErrorException(java.net.HttpURLConnection.HTTP_FORBIDDEN, "This design is not allowed for direct access: " + tmlLib.getName() + " (" + tmlLib.getMediaKey() + ")", path
                        .getDatabaseKey());
            }
        }
        else {
            WGStructEntry entry = content.getStructEntry();
            if (entry == null) {
                throw new HttpErrorException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Content " + content.getContentKey().toString() + " has no struct entry", path.getDatabaseKey());
            }
            tmlLib = entry.getOuterLayout(mediaKey);
        }

        if (tmlLib == null || tmlLib.isDummy()) {
            if (path.getLayoutKey() != null) {
                throw new HttpErrorException(404, "No WebTML layout '" + path.getLayoutKey() + "' for media key '" + mediaKey + "' available in app '" + database.getDbReference() + "'", path.getDatabaseKey());
            }
            else {
                throw new HttpErrorException(500, "Outer layout of struct entry '" + content.getStructEntry().getTitle() + "(" + content.getStructEntry().getStructKey() + ")"
                        + "' not available for media key '" + mediaKey + "'", path.getDatabaseKey());
            }
        }

        request.setAttribute(WGACore.ATTRIB_OUTER_DESIGN, tmlLib.getName());


        // TML Cache control
        if (tmlLib.isCacheable()) {
            response.setHeader("Cache-Control", "must-revalidate");

            long lastModified;
            // determine lastModified
            // - last modified of binary response depends only on resource
            // change date
            // - last change date of textual response additionally depends on
            // character encoding change date
            if (isBinary(response)) {
                lastModified = getCore().getDeployer().getLastChangedOrDeployed(database).getTime();
            }
            else {
                lastModified = Math.max(getCore().getDeployer().getLastChangedOrDeployed(database).getTime(), _core.getCharacterEncodingLastModified());
                lastModified = Math.max(lastModified, _core.getDesignEncodingLastModified(database.getDbReference()));
            }

            // Test modified since
            if (browserCacheIsValid(request, lastModified)) {
                response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                return;
            }
            else {
                response.setDateHeader("Last-Modified", lastModified);
                response.setHeader("ETag", '"' + String.valueOf(lastModified) + '"');
            }
        }
        else {
            response.setHeader("Pragma", "No-Cache");
            if (mediaKeyObj.isBinary()) {
                response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
            }
            else {
                response.setHeader("Cache-Control", "No-Cache");
            }
        }

        // check if we have an ajaxcall
        String encAjaxInfo = request.getParameter("$ajaxInfo");
        if (encAjaxInfo != null) {
            tmlLib = processAjaxCall(request, database, encAjaxInfo);
            ajax = true;
        }

        // Update usage statistics
        getCore().getUsageStatistics().addRequestStatistic(request, session, database, tmlUserProfile);

        // Dispatch to jsp
        String targetJSP = _core.getDeployer().locateTmlResource(tmlLib);

        try {
            if (targetJSP != null) {
                if (!"HEAD".equalsIgnoreCase(request.getMethod())) {
                    if (mediaKeyObj.isBinary()) {
                        if (request instanceof RenderServletRequestWrapper) {
                            HttpServletRequestWrapper wrapper = (HttpServletRequestWrapper) request;
                            wrapper.getRequest().getRequestDispatcher(targetJSP).include(wrapper.getRequest(), new DummyServletResponse(response));
                        }
                        else {
                            this.getServletContext().getRequestDispatcher(targetJSP).include(request, new DummyServletResponse(response));
                        }
                    }
                    else {
                        if (request instanceof RenderServletRequestWrapper) {
                            HttpServletRequestWrapper wrapper = (HttpServletRequestWrapper) request;
                            wrapper.getRequest().getRequestDispatcher(targetJSP).include(wrapper.getRequest(), response);
                        }
                        else {
                            this.getServletContext().getRequestDispatcher(targetJSP).include(request, response);
                        }
                    }
                }
            }
            else {
                throw new HttpErrorException(500, "tml design not active: " + tmlLib.getName(), path.getDatabaseKey());
            }

            // Eventually do redirect
            if (request.getAttribute(WGACore.ATTRIB_REDIRECT) != null) {
               
View Full Code Here

Examples of de.innovationgate.wgpublisher.webtml.utils.HttpErrorException

        try {
            // decrypt
            byte[] zipped = this.getCore().getDesEncrypter().decrypt(encAjaxInfo);
            if (zipped == null) {
                this.getCore().getLog().error("Retrieved AjaxInfo could not be decrypted. Maybe the ajax call was defined for another WGA instance.");
                throw new HttpErrorException(HttpURLConnection.HTTP_INTERNAL_ERROR, "Retrieved AjaxInfo could not be decrypted. Maybe the ajax call was defined for another WGA instance.", null);
            }
            // unzip
            String unzipped = Zipper.unzip(zipped);
            // deserialize
            ajaxInfo = (AjaxInfo) new XStream(new Dom4JDriver()).fromXML(unzipped);
            // put ajaxInfo on request so root tag can retrieve it
            request.setAttribute(WGACore.ATTRIB_AJAXINFO, ajaxInfo);
        }
        catch (HttpErrorException e) {
            throw e;
        }
        catch (Exception e) {
            this.getCore().getLog().error("Retrieved AjaxInfo could not be restored.", e);
            throw new HttpErrorException(HttpURLConnection.HTTP_INTERNAL_ERROR, "Retrieved AjaxInfo could not be restored. Check log for details.", null);
        }

        // fetch correct db for ajax (if designdb on include tag is present use
        // design db, if not use current db)
        WGDatabase ajaxDB = null;
        String ajaxDesignDBKey = ajaxInfo.getDesignDB();
        if (ajaxDesignDBKey != null) {
            // fetch design db
            try {
                ajaxDB = _core.openContentDB(ajaxDesignDBKey, request);
            }
            catch (WGUnavailableException e) {
                throw new HttpErrorException(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "The website is currently unavailable", ajaxDesignDBKey);
            }
            catch (de.innovationgate.wgpublisher.AuthenticationException e) {
                throw new HttpErrorException(HttpServletResponse.SC_UNAUTHORIZED, e.getMessage(), null);
            }
            catch (AccessException e) {
                throw new HttpErrorException(HttpServletResponse.SC_FORBIDDEN, e.getMessage(), null);
            }

            if (ajaxDB == null) {
                throw new HttpErrorException(HttpServletResponse.SC_NOT_FOUND, "No database of key " + ajaxDesignDBKey, null);
            }
            else if (ajaxDB.isSessionOpen() == false) {
                throw new HttpErrorException(HttpServletResponse.SC_FORBIDDEN, "Database '" + ajaxDesignDBKey + "' could not be opened by ajaxCall.", null);
            }
        }
        else {
            ajaxDB = database;
        }

        // search for tml module
        tmlLib = (WGTMLModule) ajaxDB.getDesignObject(WGDocument.TYPE_TML, ajaxInfo.getTmlmodule(), ajaxInfo.getMediaKey());

        if (tmlLib == null) {
            throw new HttpErrorException(HttpServletResponse.SC_NOT_FOUND, "No WebTML layout '" + ajaxInfo.getTmlmodule() + "' for media key '" + ajaxInfo.getMediaKey() + "' available in app '" + ajaxDB.getDbReference() + "'", ajaxDB
                    .getDbReference());
        }

        return tmlLib;
    }
View Full Code Here

Examples of de.innovationgate.wgpublisher.webtml.utils.HttpErrorException

                String url = getNoContentNotificationURL(request, database, path);
                sendRedirect(response, url);
            }
            else {
                if (path.getTitlePathURL() != null) {
                    throw new HttpErrorException(404, "Content on path '" + path.getTitlePathURL().getPath() + "' does not exist or is not visible for user '"
                            + database.getSessionContext().getUser() + "'", path.getDatabaseKey());
                }
                else {
                    throw new HttpErrorException(404, "Content of name/id '" + path.getContentKey() + "' does not exist or is not visible for user '" + database.getSessionContext().getUser() + "'",
                            path.getDatabaseKey());
                }
            }

        }
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.