Package org.gatein.management.api.model

Examples of org.gatein.management.api.model.ModelList


        if (siteModel.has("edit-permissions")) {
            Permission permission = getPermission(siteModel, true, "edit-permissions");
            site.setEditPermission(permission);
        }
        if (siteModel.hasDefined("attributes")) {
            ModelList list = get(siteModel, ModelList.class, "attributes");
            for (int i = 0; i < list.size(); i++) {
                ModelValue mv = list.get(i);
                String field = "attributes["+i+"]"; // Used for error reporting
                if (mv.getValueType() != ModelValue.ModelValueType.OBJECT) {
                    throw invalidType(mv, ModelValue.ModelValueType.OBJECT, field);
                }
                ModelObject attrModel = mv.asValue(ModelObject.class);
View Full Code Here


        siteModel.set("description", site.getDescription());
        siteModel.set("skin", site.getSkin());
        populate("locale", site.getLocale(), siteModel);
        populate("access-permissions", site.getAccessPermission(), siteModel);
        populate("edit-permissions", site.getEditPermission(), siteModel);
        ModelList attrList = siteModel.get("attributes", ModelList.class);
        Attributes attributes = site.getAttributes();
        for (String key : attributes.keySet()) {
            ModelObject attr = attrList.add().setEmptyObject();
            attr.set("key", key);
            attr.set("value", attributes.get(key));
        }

        // Pages
View Full Code Here

    public static void populate(String fieldName, LocalizedString string, ModelObject model) {
        if (string == null)
            return;

        ModelList list = model.get(fieldName, ModelList.class);
        if (string.isLocalized()) {
            for (Localized.Value<String> value : string.getLocalizedValues()) {
                ModelObject localizedModel = list.add().asValue(ModelObject.class);
                localizedModel.set("value", value.getValue());
                populate("lang", value.getLocale(), localizedModel);
            }
        } else {
            list.add().asValue(ModelObject.class).set("value", string.getValue());
        }
    }
View Full Code Here

        }
    }

    public static void populate(String fieldName, Permission permission, ModelObject model) {
        if (permission != null) {
            ModelList list = model.get(fieldName, ModelList.class);
            if (permission.isAccessibleToEveryone()) {
                list.add("Everyone");
            }

            for (Membership membership : permission.getMemberships()) {
                list.add(membership.toString());
            }
        }
    }
View Full Code Here

        return null;
    }

    public static Permission getPermission(ModelObject model, boolean allowNull, String...names) {
        ModelList permissionsModel = get(model, ModelList.class, names);
        if (!allowNull && !permissionsModel.isDefined()) {
            throw invalidValue(null, names);
        }
        Permission permission = null;
        for (int i=0; i<permissionsModel.size(); i++) {
            ModelValue mv = permissionsModel.get(i);
            String field = resolveField(names) + "[" + i + "]"; // Used for error reporting
            if (mv.getValueType() != ModelValue.ModelValueType.STRING) {
                throw invalidType(mv, ModelValue.ModelValueType.STRING, field);
            }
            String perm = mv.asValue(ModelString.class).getValue();
View Full Code Here

        // Populate navigation fields
        model.set("priority", navigation.getPriority());
        model.set("siteType", navigation.getSiteId().getType().getName());
        model.set("siteName", navigation.getSiteId().getName());
        ModelList nodesModel = model.get("nodes").setEmptyList();
        if (rootNode.isChildrenLoaded()) {
            for (Node child : rootNode) {
                Model childModel = nodesModel.add();
                PathAddress childAddress = address.append(child.getName());
                if (scope > 0 || scope < 0) // Continue populating nodes in response
                {
                    populateNode(child, scope - 1, childModel.setEmptyObject(), childAddress);
                } else { // Populate node reference which can be followed
View Full Code Here

        // Display name
        model.set("displayName", node.getDisplayName());
        populate("displayNames", node.getDisplayNames(), model);

        // Children nodes
        ModelList children = model.get("children", ModelList.class);
        if (node.isChildrenLoaded()) {
            for (Node child : node) {
                Model childModel = children.add();
                PathAddress childAddress = address.append(child.getName());
                if (scope > 0 || scope < 0) // Continue populating nodes in response
                {
                    populateNode(child, scope - 1, childModel.setEmptyObject(), childAddress);
                } else { // Populate node reference which can be followed
View Full Code Here

            node.setDisplayName(displayName);
        }
    }

    private static LocalizedString getDisplayNames(ModelObject nodeModel) {
        ModelList list = get(nodeModel, ModelList.class, "displayNames");
        if (!list.isDefined()) {
            throw invalidValue(null, "displayNames");
        }
        LocalizedString displayName = null;
        int i=0;
        for (ModelValue mv : list) {
View Full Code Here

TOP

Related Classes of org.gatein.management.api.model.ModelList

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.