Package de.innovationgate.wgpublisher.webtml.utils

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


        if (parentPortlet == null) {
            if (getTMLContext().isbotrequest()) {
                throw new TMLSilentCancelException();
            }
            else {
                throw new TMLException("Current user has no portlet registration");
            }
        }
       
        String pKey = getKey();
        String pName = getName();

        //  If no key direcly given try to fetch via portlet name
        if (pKey == null && pName != null) {
            pKey = parentPortlet.getPortletKeyForName(pName);
        }
       
        // Fetch registration info if key provided
        WGPortlet pReg = null;
        if (pKey != null) {
            pReg = parentPortlet.getPortletRegistration(pKey);
        }

        // If reg not retrievable and auto registration info available try auto registration, else cancel
        if (pReg == null) {
            if (pName != null && status.ref != null) {
                pKey = parentPortlet.registerportletforname(pName, status.designdb, status.ref, false);
                pReg = parentPortlet.getPortletRegistration(pKey);
            }
            else {
                if (pName != null) {
                    throw new TMLException("Portlet name not registered: " + pName, true);
                }
                else if (pKey != null) {
                    throw new TMLException("Portlet key not registered: " + pKey, true);
                }
                else {
                    throw new TMLException("No portlet key provided.", true);
                }
            }
        }

        // Check if registration matchtes the autoregister TML. If not, reregister with the given TML.
        else if (status.ref != null) {
       
                // If the registration has no design database specified we take the current design db (which is always equal)
                if (pReg.getDesignDb() == null) {
                    pReg.setDesignDb(status.designdb);
                }
           
               if (!WGUtils.nullSafeEquals(status.ref, pReg.getDesign(), true) ||
                   (!WGUtils.nullSafeEquals(status.designdb, pReg.getDesignDb(), true))) {
                     pKey = parentPortlet.registerportletforname(pName, status.designdb, status.ref, true);
                     pReg = parentPortlet.getPortletRegistration(pKey);
               }
              
        }
       
        // Prepare environment
        status.setOption(Base.OPTION_PORTLET_NAMESPACE, pKey, null);
        if (pReg.getDesignDb() != null) {
            status.designdb = pReg.getDesignDb();
        }
        status.ref = getTMLContext().resolveDesignReference(pReg.getDesign());
       
        // 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) {
                ajaxInfo.setSaveProfileOnEnd(getTMLContext().getprofile().isSavedOnEnd());
            }
            else {
                ajaxInfo.setSaveProfileOnEnd(false);
            }
            ajaxInfo.setSuperform(getStatus().getRelevantForm());

           
            // create javascript object with ajaxInfo                   
            // serialize       
            String serAjaxInfo = new XStream(new Dom4JDriver()).toXML(ajaxInfo);
            // zip
            byte[] zipped  = Zipper.zip(serAjaxInfo);
            String encryptedAjaxInfo = "";
            if (zipped != null) {
                // encrypt
                try {
                    encryptedAjaxInfo= this.getTMLContext().getwgacore().getDesEncrypter().encrypt(zipped);
                }
                catch (UnsupportedEncodingException e) {
                   throw new TMLException("Cannot render ajax enabled include because of unsupported encoding: " + e.getMessage(), true);
                }
            }                   
           
            // iframe for form submit
            // to prevent iframe from deletion by ajaxCall it has to be outside the divTag
