Revision 016427dd
Added by Marc Dequènes about 14 years ago
- ID 016427dd02ba652aba3281235e512f73f3650fb5
bin/shadowwalker | ||
---|---|---|
|
||
self.short_desc = "Modify attributes of an item"
|
||
self.usages_params = [
|
||
"<item-full-handle> [:parent=<value>] (<field>|<relation>|:aspects)(=|+=|-=)<value> [(<field>|<relation>|:aspects)(=|+=|-=)<value>] ..."
|
||
"<item-full-handle> [:parent=<value>] (<field>|<relation>|:aspects)[@](=|+=|-=)<value> [(<field>|<relation>|:aspects)(=|+=|-=)<value>] ..."
|
||
]
|
||
end
|
||
|
||
... | ... | |
|
||
self.short_desc = "Search items"
|
||
self.usages_params = [
|
||
"[:objects=<object>[,<object>]...] [:aspects=<aspect>[,<aspect>]...] [[filter:]<field>=<value>] [:parents|:siblings|:children|:ancestors|:successors=<item-full-handle>[,<item-full-handle>]] ..."
|
||
"[:objects[@]=<object>[,<object>]...] [:aspects[@]=<aspect>[,<aspect>]...] [[filter:]<field>[@]=<value>] [:parents|:siblings|:children|:ancestors|:successors[@]=<item-full-handle>[,<item-full-handle>]] ..."
|
||
]
|
||
self.usage_extra_info = "Criterias are AND-ed, but lists of values for a criteria are OR-ed."
|
||
end
|
lib/ldap_shadows/elements/object.rb | ||
---|---|---|
raise PreProcessingError, _("The field '%s' cannot be modified (read only)") % field
|
||
end
|
||
|
||
if attr_info[:binary]
|
||
unless File.exists?(val)
|
||
raise PreProcessingError, _("The field '%s' contains binary data, you must provide a filename instead of a direct value") % field
|
||
end
|
||
|
||
begin
|
||
val = File.read(val)
|
||
rescue
|
||
raise PreProcessingError, _("The file for the binary field '%s' cannot be read: ") % [field, $!]
|
||
end
|
||
elsif attr_info[:syntax] == "1.3.6.1.4.1.1466.115.121.1.12"
|
||
if attr_info[:syntax] == "1.3.6.1.4.1.1466.115.121.1.12"
|
||
if val =~ FULL_HANDLE_PATTERN
|
||
obj_hdl = $1.downcase
|
||
item_hdl = $2
|
lib/ldap_shadows/manipulation_helper.rb | ||
---|---|---|
|
||
module LdapShadows
|
||
module Manipulation
|
||
# hyphens are permitted by RFC2251, but disallowed for method named
|
||
# hyphens are permitted by RFC2251, but disallowed for method names
|
||
TEXTUI_KEY_PATTERN = "(?:[a-zA-Z]*:)?[a-zA-Z][a-zA-Z0-9]*"
|
||
|
||
def self.prepare_string_part(key, op_modifier, op, val)
|
||
case op_modifier
|
||
when '@'
|
||
unless File.exists?(val)
|
||
raise PreProcessingError, _("The file for key '%s' does not exist") % key
|
||
end
|
||
|
||
begin
|
||
val = File.read(val)
|
||
rescue
|
||
raise PreProcessingError, _("The file for key '%s' cannot be read: ") % [key, $!]
|
||
end
|
||
end
|
||
|
||
val
|
||
end
|
||
|
||
def self.item_modify_from_strings(item, str_list)
|
||
str_list = [str_list] unless str_list.is_a? Array
|
||
|
||
modification_done = false
|
||
str_list.each do |str|
|
||
unless str =~ /^(#{TEXTUI_KEY_PATTERN})(=|\+=|-=)(.*)$/
|
||
unless str =~ /^(#{TEXTUI_KEY_PATTERN})(@)?(=|\+=|-=)(.*)$/
|
||
raise SyntaxError, _("modification parameter '%s' is invalid") % str
|
||
end
|
||
key = $1
|
||
op = $2
|
||
val = $3
|
||
op_modifier = $2
|
||
op = $3
|
||
val = $4
|
||
|
||
val = prepare_string_part(key, op_modifier, op, val)
|
||
|
||
mod_done = item.modify(key, op, val)
|
||
modification_done ||= mod_done
|
||
... | ... | |
ldap_search_exclude =Set.new
|
||
ldap_search_fields_post = Set.new
|
||
str_list.each do |str|
|
||
unless str =~ /^(#{TEXTUI_KEY_PATTERN})(=|~=)(.*)$/
|
||
unless str =~ /^(#{TEXTUI_KEY_PATTERN})(@)?(=|~=)(.*)$/
|
||
raise SyntaxError, _("search parameter '%s' is invalid") % str
|
||
end
|
||
key = $1
|
||
op = $2
|
||
val = $3
|
||
op_modifier = $2
|
||
op = $3
|
||
val = $4
|
||
|
||
val = prepare_string_part(key, op_modifier, op, val)
|
||
|
||
if key.index(":")
|
||
type, field = key.split(":")
|
Also available in: Unified diff
[evol] allow specifying a file content as value in the command line for search and modify commands (closes #149)