Package de.innovationgate.webgate.api

Examples of de.innovationgate.webgate.api.WGArea


            return;
        }
       
        if (getArea() != null) {
            // a new root content should be created
            WGArea area = getTMLContext().db().getArea(getArea());
            // check access
            if (area.mayEditAreaChildren() && contentTypeAllowed(area)) {
                TagResult result = new TagResult(getMessage(), area);
                result.setContentType(getContenttype());
                setResult(result.toHTML());
            } else {
                setResultOutput(false);
View Full Code Here


        }
    }

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

        WGArea area = db.getArea(contextExpression);
        if (area == null) {
            context.setLastError("No area of name '" + contextExpression + "'");
            return errorReturnContext;
        }

        WGContent content = navigator.getRootContent(area);
        if (content != null) {
            return context.getTMLContextForDocument(content);
        }
        else {
            context.setLastError("No root content in area '" + contextExpression + "'");
            return errorReturnContext;
        }

    }

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

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

        BaseTagStatus tag = context.getDesignContext().getTag().getTagStatusById(contextExpression);
        if (tag != null && tag instanceof Query.Status) {
            Query.Status queryTag = (Query.Status) tag;
            WGContent content = queryTag.getFirstContent();
            if (content != null) {
                return context.getTMLContextForDocument(queryTag.getFirstContent());
            }
            else {
                context.setLastError(
                    "Could not retrieve context by query tag \"" + contextExpression + "\". Query had no result.");
                return errorReturnContext;
            }
        }
        else {
            context.setLastError("No query tag with id: " + contextExpression);
            return errorReturnContext;
        }
    }
   
    else if (contextFunction.equals("role")) {
        setRole(contextExpression);
        return context;
    }
   
    else if (contextFunction.equals("relation")) {
        WGContent relationContent = context.content().getRelation(contextExpression);
        if (relationContent != null) {
            return context.getTMLContextForDocument(relationContent);
        }
        else {
            context.setLastError("Content " + context.meta("KEY") + " has no relation named '" + contextExpression + "'");
            return errorReturnContext;
        }
    }
    else if (contextFunction.equals("level")) {
       
        int level;
        try {
            level = Integer.parseInt(contextExpression);
        }
        catch (NumberFormatException e) {
            context.setLastError("Cannot be parsed as level number: " + contextExpression);
            return errorReturnContext;
        }
       
        WGContent con = context.content();
        if (!con.hasCompleteRelationships()) {
            context.setLastError("Current content does not belong to a page hierarchy");
            return errorReturnContext;
        }
       
        WGStructEntry struct = con.getStructEntry();
        while (struct != null && struct.getLevel() > level) {
            struct = struct.getParentEntry();
        }
       
        if (struct != null) {
            WGContent targetCon = _languageChooser.selectContentForPage(struct, isBI);
            if (targetCon != null) {
                return context.getTMLContextForDocument(targetCon);
            }
            else {
                context.setLastError("Page on level " + level + " has no appropriate content document");
                return errorReturnContext;
            }
        }
        else {
            context.setLastError("Failed to go to page level " + level);
            return errorReturnContext;
        }
       
    }
    else if (contextFunction.equals("np")) {
        String namePart = UniqueNamePartFormatter.INSTANCE.format(contextExpression);
        String uname = context.content().getUniqueName();
        if (WGUtils.isEmpty(uname)) {
            uname = context.content().getStructEntry().getUniqueName();
        }
       
        String fullname;
        if (!WGUtils.isEmpty(uname)) {
            fullname = uname + "." + namePart;
        }
        else {
            fullname = namePart;
        }
       
        WGContent content = _languageChooser.selectContentForName(context.content().getDatabase(), fullname, context.isbrowserinterface());
        if (content != null) {
            return context.getTMLContextForDocument(navigator.chooseRelevantContent(content, mainContent));
        }
   
        context.setLastError("Could not retrieve content for hdb unique name " + fullname);
        return errorReturnContext;
       
    }

    // From here special functions for BI

    else if (contextFunction.equals("$struct")) {
        WGStructEntry entry = db.getStructEntryByKey(contextExpression);
        if (entry != null) {
            return context.getTMLContextForDocument(entry);
        }
        else {
            context.setLastError("Could not retrieve struct entry with key '" + contextExpression + "'");
            return errorReturnContext;
        }
    }

    else if (contextFunction.equals("$area")) {
        WGArea area = db.getArea(contextExpression);
        if (area != null) {
            return context.getTMLContextForDocument(area);
        }
        else {
            context.setLastError("Could not retrieve area with name '" + contextExpression + "'");
View Full Code Here

                if (rootContent != null) {
                    groupStructEntries = rootContent.getStructEntry().getChildEntries();
                }
   
                if (groupStructEntries == null) {
                    WGArea area = db.getArea(_groupsRootDoc);
                    if (area != null) {
                        groupStructEntries = area.getRootEntries();
                    }
                }
   
                if (groupStructEntries == null) {
                    throw new WGException("Root doc name '" + _groupsRootDoc + "' is neither the unique name of a content nor an area name. Please check if the default language " + db.getDefaultLanguage() + " of this database matches the language of group documents.");
                }
   
                // Recurse through group docs
                Iterator structsIt = groupStructEntries.iterator();
                while (structsIt.hasNext()) {
                    recurseGroupDocuments((WGStructEntry) structsIt.next(), groupMembership, newGroupInformation);
                }
            }

            // Collect user struct entries {
            WGStructEntryList structEntries = null;
            WGContent rootContent = db.getContentByName(_userRootDoc);
            if (rootContent != null) {
                structEntries = rootContent.getStructEntry().getChildEntries();
            }

            if (structEntries == null) {
                WGArea area = db.getArea(_userRootDoc);
                if (area != null) {
                    structEntries = area.getRootEntries();
                }
            }

            if (structEntries == null) {
                throw new WGException("Root doc name '" + _userRootDoc + "' is neither the unique name of a content nor an area name. Please check if the default language " + db.getDefaultLanguage() + " of this database matches the language of user documents.");
View Full Code Here

        triggerNames = newNames;

    }

    private void parseShortcutArea(WGDatabase db, Map newNames) throws WGAPIException, UnsupportedEncodingException {
        WGArea area = db.getArea(_shortcutArea);
        if (area == null) {
            _core.getLog().warn("Title path URL shortcut area '" + _shortcutArea + "' does not (yet) exist in database " + db.getDbReference());
            return;
        }

        Iterator rootStructs = area.getRootEntries().iterator();
        while (rootStructs.hasNext()) {
            WGStructEntry root = (WGStructEntry) rootStructs.next();
            Iterator contents = root.getContentSet(false).getReleasedContent().values().iterator();
            while (contents.hasNext()) {
                WGContent content = (WGContent) contents.next();
View Full Code Here

  private WGContentList getAreasListFor(WGContent content, WGContentNavigator navigator) throws WGAPIException {
   
    java.util.ArrayList contents = new java.util.ArrayList();
   
    Iterator areas = content.getDatabase().getAreas().values().iterator();
    WGArea area;
    while (areas.hasNext()) {
      area = (WGArea) areas.next();
      content = navigator.getRootContent(area);
      if (content != null) {
        contents.add(content);
View Full Code Here

     
    }
    else {

        Iterator areas = content.getDatabase().getAreas().iterator();
      WGArea area;
      while (areas.hasNext()) {
        area = (WGArea) areas.next();
        if (area.isSystemArea()) {
            continue;
        }
       
        WGContent rootContent = navigator.getRootContent(area);
        if (rootContent == null) {
View Full Code Here

    private void cloneContent() throws WGAPIException {

        _log.info("Cloning areas, struct entries and contents...");
        Iterator areas = _from.getAreas().iterator();
        WGArea area;
        WGArea areaClone;

        // Clone everything
        while (areas.hasNext()) {
            area = (WGArea) areas.next();
            if (area.isSystemArea() && !_includeSystemAreas) {
                continue;
            }
           
            validate(area);
            _log.info("Cloning area '" + area.getName() + "'");
            try {
                areaClone = (WGArea) createDumpClone(area, null);
            }
            catch (WGAPIException e) {
                handleException("Error cloning area", e, area);
                continue;
            }
           
            if (areaClone == null) {
                handleSaveError("Unable to clone area", area);
                continue;
            }

            areaClone.dropCore();
            area.dropCore();
           
            incSourceDocCounter();
            incTargetDocCounter();
            Iterator rootEntries = area.getRootEntries().iterator();
View Full Code Here

    }

    private void deleteOldContent() throws WGAPIException {

        Iterator areas = _to.getAreas().iterator();
        WGArea area;

        if (areas.hasNext()) {

            _log.info("Deleting old areas...");
            while (areas.hasNext()) {
                area = (WGArea) areas.next();
                _log.info("Deleting old area '" + area.getName() + "'");

                Iterator roots = area.getRootEntries().iterator();
                while (roots.hasNext()) {
                    deleteOldStruct((WGStructEntry) roots.next());
                }

                if (!area.remove()) {
                    _log.error("Cannot delete area. See application log for error details");
                    throw new WGBackendException("Canceled import because of failed deletion: " + area.getDocumentKey());
                }

                incTargetDocCounter();
            }
View Full Code Here

TOP

Related Classes of de.innovationgate.webgate.api.WGArea

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.