Examples of WGContent


Examples of de.innovationgate.webgate.api.WGContent

            // Exit. This is no hdb model triggered action
            return;
        }
       
        // If the listener is a hdbmodel content we will remove it's relation on the created content
        WGContent listenerContent = event.getListenerContent();
        WGContent movedContent = event.getContent();
        if (listenerContent.getItemValue(HDBModel.ITEM_TYPE).equals(HDBModel.TYPE_CONTENT)) {
            String relationName = "parent-" + listenerContent.getContentClass();
            movedContent.removeRelation(relationName);
            movedContent.save();
        }
       
       
      if (event.isDirectChild()) {
           TMLScriptHDBListener customListener = retrieveCustomListener(event);
View Full Code Here

Examples of de.innovationgate.webgate.api.WGContent

            // Exit. This is no hdb model triggered action
            return;
        }
       
        // If the listener is a hdbmodel content we will create a relation to it on the created content
        WGContent listenerContent = event.getListenerContent();
        WGContent movedContent = event.getContent();
        if (listenerContent.getItemValue(HDBModel.ITEM_TYPE).equals(HDBModel.TYPE_CONTENT)) {
            String relationName = "parent-" + listenerContent.getContentClass();
            movedContent.setRelation(relationName, listenerContent);           
            movedContent.save();
        }
       
      if (event.isDirectChild()) {
           TMLScriptHDBListener customListener = retrieveCustomListener(event);
           if (customListener != null) {
View Full Code Here

Examples of de.innovationgate.webgate.api.WGContent

        }
       
        HDBModelParams params = (HDBModelParams) event.getParameter();
       
        HDBModel model = getModel(event);
        WGContent newContent = event.getContent();
        boolean saveContent = false;
        WGContent listenerContent = event.getListenerContent();
       
        // Operations for the parent of the created content only (should only be executed once)
        WGContent parentContent = event.getParentContent();
        if (parentContent != null && parentContent.equals(event.getListenerContent())) {
           
            newContent.setItemValue(HDBModel.ITEM_TYPE, params.getType());
           
            // Operations for model contents only
            if (params.getType().equals(HDBModel.TYPE_CONTENT)) {
View Full Code Here

Examples of de.innovationgate.webgate.api.WGContent

        // 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) {
               
                if (!ajax) { // On AJAX requests the redirect is performed by Root.tmlEndTag()
                    if (!session.isNew()) { // on new sessions we must not reset the response (#00000147)
                        response.reset();
                    }
                    response.sendRedirect(String.valueOf(request.getAttribute(WGACore.ATTRIB_REDIRECT)));
                }
            }

            // Eventually save profile
            if (tmlUserProfile != null && tmlUserProfile.isSavedOnEnd() && !tmlUserProfile.isSaved()) {

                // To keep profile storage operation from delaying the response
                commitResponse(response);

                if (!tmlUserProfile.getprofile().save()) {
                    getCore().getLog().error("Unable to save profile on request end");
                }

            }
        }
        catch (Exception t) {
            throw t;
        }
        finally {
            // Log
            // WGALoggerWrapper logger = (WGALoggerWrapper)
            // database.getAttribute(WGACore.DBATTRIB_LOGGER);
            // if (logger != null) {
            // logger.logRequest(mimeType, path, request, content,
            // tmlUserProfile, tmlLib);
            // }
            WGARequestInformation info = (WGARequestInformation) request.getAttribute(WGARequestInformation.REQUEST_ATTRIBUTENAME);
            if (info != null) {
                if (content == null || content.isDummy()) {
                    info.setType(WGARequestInformation.TYPE_TML);
                }
                else {
                    info.setType(WGARequestInformation.TYPE_CONTENT);
                }
View Full Code Here

Examples of de.innovationgate.webgate.api.WGContent

    public static WGContent getContentByAnyKey(URLID id, WGDatabase database, WGLanguageChooser languageChooser, boolean isBI) throws WGAPIException {

        WGLanguage langObj;
        // Block with various attempts to search content by this key
        WGContent content = null;

        // Try to retrieve content via content key - Fastest way
        WGContentKey key = id.asContentKey();
        if (key != null) {
            content = database.getContentByKey(key);
View Full Code Here

Examples of de.innovationgate.webgate.api.WGContent

        // Fetch the file container
        WGDocument fileContainer = database.getFileContainer(containerKeyLastElement);
        if (fileContainer == null) {

            // Container addressed by some kind of content key?
            WGContent content = getContentByAnyKey(containerKeyLastElement, database, request);

            // Container addressed by Title path?
            if (content == null) {
                TitlePathManager tpm = (TitlePathManager) database.getAttribute(WGACore.DBATTRIB_TITLEPATHMANAGER);
                if (tpm != null && tpm.isGenerateTitlePathURLs()) {
                    TitlePathManager.TitlePath url = tpm.parseTitlePathURL(containerKeyElems);
                    if (url != null) {
                        path.setTitlePathURL(url);
                        content = path.getContentByTitlePath(request);
                    }
                }
            }

            if (content == null || !content.mayBePublished(isBrowserInterface(request.getSession()) || isAuthoringMode(database.getDbReference(), request.getSession()), WGContent.DISPLAYTYPE_NONE)) {
                sendNoFileContainerNotification(path, request, response, database);
                return;
            }

            fileContainer = content;
View Full Code Here

Examples of de.innovationgate.webgate.api.WGContent

        WGDatabase database = path.getDatabase();
        String contentKey = path.getContentKey();
        String jspName = path.getResourcePath();

        if (database != null) {
            WGContent content = null;
            LanguageBehaviour langBehaviour = LanguageBehaviourTools.retrieve(database);

            // Determine the content for this request
            if (contentKey != null) {
                content = getContentByAnyKey(contentKey, database, request);
                if (content == null) {
                    if (request.getQueryString() != null && request.getQueryString().toLowerCase().indexOf("login") != -1) {
                        sendRedirect(response, getLoginURL(request, database, path.getCompleteURL()));
                    }
                    else {
                        throw new HttpErrorException(404, "No content of name/id " + contentKey, path.getDatabaseKey());
                    }
                    return;
                }
                if (!content.isVisible() && !isBrowserInterface(request.getSession())) {
                    throw new HttpErrorException(404, "No content of name/id " + contentKey, path.getDatabaseKey());
                }
            }
            else {
                WGLanguage lang = langBehaviour.requestSelectDatabaseLanguage(database, request);
                content = database.getDummyContent(lang.getName());
            }

            // 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());
            }

            request.setAttribute(WGACore.ATTRIB_MAINCONTEXT, content);
            request.setAttribute(WGACore.ATTRIB_MEDIAKEY, database.getAttribute(WGACore.DBATTRIB_DEFAULT_MEDIAKEY));
View Full Code Here

Examples of de.innovationgate.webgate.api.WGContent

     * @throws WGAPIException
     */
    static List getFieldValue(WGDocument doc, TMLContext context, FormInfo formInfo, String fieldname, boolean meta, Object defaultvalue, boolean useRelation) throws WGAPIException {
       
      if (useRelation && doc instanceof WGContent) {
        WGContent content = (WGContent)doc;
        List<String> values = new ArrayList<String>();
       
        WGRelationData relationData = content.getRelationData(fieldname);
            if (relationData != null) {
                values.add(relationData.getTargetStructkey().toString());
            }
            else {
                for (WGRelationData relData : content.getRelationsDataOfGroup(fieldname)) {
                    values.add(relData.getTargetStructkey().toString());
                }
        }
       
        return values;
View Full Code Here

Examples of de.innovationgate.webgate.api.WGContent

                    if (entry.isRoot() && entry.getArea().getName().equals(_shortcutArea)) {
                        updateRootNames();
                    }
                }
                else if (event.getEditedDocument() instanceof WGContent) {
                    WGContent content = (WGContent) event.getEditedDocument();
                    WGStructEntry entry = content.getStructEntry();
                    if (entry.isRoot() && entry.getArea().getName().equals(_shortcutArea)) {
                        updateRootNames();
                    }
                }
            }
View Full Code Here

Examples of de.innovationgate.webgate.api.WGContent

        Iterator rootStructs = area.getRootEntries().iterator();
        while (rootStructs.hasNext()) {
            WGStructEntry root = (WGStructEntry) rootStructs.next();
            Iterator contents = root.getContentSet(false).getReleasedContent().values().iterator();
            while (contents.hasNext()) {
                WGContent content = (WGContent) contents.next();
                newNames.put(normalizeURLTitle(content.getTitle()) + "/" + content.getLanguage().getName(), new TitlePathRoot(content.getDocumentKeyObj()));
                newNames.put(normalizeURLTitle(content.getTitle()), new TitlePathRoot(content.getDocumentKeyObj()));
            }
        }
    }
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.