private static boolean applyEdit ( Element edit , Document ilf ) { String nodeID = edit . getAttribute ( Constants . ATT_TARGET ) ; Element channel = ilf . getElementById ( nodeID ) ; if ( channel == null ) return false ; // now get the name of the parameter to be edited and find that element String parmName = edit . getAttribute ( Constants . ATT_NAME ) ; String parmValue = edit . getAttribute ( Constants . ATT_USER_VALUE ) ; NodeList ilfParms = channel . getChildNodes ( ) ; Element targetParm = null ; for ( int i = 0 ; i < ilfParms . getLength ( ) ; i ++ ) { Element ilfParm = ( Element ) ilfParms . item ( i ) ; if ( ilfParm . getAttribute ( Constants . ATT_NAME ) . equals ( parmName ) ) { targetParm = ilfParm ; break ; } } if ( targetParm == null ) // parameter not found so we are free to set { Element parameter = ilf . createElement ( "parameter" ) ; parameter . setAttribute ( "name" , parmName ) ; parameter . setAttribute ( "value" , parmValue ) ; parameter . setAttribute ( "override" , "yes" ) ; channel . appendChild ( parameter ) ; return true ; } /* TODO Add support for fragments to set dlm:editAllowed attribute for * channel parameters. (2005.11.04 mboyd) * * In the commented code below, the check for editAllowed will never be * seen on a parameter element in the * current database schema approach used by DLM. This is because * parameters are second class citizens of the layout structure. They * are not found in the up_layout_struct table but only in the * up_layout_param table. DLM functionality like dlm:editAllowed, * dlm:moveAllowed, dlm:deleteAllowed, and dlm:addChildAllowed were * implemented without schema changes by adding these as parameters to * structural elements and upon loading any parameter that begins with * 'dlm:' is placed as an attribute on the containing structural * element. So any channel parameter entry with dlm:editAllowed has that * value placed as an attribute on the containing channel not on the * parameter that was meant to have it. * * The only solution would be to add special dlm:parm children below * channels that would get the editAllowed value and then when creating * the DOM don't create those as child elements but use them to set the * attribute on the corresponding parameter by having the name of the * dlm:parm element be the name of the parameter to which it is to be * related. * * The result of this lack of functionality is that fragments can't * mark any channel parameters as dlm:editAllowed='false' thereby * further restricting which channel parameters can be edited beyond * what the channel definition specifies during publishing. */ // Attr editAllowed = targetParm.getAttributeNode( Constants.ATT_EDIT_ALLOWED ); // if ( editAllowed != null && editAllowed.getNodeValue().equals("false")) // return false; // target parm found. See if channel definition will still allow changes. Attr override = targetParm . getAttributeNode ( Constants . ATT_OVERRIDE ) ; if ( override != null && ! override . getNodeValue ( ) . equals ( Constants . CAN_OVERRIDE ) ) return false ; // now see if the change is still needed if ( targetParm . getAttribute ( Constants . ATT_VALUE ) . equals ( parmValue ) ) return false ; // user's edit same as fragment or chan def targetParm . setAttribute ( "value" , parmValue ) ; return true ; }
Attempt to apply a single channel parameter edit command and return true if it succeeds or false otherwise . If the edit is disallowed or the target element no longer exists in the document the edit command fails and returns false .