require 'fiona7/builder/obj_builder' #require 'fiona7/write_obj' module Fiona7 module Builder class ObjUpdater < ObjBuilder protected def update? true end def validate return true end def prepare_object obj_id = @values.delete(:_id) @obj = WriteObj.find(obj_id) @path = @values.delete(:_path) @widget_pool = @values.delete(:_widget_pool) @permalink = @values.key?(:_permalink) ? (@values.delete(:_permalink) || "") : nil # revert command sends this info. we cannot do anything useful with it. @values.delete(:_last_changed) @name, parent_path = name_and_parent_path_from_path(@path) if (@path) old_name, old_parent_path = name_and_parent_path_from_path(@obj.path) if obj_class = @values.delete(:_obj_class) @obj_class = obj_class @real_obj_class = Fiona7::ObjClassNameMangler.new(@obj_class).mangle else @real_obj_class = @obj.obj_class @obj_class = Fiona7::ObjClassNameDemangler.new(@real_obj_class).demangle end ensure_obj_class_exists # NOTE: name is an object attribute and not content attribute # changing content attributes requires permissionWrite # but changing the name attribute requires permissionRoot # # setting the name without changing the value counts # as changing the name attribute for the CM @obj.name = @name if !@name.blank? && @name != @obj.name # this is a obj move operation if parent_path && old_parent_path != parent_path # we first have to make sure that the new parent exists # FIXME: moving the object and changing the obj class # will not move the object @obj.parent = ContainerChainBuilder.new(parent_path).call end end end end end