Package org.gatein.management.api.model

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


   {
      ModelValue.ModelValueType type = value.getValueType();
      switch (type)
      {
         case OBJECT:
            ModelObject mo = value.asValue(ModelObject.class);
            for (String name : mo.getNames())
            {
               resolveLinks(mo.get(name), uriInfo);
            }
            break;
         case REFERENCE:
            ModelReference ref = value.asValue(ModelReference.class);
            PathAddress address = ref.getValue();
View Full Code Here


                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);
                if (!attrModel.hasDefined("key")) {
                    throw requiredField(field, "key");
                }
                String key = get(attrModel, ModelString.class, "key").getValue();
                if (!attrModel.has("value")) {
                    throw requiredField(field, "value");
                }
                String value = get(attrModel, ModelString.class, "value").getValue();
                site.getAttributes().put(key, value);
            }
View Full Code Here

        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
        ModelReference pagesRef = siteModel.get("pages", ModelReference.class);
        pagesRef.set(address.append("pages"));
View Full Code Here

            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

        } else {
            node = node.filter().showDefault();
        }

        // Populate the model
        ModelObject model = modelProvider.newModel(ModelObject.class);
        populateNode(node, scope, model, context.getAddress());

        return model;
    }
View Full Code Here

        // Add child and save
        Node child = parent.addChild(name);
        navigation.saveNode(parent);

        // Populate model
        ModelObject model = modelProvider.newModel(ModelObject.class);
        populateNode(child, 0, model, address);

        return model;
    }
View Full Code Here

        // Save node
        navigation.saveNode(node);

        // Populate model for update node
        ModelObject updateNodeModel = modelProvider.newModel(ModelObject.class);
        populateNode(node, 0, updateNodeModel, address);

        return updateNodeModel;
    }
View Full Code Here

        return node;
    }

    private ModelObject populateNavigationModel(Node rootNode, int scope, OperationContext context) {
        ModelObject model = modelProvider.newModel(ModelObject.class);

        PathAddress address = context.getAddress();

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

    private void populateVisibility(Visibility visibility, ModelObject model) {
        if (visibility != null) {
            set("status", visibility.getStatus(), model);
            if (visibility.getPublicationDate() != null) {
                ModelObject pubDateModel = model.get("publication-date", ModelObject.class);
                Date start = visibility.getPublicationDate().getStart();
                Date end = visibility.getPublicationDate().getEnd();
                set("start", start, pubDateModel);
                set("end", end, pubDateModel);
            }
View Full Code Here

            throw invalidValue(null, "displayNames");
        }
        LocalizedString displayName = null;
        int i=0;
        for (ModelValue mv : list) {
            ModelObject displayNameModel = mv.asValue(ModelObject.class);

            // Parse value (required && non-null)
            if (!displayNameModel.has("value")) {
                throw requiredField("displayNames["+i+"].value");
            }
            String value = get(displayNameModel, ModelString.class, "value").getValue();
            if (value == null) {
                throw invalidValue(value, "displayNames[" + i + "].value");
            }

            // Parse lang (not-required but if defined must be non-null)
            if (displayNameModel.has("lang")) {
                ModelString langModel = get(displayNameModel, ModelString.class, "lang");
                String lang = langModel.getValue();
                if (lang == null) {
                    throw invalidValue(lang, "displayNames[" + i + "].lang");
                }
View Full Code Here

TOP

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

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.