throw notFound("Cannot remove site", id);
}
}
private ModelObject _updateSite(SiteId id, ModelObject siteModel, OperationContext context) {
Site site = requireSite(id, context);
if (siteModel.has("displayName")) {
String displayName = get(siteModel, ModelString.class, "displayName").getValue();
site.setDisplayName(displayName);
}
if (siteModel.has("description")) {
String description = get(siteModel, ModelString.class, "description").getValue();
site.setDescription(description);
}
if (siteModel.has("skin")) {
String skin = get(siteModel, ModelString.class, "skin").getValue();
site.setSkin(skin);
}
if (siteModel.has("locale")) {
Locale locale = getLocale(siteModel, "locale");
site.setLocale(locale);
}
if (siteModel.has("access-permissions")) {
Permission permission = getPermission(siteModel, false, "access-permissions");
site.setAccessPermission(permission);
}
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);
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);
}
}
portal.saveSite(site);