Examples of TMLContext


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

   
  }

  protected boolean innerTestCondition() {

        TMLContext context = this.getTMLContext();
        context.setrole(this.getRole());
      try {
     
      WGContent content = context.content();
     
      String attValue;
      attValue = this.getIstrue();
      if (attValue != null) {
        if (!context.istrue(attValue)) {
          return false;
        }
      }
   
      attValue = this.getIsfalse();
      if (attValue != null) {
        if (!context.isfalse(attValue)) {
          return false;
        }
      }
     
      attValue = this.getIsdefined();
      if (attValue != null) {
        if (!context.isdefined(attValue)) {
          return false;
        }
      }
     
      attValue = this.getCondition();
      if (attValue != null) {
        ExpressionEngine engine = ExpressionEngineFactory.getEngine(this.getConditionlanguage());
        if (engine == null) {
          this.addWarning("Unknown expression language: " + this.getConditionlanguage(), true);
          return false;
        }
       
       
        Map objects = new HashMap();
        objects.put(RhinoExpressionEngine.PARAM_SCRIPTNAME, "Condition on " + getTagDescription());
        ExpressionResult result = engine.evaluateExpression(attValue, this.getTMLContext(), ExpressionEngine.TYPE_EXPRESSION, objects);
        if (result.isError()) {
            addExpressionWarning(attValue,result);
          return false;
        }
        else if (result.isFalse()) {
          return false;
        }
      }
   
      attValue = this.getIsselected();
      if (attValue != null) {
        boolean isSelected = context.isselected();
        if (this.stringToBoolean(attValue) == false) {
          isSelected = !isSelected;
        }
        if (isSelected == false) {
          return false;
        }
      }
     
      attValue = this.getHaschildren();
      if (attValue != null) {
        boolean hasChildren = context.haschildren();
        if (this.stringToBoolean(attValue) == false) {
          hasChildren = !hasChildren;
        }
        if (hasChildren == false) {
          return false;
        }       
      }
     
      attValue = this.getHassiblings();
      if (attValue != null) {
        boolean hasSiblings = context.hassiblings();
        if (this.stringToBoolean(attValue) == false) {
          hasSiblings = !hasSiblings;
        }
        if (hasSiblings == false) {
          return false;
        }       
      }

      attValue = this.getHasoption();
      if (attValue != null) {
        if(!context.hasoption(attValue))
          return false;
      }

      attValue = this.getIsroot();
      if (attValue != null) {
        boolean isRoot = context.isroot();
        if (this.stringToBoolean(attValue) == false) {
          isRoot = !isRoot;
        }
        if (isRoot == false) {
          return false;
        }
      }
     
      attValue = this.getIscurrentdocument();
      if (attValue != null) {
        boolean isCurrentDocument = context.ismaindocument();
        if (this.stringToBoolean(attValue) == false) {
          isCurrentDocument = !isCurrentDocument;
        }
        if (isCurrentDocument == false) {
          return false;
        }
      }
     
      attValue = this.getHasurlparameter();
      if (attValue != null) {
        String urlParam = this.pageContext.getRequest().getParameter(attValue);
        boolean hasUrlParameter = (urlParam != null ? true : false);
        if (hasUrlParameter == false) {
          return false;
        }
      }
     
      attValue = this.getHasnextpage();
      if (attValue != null) {
        IterationTagStatus iterationTag = (IterationTagStatus) this.getTagStatusById(attValue, IterationTagStatus.class);
        if (iterationTag == null) {
          this.addWarning("Could not find iteration tag: " + this.getHasnextpage());
          return false;
        }
        if (!iterationTag.hasNextPage()) {
          return false;
        }
      }
   
      attValue = this.getHaspreviouspage();
      if (attValue != null) {
          IterationTagStatus iterationTag = (IterationTagStatus) this.getTagStatusById(attValue, IterationTagStatus.class);
        if (iterationTag == null) {
          this.addWarning("Could not find iteration tag: " + attValue);
          return false;
        }
        if (!iterationTag.hasPreviousPage()) {
          return false;
        }
      }
     
      attValue = this.getIscontextvalid();
      if (attValue != null) {
        boolean iscontextvalid = !this.isChildContextErrornous();
        if (this.stringToBoolean(attValue) == false) {
          iscontextvalid = !iscontextvalid;
        }
        if (iscontextvalid == false) {
          return false;
        }
      }
     
      attValue = this.getIstagidvalid();
      if (attValue != null) {
        boolean istagidvalid = (this.getTagStatusById(attValue) != null ? true : false);
        if (istagidvalid == false) {
          return false;
        }
      }
           
      attValue = this.getPlatform();
      if (attValue != null) {
        if (!attValue.equalsIgnoreCase("wgpublisher")) {
          return false;
        }
      }
     
      attValue = this.getDoctype();
      if (attValue != null) {
        if (content.getStructEntry() == null || content.getStructEntry().getContentType() == null) {
          return false;
        }
       
        if (!attValue.equalsIgnoreCase(content.getStructEntry().getContentType().getName())) {
          return false;
        }
      }
     
      attValue = this.getIsbrowserinterface();
      if (attValue != null) {
        boolean isBI = context.isbrowserinterface();
        if (this.stringToBoolean(attValue) == false) {
          isBI = !isBI;
        }
        if (isBI == false) {
          return false;
        }
      }
     
      attValue = this.getIseditmode();
      if (attValue != null) {
        boolean isEditmode = (context.isbrowserinterface() && content.getStatus().equals(WGContent.STATUS_DRAFT));
        if (this.stringToBoolean(attValue) == false) {
          isEditmode = !isEditmode;
        }
        if (isEditmode == false) {
          return false;
        }
      }
     
      attValue = this.getIsnewsession();
      if (attValue != null) {
        boolean isNewSession = context.isnewsession();
        if (this.stringToBoolean(attValue) == false) {
          isNewSession = !isNewSession;
        }
        if (isNewSession == false) {
          return false;
        }
      }
     
      attValue = this.getPortletmode();
      if (attValue != null) {
        List modesToTest = WGUtils.deserializeCollection(attValue.toLowerCase(), ",", true);
        HttpSession session = this.pageContext.getSession();
        TMLPortlet portlet = context.getportlet();
                if (portlet == null) {
                    addWarning("Portlet mode was tested although no portlet was registered", false);
                    return false;
                }
               
                String portletMode  = portlet.getmode();
        if (!modesToTest.contains(portletMode.toLowerCase())) {
          return false;
        }
      }
     
      attValue = this.getHasprofile();
      if (attValue != null) {
       
        boolean hasProfile = context.hasprofile();
        if (this.stringToBoolean(attValue) == false) {
          hasProfile = !hasProfile;
        }
        if (hasProfile == false) {
          return false;
        }
       
      }
     
      attValue = this.getLanguage();
      if (attValue != null) {
       
        String prefLanguage = getTMLContext().getpreferredlanguage();
        if (prefLanguage == null) {
          prefLanguage = (String) getTMLContext().meta("language");
        }
        if (!prefLanguage.equals("attValue")) {
          return false;
        }
               
      }
           
            attValue = this.getIsempty();
            if (attValue != null) {
                if (!getTMLContext().isempty(attValue)) {
                    return false;
                }
            }

            attValue = this.getIsfilled();
            if (attValue != null) {
               
                // Bypass this test in edit mode (as it most likely is used to hide fields that are not filled)
                boolean isEditmode = (context.isbrowserinterface() && content.getStatus().equals(WGContent.STATUS_DRAFT));
                if (!isEditmode) {
                    if (getTMLContext().isempty(attValue)) {
                        return false;
                    }
                }
            }
           
            attValue = this.getIsfirstloop();
            if (attValue != null) {
              boolean firstLoop = false;
              if (WGUtils.isBooleanValue(attValue)) {
                firstLoop = getTMLContext().isfirstloop();
                if (this.stringToBoolean(attValue) == false) {
            firstLoop = !firstLoop;
          }
              } else {
                firstLoop = getTMLContext().isfirstloop(attValue);
              }
              if (firstLoop == false) {
                return false;
              }
            }
           
            attValue = this.getIslastloop();
            if (attValue != null) {
              boolean lastLoop = false;
              if (WGUtils.isBooleanValue(attValue)) {
                lastLoop = getTMLContext().islastloop();
                if (this.stringToBoolean(attValue) == false) {
            lastLoop = !lastLoop;
          }
              } else {
                lastLoop = getTMLContext().islastloop(attValue);
              }
              if (lastLoop == false) {
                return false;
              }
            }
           
      return true;
    }
    catch (Exception exc) {
      log.error("Error evaluating expression", exc);
      return false;
    }
    catch (Error err) {
      log.error("Error evaluating expression", err);
      return false;
    }
    finally {
        context.setrole(null);
    }
  }
