Examples of WGContent


Examples of de.innovationgate.webgate.api.WGContent

          enableDebug(session);
        }
       
        // Determine, which (if any) document can be edited in this request
        if (status.isBrowserInterface()) {
          WGContent content = this.getTMLContext().content();       
                 
          List userNamesList = new ArrayList();
          userNamesList.add(content.getAuthor());
          
          if ( content.getStatus().equals(WGContent.STATUS_DRAFT)
            && (!content.hasCompleteRelationships() || content.getStructEntry().mayEditEntryAndContent() == null)
            && content.getLanguage().mayCreateContent()
            && content.getDatabase().isMemberOfUserList( userNamesList )
            && !content.hasItem("remote_info")
            ) {     
           
            pageContext.getRequest().setAttribute(WGACore.ATTRIB_EDITDOCUMENT, content.getContentKey().toString());
          }
        }

       
        // process multipartformdata
View Full Code Here

Examples of de.innovationgate.webgate.api.WGContent

    public WGContent getContentByTitlePath(HttpServletRequest request) throws WGAPIException, UnsupportedEncodingException {

        TitlePathManager tpm = (TitlePathManager) database.getAttribute(WGACore.DBATTRIB_TITLEPATHMANAGER);
        TitlePath titlePathURL = getTitlePathURL();
       
        WGContent pathContent = null;
        try {
            pathContent = tpm.findContentByTitlePath(titlePathURL, database, new RequestLanguageChooser(database, request), TitlePathManager.MODE_URL);
        }
        catch (RemainingPathElementException e) {
            // Cannot happen with MODE_URL of title path manager
View Full Code Here

Examples of de.innovationgate.webgate.api.WGContent

        }

        protected void exec(WGDatabase db) throws Throwable {

            // Find the document that the link in remote source doc points to
            WGContent content = WGPDispatcher.getContentByAnyKey(_linkKey, db, _languageChooser, false);
            if (content == null) {
                return;
            }
           
            Iterator refs = content.getItemValueList("remote_references").iterator();
            while (refs.hasNext()) {
                String refStr = (String) refs.next();
                try {
                    RemoteDocReference ref = new RemoteDocReference(refStr);
                   
                    // If we find a reference that point to our remote consumer db we will return
                    // the key of that document
                    if (ref.getDbKey().equals(_remoteConsumerDB)) {
                        _targetDBKey = null;
                        _targetContentKey = ref.getContentKey();
                        return;
                    }
                }
                catch (IllegalArgumentException e) {
                    WGFactory.getLogger().error("Illegal remote doc reference on " + content.getDocumentKey() + " (DB " + db.getDbReference() + ")" ,e);
                }
               
            }
           
            // If we find no suitable reference we point to the remote source document
            _targetDBKey = db.getDbReference();
            _targetContentKey = content.getContentKey().toString();
           
        }
View Full Code Here

Examples of de.innovationgate.webgate.api.WGContent

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

Examples of de.innovationgate.webgate.api.WGContent

            status.queryParameters.putAll(collectionTag.getQueryParameters());
        }
       
        // Put default query parameters
        try {
            WGContent content = getTMLContext().content();
            Map<String, Object> defaultParameters = buildDefaultQueryParams(content);
            for (Map.Entry<String,Object> param : defaultParameters.entrySet()) {
                WGUtils.setDefaultProperty(status.queryParameters, param.getKey(), param.getValue());
            }
        }
View Full Code Here

