Package de.innovationgate.webgate.api

Examples of de.innovationgate.webgate.api.WGDatabase$FreeContentVersionFinder


            throw new TMLException("Cannot find inner layout for doctype " + this.getTMLContext().content().getStructEntry().getContentType().getName());
          }
        }
       
        else {
          WGDatabase designdb = database;
          if (designDBKey != null) {
            try {
              designdb = this.openContentDB(designDBKey);
            }
            catch (WGUnavailableException e1) {
            }
                catch (WGException e) {
                    throw new TMLException(e.getMessage(), true);
                }
            if (designdb == null || !designdb.isSessionOpen()) {
              throw new TMLException("Cannot open design db: " + designDBKey, true);
            }
          }
         
            tmllib = (WGTMLModule) designdb.getDesignObject(WGDocument.TYPE_TML, status.ref, mediaKey);
          if (tmllib == null) {
            throw new TMLException("Cannot find requested tml module: " + status.ref + " (" + mediaKey + ")");
          }
        }
View Full Code Here


      return false;
    }
   
        WGContent content = (WGContent) _pageContext.getRequest().getAttribute(WGACore.ATTRIB_MAINCONTEXT);
        if (content != null) {
            WGDatabase db = content.getDatabase();
            String startPageEnabled = (String) db.getAttribute(WGACore.DBATTRIB_STARTPAGE);
            if (startPageEnabled != null && startPageEnabled.equals("false")) {
                return false;
            }
        }
       
View Full Code Here

        if (dbKey == null) {
            dbKey = context.db().getDbReference();
        }
       
        String defaultMediaKey = "html";
        WGDatabase db = (WGDatabase) context.getwgacore().getContentdbs().get(dbKey);
        if (db != null) {
            defaultMediaKey = (String) db.getAttribute(WGACore.DBATTRIB_DEFAULT_MEDIAKEY);
        }
       
        return context.meta("request", "wgaurl") + "/" + dbKey + "/" + defaultMediaKey + "/default/" + anyURLContentKey;
  }
View Full Code Here

    private TMLContext traceRemoteDocument(TMLContext context, String linkTargetContentKey) throws WGAPIException {

        try {
            String remoteInfo = context.content().getItemText("remote_info");
            RemoteDocReference ref = new RemoteDocReference(remoteInfo);
            WGDatabase targetDB = context.content().getDatabase();
            WGDatabase sourceDB = (WGDatabase) context.getwgacore().getContentdbs().get(ref.getDbKey());
           
            // Determine the language behaviour to use while resolving the link in source DB. If both dbs are multi-language we can
            // use the target language behaviour to allow behaviour integrity. Otherwise we must choose source behaviour.
            WGDatabase langBehaviourDB;
            if (LanguageBehaviourTools.isMultiLanguageDB(sourceDB) && LanguageBehaviourTools.isMultiLanguageDB(targetDB)) {
                langBehaviourDB = targetDB;
            }
            else {
                langBehaviourDB = sourceDB;
View Full Code Here

            TMLContext con = fetchInitialContext(Context.getCurrentContext());
            WGAPlugin plugin = con.getwgacore().getPluginSet().getPluginByUniqueName((String) arg1);
            if (plugin == null || !plugin.isActive() || !plugin.isValid()) {
                return null;
            }
            WGDatabase db = con.db(plugin.buildDatabaseKey());
            if (db != null) {
                return new Plugin(db);
            }
            else {
                return null;
View Full Code Here

        }
        else if (ref instanceof WGDatabase) {
            _designContext = tmlContext.getDesignContext().createContextDelegate((WGDatabase) ref, null);
        }
        else if (ref instanceof String) {
            WGDatabase designDB = tmlContext.db((String) ref);
            if (designDB != null && designDB.isSessionOpen()) {
                _designContext = tmlContext.getDesignContext().createContextDelegate((WGDatabase) designDB, null);
            }
        }
        else if (ref instanceof NativeObject) {
            _currentObject  = (NativeObject) ref;
            _currentAction = WGAGlobal.currentAction(Context.getCurrentContext(), _currentObject);
            if (_currentAction == null) {
                throw new IllegalArgumentException("Cannot determine design of parameter object");
            }

            String dbKey = _currentAction.getModuleDatabase();
            WGDatabase designDB = tmlContext.db(dbKey);       
            if (designDB != null && designDB.isSessionOpen()) {
                _designContext = tmlContext.getDesignContext().createContextDelegate((WGDatabase) designDB, null);
            }
        }
        else {
            throw new IllegalArgumentException("Invalid parameter object type " + ref.getClass().getName());           
View Full Code Here

   
    public static Plugin plugin(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj) throws JavaScriptException, WGException {
       
        TMLContext context = WGAGlobal.fetchInitialContext(cx);
        Design design = unwrapThisObj(thisObj);
        WGDatabase designDb = design._designContext.getDesignDB();
       
        // Look if the design db is a plugin itself
        if (designDb.getDbReference().startsWith(PluginConfig.PLUGIN_DBKEY_PREFIX)) {
            return new Plugin(designDb);
        }
       
        // Follow to the design provider
        WGDesignProvider provider = designDb.getDesignProvider();
        if (!(provider instanceof PluginDesignProvider)) {
            return null;
        }
       
        PluginDesignProvider pluginProvider = (PluginDesignProvider) provider;
        String dbKey = pluginProvider.getDesignDBKey();
       
       
        WGDatabase db = context.db(dbKey);
        if (db == null) {
            return null;
        }
       
        return new Plugin(db);
View Full Code Here

                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;
            }
View Full Code Here

    private WGPRequestPath parseRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws HttpErrorException, WGException, IOException {
        return new WGPRequestPath(request, response, this, _core);
    }

    private int determineHomepage(javax.servlet.http.HttpServletRequest request, WGPRequestPath path, int iPathType) throws UnsupportedEncodingException, HttpErrorException {
        WGDatabase db = (WGDatabase) _core.getContentdbs().get(path.getDatabaseKey());

        WGAURLBuilder urlBuilder = _core.retrieveURLBuilder(request, db);

        String homepage;
        try {
View Full Code Here

        String completeUrl = path.getCompleteURL();

        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);
View Full Code Here

TOP

Related Classes of de.innovationgate.webgate.api.WGDatabase$FreeContentVersionFinder

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.