View Full Code Here

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

    public void createFileURL(WGContent content, StringBuffer url) throws WGException, UnsupportedEncodingException {
       
        Status status = (Status) getStatus();
       
        // Get the correct db for building file URL
        TMLContext fileContext = getTMLContext();

        if (!stringToBoolean(getDataurl())) {
            url.append(fileContext.fileurl(getDb(), getDoc(), getFile()));
        } else {
            //render data url (RFC 2397)
            url.append(fileContext.filedataurl(getDb(), getDoc(), getFile(), null));
            status.encodeURL = false;
        }
        return;
    }
View Full Code Here

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

                if (content == null) {
                    content = (WGContent) event.getDatabase().getDocumentByDocumentKey(event.getDocumentKey());
                }
           
                if (content != null) {
                    TMLContext context = new TMLContext(event.getContent(), _core, null, null);
                    Map objects = new HashMap();
       
                    // Execute script
                    ExpressionEngine engine = ExpressionEngineFactory.getTMLScriptEngine();
                    ExpressionResult result = engine.evaluateExpression(_collectCondition, context, ExpressionEngine.TYPE_EXPRESSION, objects);
View Full Code Here

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

            if (!mayCallAction(db, actionID)) {
                throw new WGAServiceException("You are not permitted to call remote action '" + actionID + "'");
            }
           
            // Get root content and action
            TMLContext context = new TMLContext(db.getDummyContent(db.getDefaultLanguage()), _core, null, null);
            context.makeThreadMainContext();
           
            TMLAction action = context.getActionByID(actionID, null);
            if (action == null) {
                throw new WGAServiceException("Undefined action: " + actionID);
            }
           
            // Calculate execution context
            if (executionContext != null) {
                context = context.context(executionContext, false);
                if (context == null) {
                    throw new WGAServiceException("Unretrievable execution context: " + executionContext);
                }
            }
           
            // Create TMLForm, if form information was issued
            if (form != null) {
                FormInfo formInfo = new FormInfo(form.getId(), false, false);
                formInfo.setSource("none");
                formInfo.setKeepOnValidate(false);
                CSConfig csConfig = (CSConfig) db.getAttribute(WGACore.DBATTRIB_CSCONFIG);
                if (csConfig != null) {
                    formInfo.setVersionCompliance(csConfig.getVersionCompliance());
                }
                de.innovationgate.wgpublisher.webtml.utils.TMLForm tmlForm = context.createform(formInfo);
                tmlForm.importServicesForm(form);
            }
           
            // Create map of parent scope objects
            Map<String, Object> parentScopeObjects = new HashMap<String, Object>();
            parentScopeObjects.put(SCRIPTOBJ_WGASERVICESCONTEXT, _contextProvider);
           
            // Call action
            Object result = context.callCustomAction(action, params, parentScopeObjects);
            if (context.isdefined("actionresult")) {
                ExpressionResult expressionResult = (ExpressionResult) context.item("actionresult");
                if (expressionResult.isError()) {
                    WGExpressionException ex = expressionResult.getException();
                   
                    // User defined TMLScript exception should be passed on unmodified
                    if (ex.getCause() instanceof TMLScriptException) {
View Full Code Here

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

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

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

   * @see Base#tmlEndTag()
   */
  public void tmlEndTag() throws TMLException, WGAPIException {

    try {
            TMLContext context = this.getTMLContext();
            WGContent content = context.content()
           
            // Build link body
            String contentURL = context.contenturl(this.getMedium(), this.getLayout());
            String imageBaseURL = context.contenturl(this.getMedium(), this.getLayout(), true);
            String linkBody = null;
            String moEventAttributes = "";
           
           
            linkBody = content.getTitle();
View Full Code Here

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

      _log.error("Error executing event script. Unknown script type: " + eventScript.getType());
      return null;
    }
   
    // Create necessary context objects
    TMLContext context;
        try {
            context = new TMLContext(event.getdocument(), _core, event.getUserProfile(), null);
        }
        catch (WGAPIException e) {
            _log.error("Error creating context for event script.", e);
            return null;
        }
View Full Code Here

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

                throw new WGException("Script module '" + _scriptCollect + "' in Database '" + _dbkey + "' is not of type TMLScript");
            }

            // Build a TMLScript runtime
            ExpressionEngine engine = ExpressionEngineFactory.getTMLScriptEngine();
            TMLContext context = new TMLContext(db.getDummyContent(db.getDefaultLanguage()), _core, null, null);
            Map objects = new HashMap();
            objects.put("logins", newLoginInformation);
            objects.put("groups", newGroupInformation);

            // Execute script
View Full Code Here

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

        // Update portlet event index information
        TMLPortlet childPortlet = getTMLContext().getportlet();       
        childPortlet.prepareEventProcessing(this);
       
        // set child tag context to portlet context if set
        TMLContext portletContext = childPortlet.getcontext();
        if (portletContext != null) {
          setChildTagContext(portletContext);
        }
       
        // if ajax enabled
        if (status.ajax) {
            String uniquePortletID = pReg.getKey();
           
            // create prefix buffer
            StringBuffer prefix = new StringBuffer();
            // create suffix buffer
            StringBuffer suffix = new StringBuffer();
           
            // set id as option, so tags from included module can retrieve it for rendering ajaxCall
            status.setOption(OPTION_AJAX_DIVTAG_ID, uniquePortletID, null);
            // set tmlModule as option, so tags from included module can retrieve the tmlmodulename
            status.setOption(OPTION_PORTLET_TMLMODULE, pReg.getDesign(), null);
                               
            // create ajaxInfo
            AjaxInfo ajaxInfo = new AjaxInfo(uniquePortletID);
            try {
        URLBuilder builder = new URLBuilder(getTMLContext().getrequest());
        builder.removeParameter("$action");
        java.net.URL url = builder.rebuild();
        ajaxInfo.setQueryString(url.getQuery());
      } catch (Exception e1) {
        getTMLContext().addwarning("Unable to build request querystring for ajax environment.");
      }
            ajaxInfo.setTmlmodule(pReg.getDesign());
            ajaxInfo.setDesignDB(pReg.getDesignDb() != null ? pReg.getDesignDb() : getDesigndb());
            ajaxInfo.setMediaKey((String)this.getOption(OPTION_CURRENT_MEDIAKEY));
            if (portletContext != null) {
              ajaxInfo.setContextPath(portletContext.getpath());
            } else {
              ajaxInfo.setContextPath(this.getTMLContext().getpath());
            }
            ajaxInfo.setOptions(getStatus().getTagOptions());
            if (getTMLContext().getprofile() != null) {
View Full Code Here

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


  public void tmlEndTag() throws WGAPIException {
   
    String itemName = this.getName();
    TMLContext tmlContext = this.getTMLContext();
    List result = null;
    String type = this.getType();
       
        // add warning on illegal use of highlight attribute
        if (stringToBoolean(getHighlight())) {
            if (!type.equals("content")) {
                addWarning("Highlighting can only be used with type 'content' - skipped.");
            }
        }
   
    // Retrieve value
    if (type.equals("content")) {
      result = tmlContext.itemlist(itemName);
            if (stringToBoolean(getHighlight())) {
                if (this.stringToBoolean(this.getScriptlets())) {
                    addWarning("Highlighting cannot be used with scriptlets - skipped.");                   
                } else if (this.getAliases() != null) {
                        addWarning("Highlighting cannot be used with aliases - skipped.");   
                } else if (getXpath() != null) {
                    addWarning("Highlighting cannot be used together with xpath - skipped.");
                } else {
                    // highlight itemvalue with information from lucene query
                    result = Collections.singletonList(tmlContext.highlightitem(itemName, getHighlightprefix(), getHighlightsuffix(), getStatus().encode));
                    getStatus().encode = "none";
                }
            }
    }
    else if (type.equals("profile")) {
      TMLUserProfile profile = tmlContext.getprofile();
      if (profile == null) {
        this.addWarning("Current user has no profile", true);
        return;
      }
      result = profile.itemlist(itemName);
    }
    else if (type.equals("portlet")) {
      TMLPortlet portlet = tmlContext.getportlet();
      if (portlet == null) {
        this.addWarning("Current user has no portlet registration", true);
        return;
      }
      result = portlet.itemlist(itemName);
    }
        else if (type.equals("tmlform")) {
            TMLForm form = tmlContext.gettmlform();
            if (form == null) {
                addWarning("There is no current WebTML form at this position in the current request");
                return;
            }
            result = form.fieldlist(itemName);
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.