Examples of WGDatabase


Examples of de.innovationgate.webgate.api.WGDatabase

            _log.error("Cannot process move event for content '" + contentEvent.getDocumentKey() + "' (DB " + contentEvent.getDatabase().getDbReference() + ").", e);
            return;
        }
       
       
        WGDatabase db = contentEvent.getDatabase();
        if (!db.getSessionContext().isContentTypeEventsEnabled()) {
            return;
        }
       
        String dbKey = (String) db.getAttribute(WGACore.DBATTRIB_DBKEY);
       
        HttpServletRequest request = (HttpServletRequest) db.getSessionContext().getAttribute(WGACore.DBSESSIONCONTEXT_REQUEST);
        TMLUserProfile userProfile = null;
        if (request != null) {
            userProfile = (TMLUserProfile) request.getAttribute(WGACore.ATTRIB_PROFILE + db.getDbReference());
        }
       
        String contentType = "*";
        try {
            if (newContent != null && newContent.hasCompleteRelationships()) {
View Full Code Here

Examples of de.innovationgate.webgate.api.WGDatabase

        }
        catch (WGAPIException e) {
            _log.error("Cannot process status change event for content '" + contentEvent.getDocumentKey() + "' (DB " + contentEvent.getDatabase().getDbReference() + ").", e);
            return;
        }
        WGDatabase db = contentEvent.getDatabase();
        if (!db.getSessionContext().isContentTypeEventsEnabled()) {
            return;
        }
       
        String dbKey = (String) db.getDbReference();
       
        HttpServletRequest request = (HttpServletRequest) db.getSessionContext().getAttribute(WGACore.DBSESSIONCONTEXT_REQUEST);
        TMLUserProfile userProfile = null;
        if (request != null) {
            userProfile = (TMLUserProfile) request.getAttribute(WGACore.ATTRIB_PROFILE + db.getDbReference());
        }
       
        String contentType = contentEvent.getContentType();
        WGDocumentKey docKey = new WGDocumentKey(contentEvent.getDocumentKey());
        EventPath eventPath = createContentEventPath(EVENTNAME_STATUSCHANGE, dbKey, contentType, docKey.getName());
View Full Code Here

Examples of de.innovationgate.webgate.api.WGDatabase

                    "Cannot process expression '" + getExpression() + "' on a non-content context: " + context.getdocument().getDocumentKey());
            return errorReturnContext;
        }
       
        WGStructEntry struct = content.getStructEntry();
        WGDatabase db = context.getdocument().getDatabase();
   
        if (contextExpression.equals("parent")) {
   
            if (content.isDummy()) {
                context.setLastError("Cannot retrieve parent of dummy content");
                return errorReturnContext;
            }
   
            if (struct.isRoot()) {
                context.setLastError("Cannot get parent of root document");
                return errorReturnContext;
            }
            else {
                WGContent parentContent = navigator.getParentContent(content);
                if (parentContent != null) {
                    return context.getTMLContextForDocument(parentContent);
                }
                else {
                    context.setLastError(
                        "Could not retrieve parent content: "
                            + content.getTitle()
                            + " ("
                            + content.getContentKey().toString()
                            + ")");
                    return errorReturnContext;
                }
            }
        }
   
        else if (contextExpression.equals("root")) {
            WGContent rootContent = null;
            if (!content.isDummy()) {
                rootContent = navigator.getRootContent(content);
            }
            else {
                rootContent = content.getDatabase().getFirstReleasedContent(_languageChooser, true);
            }
   
            if (rootContent != null) {
                return context.getTMLContextForDocument(rootContent);
            }
            else {
                context.setLastError("Could not retrieve root content");
                return errorReturnContext;
            }
        }
   
        else if (contextExpression.equals("main") || contextExpression.equals("currentdocument")) {
            TMLContext mainContext = context.getmaincontext();
            return new TMLContext(mainContext.getdocument(), context);
        }
   
        else if (contextExpression.startsWith("children")) {
   
            if (content.isDummy()) {
                context.setLastError("Cannot retrieve children of dummy content");
                return errorReturnContext;
            }
   
            String idxString = contextExpression.substring(contextExpression.indexOf("[") + 1, contextExpression.indexOf("]"));
            int idx;
            try {
                idx = Integer.parseInt(idxString);
            }
            catch (NumberFormatException exc) {
                context.setLastError("Can't parse children index: " + contextExpression);
                return errorReturnContext;
            }
            WGContent childContent = navigator.getChildContent(content, idx, WGContent.SEARCHORDER_ASCENDING);
            if (childContent != null) {
                return context.getTMLContextForDocument(childContent);
            }
            else {
                context.setLastError("Cant retrieve child content idx " + idx);
                return errorReturnContext;
            }
        }
   
        else if (contextExpression.equals("selectedchild")) {
   
            if (content.isDummy()) {
                context.setLastError("Cannot retrieve children of dummy content");
                return errorReturnContext;
            }
   
            WGContent mainContentParent = context.getmaincontext().content();
            while (mainContentParent != null && !mainContentParent.isDummy() && !mainContentParent.getStructEntry().isRoot()) {
                if (mainContentParent.getStructEntry().getParentEntry().equals(struct)) {
                    return context.getTMLContextForDocument(mainContentParent);
                }
                else {
                    mainContentParent = navigator.getParentContent(mainContentParent);
                }
            }
            context.setLastError("Could not retrieve selected child");
            return errorReturnContext;
   
        }
   
        else if (contextExpression.startsWith("siblings")) {
   
            if (content.isDummy()) {
                context.setLastError("Cannot retrieve siblings of dummy content");
                return errorReturnContext;
            }
   
            String idxString =
                contextExpression.substring(contextExpression.indexOf("[") + 1, contextExpression.indexOf("]")).trim();
            boolean relative = (idxString.charAt(0) == '+' || idxString.charAt(0) == '-' ? true : false);
            if (idxString.charAt(0) == '+') {
                idxString = idxString.substring(1);
            }
            int idx = 0;
            try {
                idx = Integer.parseInt(idxString);
            }
            catch (NumberFormatException exc) {
                context.setLastError("Can't parse siblings index: " + contextExpression);
                return errorReturnContext;
            }
   
            WGContent sibling = navigator.getSiblingContent(content, idx, relative);
            if (sibling != null) {
                return context.getTMLContextForDocument(sibling);
            }
            else {
                context.setLastError("Could not retrieve sibling " + idxString);
                return errorReturnContext;
            }
        }
   
        else if (contextExpression.equals("this")) {
           
            if (!_explicitLanguageChoice) {
                return context;
            }
   
            if (content.isDummy()) {
                WGLanguage lang = _languageChooser.selectDatabaseLanguage(db);
                if (lang != null) {
                    return context.getTMLContextForDocument(db.getDummyContent(lang.getName()));
                }
                else {
                    return errorReturnContext;
                }
            }
View Full Code Here

Examples of de.innovationgate.webgate.api.WGDatabase

    TMLContext processExpressionFunction(TMLContext context, TMLContext errorReturnContext, WGContent mainContent, WGContentNavigator navigator)
    throws WGAPIException {
       
    String contextFunction = getFunction();
    String contextExpression = getExpression();
    WGDatabase db = context.getdocument().getDatabase();
   
    boolean isBI = (context.getDesignContext().getTag() != null ? context.getDesignContext().getTag().isBrowserInterface() : false);

    // Retrieve context by content key or unid
    if (contextFunction.equals("docid") || contextFunction.equals("content")) {
        WGContent content = null;
        WGContentKey tmpKey;
        try {
            tmpKey = WGContentKey.parse(contextExpression, context.getdocument().getDatabase());
        }
        catch (WGAPIException e) {
            context.setLastError("Error parsing contextExpression. Exception: " + e.getClass().getName() + " message: " + e.getMessage());
            return errorReturnContext;
        }
        if (tmpKey != null) {
            content = context.content().getDatabase().getContentByKey(tmpKey);
            if (content != null) {
                return context.getTMLContextForDocument(content);
            }
        }

        content =
                WGPDispatcher.getContentByAnyKey(
                    contextExpression,
                    context.content().getDatabase(),
                    _languageChooser,
                    context.isbrowserinterface());


        if (content != null) {
            return context.getTMLContextForDocument(navigator.chooseRelevantContent(content, mainContent));
        }
        else {
            context.setLastError("docid could not be resolved: " + contextExpression);
            return errorReturnContext;
        }

    }

    else if (contextFunction.equals("name")) {
       

        WGContent content = _languageChooser.selectContentForName(context.content().getDatabase(), contextExpression, context.isbrowserinterface());
        if (content != null) {
            return context.getTMLContextForDocument(navigator.chooseRelevantContent(content, mainContent));
        }
   
        context.setLastError("Could not retrieve content for name: " + contextExpression);
        return errorReturnContext;
       
    }

    // Retrieve the context of another tag
    else if (contextFunction.equals("tag")) {

        if (context.getDesignContext().getTag() == null) {
            context.setLastError("Cannot retrieve tag because this script does not run on a WebTML page");
            return errorReturnContext;
        }

        BaseTagStatus refTag = context.getDesignContext().getTag().getTagStatusById(contextExpression);
        if (refTag != null) {
            TMLContext tagContext = refTag.tmlContext;
            if (tagContext != null) {
                return tagContext;
            }
            else {
                context.setLastError("Context of this Tag could not be retrieved: " + contextExpression);
                return errorReturnContext;
            }
        }
        else {
            context.setLastError("Tag could not be retrieved: " + contextExpression);
            return errorReturnContext;
        }
    }

    else if (contextFunction.equals("db") || contextFunction.equals("plugin")) {
       
        if (contextFunction.equals("plugin")) {
            WGAPlugin plugin = context.getwgacore().getPluginSet().getPluginByUniqueName(contextExpression);
            if (plugin != null) {
                contextExpression = plugin.buildDatabaseKey();
            }
            else {
                context.setLastError("Unknown plugin unique name: " + contextExpression);
                return errorReturnContext;
            }
        }
       
        WGDatabase dbTarget = null;
        try {
            dbTarget = context.db(context.resolveDBKey(contextExpression));
        }
        catch (WGUnavailableException e1) {
            context.setLastError("Database '" + contextExpression + "' is currently unavailable");
            return errorReturnContext;
        }
        catch (WGException e) {
            context.setLastError("Unable to open database '" + contextExpression + "'. Exception: " + e.getClass().getName() + " message: " + e.getMessage());
            return errorReturnContext;
        }

        if (dbTarget == null) {
            context.setLastError("No database with key " + contextExpression);
            return errorReturnContext;
        }

        if (dbTarget.isSessionOpen() == false) {
            context.setLastError("User cannot open database '" + contextExpression + "'");
            return errorReturnContext;
        }

        if (dbTarget.getSessionContext().getAccessLevel() <= WGDatabase.ACCESSLEVEL_NOACCESS) {
            context.setLastError("User has no access to database '" + contextExpression + "'");
            return errorReturnContext;
        }

        TMLContext dbContext = context.dbContext(dbTarget);
View Full Code Here

Examples of de.innovationgate.webgate.api.WGDatabase

  /* (Kein Javadoc)
   * @see de.innovationgate.wgpublisher.scheduler.Task#execute(de.innovationgate.wgpublisher.scheduler.JobContext)
   */
  public void execute(JobContext jobContext) throws TaskException {
 
    WGDatabase db;
    try {
      db = jobContext.getWgaCore().openContentDB(_database, null, true);
    }
    catch (WGUnavailableException e) {
      throw new TaskException("Database '" + _database + "' is unavailable");
    }
        catch (WGException e) {
            throw new TaskException(e.getMessage());
        }
    if (db == null) {
      throw new TaskException("Database '" + _database + "' does not exist");
    }
    else if (db.isSessionOpen() == false) {
      throw new TaskException("Cannot open database '" + _database + "'");
    }

    WGCSSJSModule module;
        try {
            module = db.getCSSJSModule(_module, WGScriptModule.CODETYPE_TMLSCRIPT);
            if (module == null) {
                throw new TaskException("Script module '" + _module + "' does not exist in database '" + _database + "'");
            }
        }
        catch (WGAPIException e) {
            throw new TaskException("Error retrieving script module '" + _module + "' from database '" + _database + "'", e);
        }
   
   
    ExpressionEngine engine = ExpressionEngineFactory.getTMLScriptEngine();
   
   
   
   
    // Create necessary context objects
        WGContent dummyContent;
        try {
            dummyContent = db.getDummyContent(db.getDefaultLanguage());
        }
        catch (WGAPIException e) {
            throw new TaskException("Unable to retrieve dummy content context from database " + db.getDbReference(), e);
        }
       
    TMLContext context;
        try {
            context = new TMLContext(dummyContent, jobContext.getWgaCore(), null, null);
        }
        catch (WGAPIException e) {
            throw new TaskException("Unable to create context." + db.getDbReference(), e);
        }
    Map objects = new HashMap();
    objects.put("jobContext", jobContext);
    objects.put(RhinoExpressionEngine.PARAM_SCRIPTNAME, "TMLScript-Task running module " + _database + "/" + _module + " for scheduler job '" +  jobContext.getCurrentJob().getName() + "'");
   
        String code;
        try {
            code = module.getCode();
        }
        catch (WGAPIException e) {
            throw new TaskException("Unable to retrieve code of module '" + _module + "' from database " + db.getDbReference(), e);
        }
       
    ExpressionResult result = engine.evaluateExpression(code, context, ExpressionEngine.TYPE_SCRIPT, objects);
    if (result.isError()) {
      throw new TaskException("Error executing TMLScript task", result.getException());
View Full Code Here

Examples of de.innovationgate.webgate.api.WGDatabase

            synchronized (CSAuthModule.this) {
           
                try {
                    _currentCollectorThread = Thread.currentThread();
                    WGDatabase db = (WGDatabase) _core.getContentdbs().get(_dbkey);
                    if (db == null) {
                        _core.getLog().error("Cannot collect authentications from db '" + _dbkey + "' because the db is not connected");
                        return;
                    }
                   
                    db.openSession();
                    db.getSessionContext().setTask("CS Authentication Module - Login collection task");
                   
                    // Try to read configuration
                    readConfigurationProperties(db);
   
                    // Collect logins
View Full Code Here

Examples of de.innovationgate.webgate.api.WGDatabase

   
    if (!isAdminSession(session)) {
      throw new WGAServiceException("You need an administrative login to access this service.");
    }
   
    WGDatabase db = retrieveAndOpenDB(session, dbKey);
    if (db.isSessionOpen()) {
      WGDesignProvider provider = db.getDesignProvider();
      if (provider instanceof FileSystemDesignProvider) {
        return ((FileSystemDesignProvider)provider).getDesignPath();
      } else {
        return null;
      }
View Full Code Here

Examples of de.innovationgate.webgate.api.WGDatabase

        if (!isAdminSession(session)) {
            throw new WGAServiceException("You need an administrative login to access this service.");
        }
       
        try {
            final WGDatabase db = retrieveAndOpenDB(session, dbKey);
            if (db != null && db.isSessionOpen()) {
                return new DataSource() {
                   
                    public OutputStream getOutputStream() throws IOException {
                        return null;
                    }
                   
                    public String getName() {
                        return "Dump '" + db.getDbReference() + "'";
                    }
                   
                    public InputStream getInputStream() throws IOException {
                        try {
                            return _core.dumpContentStore(db, "", true, _core.getLog(), includeACL, includeSystemAreas);
View Full Code Here

Examples of de.innovationgate.webgate.api.WGDatabase

        if (!isAdminSession(session)) {
            throw new WGAServiceException("You need an administrative login to access this service.");
        }
       
        try {
            WGDatabase db = retrieveAndOpenDB(session, dbKey);
            if (db != null && db.isSessionOpen()) {
                _core.importContentStoreDump(new ZipInputStream(csDump.getInputStream()), db, _core.getLog(), includeACL, includeSystemAreas);
            } else {
                throw new WGAServiceException("Unable to open database '" + dbKey + "'.");
            }
            // reconnect cs
View Full Code Here

Examples of de.innovationgate.webgate.api.WGDatabase

   
  public void tmlEndTag() throws TMLException, WGAPIException {

      Status status = (Status) getStatus();
    WGDatabase database = this.getMainContext().getdocument().getDatabase();
       
    // Set WebTML scope option
        String scope = getTmlscope();
        if (scope != null) {
            status.setOption(Base.OPTION_WEBTML_SCOPE, scope, TMLOption.SCOPE_GLOBAL);
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.