View Full Code Here


      ResultSetTagStatus tag;

      if (this.getSourcetag() != null) {
        tag = (ResultSetTagStatus) this.getTagStatusById(this.getSourcetag(), ResultSetTagStatus.class);
        if (tag == null) {
          throw new TMLException("Could not find content list tag with id " + this.getSourcetag(), true);
        }
      }
      else if (this.getRelationgroup() != null) {
          String group = getRelationgroup();
          status.contentLanguage = getTMLContext().content().getLanguage().getName();
              return new ResultIterator(getTMLContext().content().getRelationsOfGroup(group));
      }
      else if (getStatus() instanceof ResultSetTagStatus) {
        tag = (ResultSetTagStatus) getStatus();
      }
      else {
        tag = (ResultSetTagStatus) getStatus().getAncestorTag(ResultSetTagStatus.class);
        if (tag == null) {
          throw new TMLException("No content list tag specified", true);
        }
      }

      objectIterator = tag.getResultIterator();
            status.contentLanguage = tag.getResultLanguage();
     
    }
    else if (status.forEachType.equals("loop") || status.forEachType.equals("level")) {

      int count = 0;
      if (status.forEachType.equals("loop")) {
        String strCount = this.getCount();
        if (strCount == null) {
          throw new TMLException("Foreach with type loop but without attribute count", true);
        }
        count = stringToInteger(strCount, 0);
      }
      else if (status.forEachType.equals("level")) {
          WGContentNavigator nav = new WGContentNavigator(null, new WebTMLLanguageChooser(getTMLContext().db(), getTMLContext()));
        count = nav.getContentLevel(this.getTMLContext().content()).intValue();
      }
      List objects = new java.util.ArrayList();
      for (int idx = 0; idx < count; idx++) {
        objects.add(new Integer(idx + 1));
      }
      objectIterator = new ResultIterator(objects.iterator(), objects.size());
    }
    else if (status.forEachType.equals("itemvalue")) {
      Object obj = this.getTMLContext().itemlist(this.getItem());
      if (obj == null) {
        throw new TMLException("Could not retrieve item " + this.getItem(), true);
      }
      if (obj instanceof List) {
        objectIterator = new ResultIterator((java.util.List) obj);
      }
      else {
        objectIterator = new ResultIterator(java.util.Collections.singletonList(obj));
      }
     
    }
    else if (status.forEachType.equals("fieldvalue")) {
      Object obj=null;
      // Register with form parent (if present) and retrieve item values from it;
      FormInputRegistrator form = (FormInputRegistrator) getStatus().getAncestorTag(FormBase.class)
      if (form != null)
        obj=form.getFieldValue(this.getItem(), false, "", false);
      else obj = this.getTMLContext().itemlist(this.getItem());
     
      if (obj == null) {
        throw new TMLException("Could not retrieve item " + this.getItem(), true);
      }
      if (obj instanceof List) {
        objectIterator = new ResultIterator((java.util.List) obj);
      }
      else {
        objectIterator = new ResultIterator(java.util.Collections.singletonList(obj));
      }
     
    }
    else if (status.forEachType.equals("tagresult")) {
      if (this.getSourcetag() == null) {
        throw new TMLException("No tag specified to take tagresult from", true);
      }
      BaseTagStatus tag = this.getTagStatusById(this.getSourcetag());
      if (tag == null) {
        throw new TMLException("Could not find tag with id " + this.getSourcetag(), true);
      }
      Object result = tag.result;
      if (de.innovationgate.utils.WGUtils.isCollection(result)) {
        objectIterator = new ResultIterator((java.util.Collection) result);
      }
      else {
        objectIterator = new ResultIterator(java.util.Collections.singletonList(result));
      }
    }
    else {
      throw new TMLException("Unknown type for foreach tag: " + status.forEachType, true);
    }
        return objectIterator;
    }
View Full Code Here

    }
    else if (type.equals("versions")) {
        status.contentList = relContent.getStructEntry().getAllContent(true);
    }
    else {
        throw new TMLException("Unknown navigator type: " + type, true);
    }
   
    String exclude = getExclude();
    if (exclude != null) {
        TMLContext excludeContext = getTMLContext().context(exclude, false);
View Full Code Here

      public ResultIterator getResultIterator() throws TMLException {
          if (contentList != null) {
              return new ResultIterator((List) contentList);
          }
          else {
              throw new TMLException("Tag has no result list", true);
          }
      }
View Full Code Here

            if (modDef != null) {
                try {
                    modDef.testDependencies();
                }
                catch (ModuleDependencyException e) {
                    throw new TMLException("WebTML element '" + name + "' not available bc. of missing dependency: " + e.getMessage(), true);
                }
                className = modDef.getImplementationClass().getName();
            }
        }
        
View Full Code Here

TOP

Related Classes of de.innovationgate.wgpublisher.webtml.utils.TMLException

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.