Examples of de.innovationgate.webgate.api.WGContent

     */
    private List<WGContentKey> recurseExpressionQuery(ExpressionEngine engine, WGStructEntryList entryList, String language, String expr, boolean deep, int maxDocs, String role) throws WGAPIException {

        Iterator childEntries = entryList.iterator();
        WGStructEntry childEntry;
        WGContent childContent;
        List<WGContentKey> results = new ArrayList<WGContentKey>();
        while (childEntries.hasNext()) {
            childEntry = (WGStructEntry) childEntries.next();
            childContent = childEntry.getReleasedContent(language);
            if (childContent != null) {
               
                if (role == null || childContent.isVisibleFor(role)) {
                    ExpressionResult result = engine.evaluateExpression(expr, getTMLContextForDocument(childContent), ExpressionEngine.TYPE_EXPRESSION, null);
                    if (result.isTrue()) {
                        results.add(childContent.getContentKey());
                        if (maxDocs != 0 && results.size() >= maxDocs) {
                            break;
                        }
                    }
                   
View Full Code Here

Examples of de.innovationgate.webgate.api.WGContent

            try {
                if (firstContentRetrieved) {
                    return;
                }
               
                WGContent tryContent = null;
                for  (int offset = 0; offset < _resultSet.results(); offset++) {
                    try {
                        List contentList = _resultSet.getContentList(offset+1, 1);
                        if (contentList.size() >= 1) {
                            tryContent = (WGContent) contentList.get(0);
                            if (tryContent.mayBePublished(tmlContext.isbrowserinterface(), _role)) {
                                firstContent = tryContent;
                                break;
                            }
                        }
                    }
View Full Code Here

Examples of de.innovationgate.webgate.api.WGContent

        // If the relation is "broken" or empty we try to resolve it by using struct and language information
        WGStructEntry entry = _parent.getDb().getStructEntryByKey(relation.getTargetstructentry());
        if (entry == null) {
            return null;
        }
        WGContent content = entry.getReleasedContent(relation.getTargetlanguage());
        if (content != null) {
            return content.getCore();
        }
        else {
            return null;
        }
View Full Code Here

Examples of de.innovationgate.webgate.api.WGContent

     */
    public void tmlEndTag() throws TMLException, WGAPIException {
       
        Status status = (Status) getStatus();
       
        WGContent content = this.getTMLContext().content();
        StringBuffer url = new StringBuffer();

        String type = this.getType();
        String fileName = this.getFile();
        String actionName = this.getAction();
View Full Code Here

Examples of de.innovationgate.webgate.api.WGContent

                                                }
                                            });
                                            for (File container : containers) {
                                                if (container.getName().startsWith("content:")) {
                                                    String contentKey = container.getName().substring("content:".length());
                                                    WGContent content = db.getContentByKey(contentKey);
                                                    if (content == null || !content.getStatus().equals(WGContent.STATUS_RELEASE)) {
                                                        // content has been deleted or archived - remove file data
                                                        _core.getLog().info("Content '" + contentKey + "' has been deleted or archived. Clearing external file serving cache.");
                                                        WGUtils.delTree(container);
                                                        if (container.exists()) {
                                                            _core.getLog().warn("External file cache maintenance failed. Unable to remove directory '" + container.getAbsolutePath() + "'. Cache might serve stale file data.");           
                                                        }
                                                    } else {
                                                        // check general access to content                                                   
                                                        if (content.getReaders().size() > 0) {
                                                            // delete all deployed files of content
                                                            _core.getLog().info("Content '" + content.getContentKey() + "' is not accessible by anonymous. Clearing external file serving cache.");
                                                            WGUtils.delTree(container)
                                                            if (container.exists()) {
                                                                _core.getLog().warn("External file cache maintenance failed. Unable to remove directory '" + container.getAbsolutePath() + "'. Cache might serve stale file data.");           
                                                            }
                                                        } else {
                                                            // check for existence and size of files
                                                            File[] deployedFiles = container.listFiles();
                                                            for (File deployedFile : deployedFiles) {
                                                                if (deployedFile.isFile()) {
                                                                    if (!content.hasFile(deployedFile.getName())) {
                                                                        _core.getLog().info("File '" + deployedFile.getName() + "' has been removed from content '" + content.getContentKey() + "' and will be removed from external file serving cache.");
                                                                        if (!deployedFile.delete()) {
                                                                            _core.getLog().warn("Unable to delete external file serving data '" + deployedFile.getAbsolutePath() + "'. File cache might serve stale data.");
                                                                        }
                                                                    } else if (deployedFile.length() < config.getThreshold()) {
                                                                        _core.getLog().info("Deployed file '" + deployedFile.getName() + "' of content '" + content.getContentKey() + "' deceeds current file size threashold and will be removed from external file serving cache.");
                                                                        if (!deployedFile.delete()) {
                                                                            _core.getLog().warn("Unable to delete external file serving data '" + deployedFile.getAbsolutePath() + "'. File cache might serve stale data.");
                                                                        }
                                                                    }
                                                                }
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.