Best Howitzer_ruby code snippet using Copyable.copy_files
request_broker.rb
Source:request_broker.rb
...2029 # rethash[:success] = false2030 # rethash[:status] = ERROR_FAILED_TO_COPY_FILE2031 # end2032 # end2033 when 'copy_files'2034 # delete file from list and put it in the recycler2035 # session_id, cont_location, hash_key, file_writable_status:bool, lock:int, file_name2036 copy_sid = my_session_id2037 # copy_target_folder_name = paramshash[:target_folder]2038 # copy_target_folder_hashkey = paramshash[:target_hash]2039 # get numbered hashes2040 list_files = Array.new2041 # files_to_move = Array.new2042 hash_params = Hash.new2043 paramshash.each {|key, value|2044 if /[0-9]+/ =~ key # => number2045 list_files.append value2046 else # => string2047 hash_params[key] = value2048 end2049 }2050 # get file attributes2051 target_cont_location = 'folder_b'2052 source_cont_location = 'folder_a'2053 copy_file_hash_keys = Array.new2054 list_files.each {|f|2055 f_rec = FileDatum.find_by_hash_key f[:hash_key]2056 if f_rec.blank?2057 rethash[:success] = false2058 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST2059 rethash[:errors] = 'No file record is found'2060 return rethash2061 end2062 source_cont_location = f[:cont_location]2063 copy_file_hash_keys.append(f_rec[:spin_node_hashkey])2064 }2065 if source_cont_location == 'folder_a'2066 target_cont_location = 'folder_b'2067 else2068 target_cont_location = 'folder_a'2069 end2070 target_folder_rec = FolderDatum.find_by_session_id_and_cont_location_and_selected copy_sid, target_cont_location, true2071 copy_target_folder_hashkey = target_folder_rec[:spin_node_hashkey]2072 if target_folder_rec.blank?2073 rethash[:success] = false2074 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST2075 rethash[:errors] = 'No folder record is found at copy_files'2076 return rethash2077 end2078 r = Random.new2079 opr_id = Security.hash_key_s(copy_sid + target_folder_rec[:spin_node_hashkey] + target_cont_location + r.rand.to_s)2080 rethash = ClipBoards.put_nodes(opr_id, copy_sid, copy_file_hash_keys, OPERATION_COPY)2081 unless rethash[:success]2082 return rethash2083 end2084 put_node_count = rethash[:rsult]2085 copy_source_folder_hashkey = SpinLocationManager.get_parent_key(copy_file_hash_keys[0])2086 # acl check!2087 # Does it have ACL to do move operation?2088 # source_acls = SpinAccessControl.has_acl_values copy_sid, copy_source_folder_hashkey, NODE_DIRECTORY2089 target_acls = SpinAccessControl.has_acl_values copy_sid, copy_target_folder_hashkey, NODE_DIRECTORY2090 has_right_to_delete = false2091 target_has_right_to_delete = false2092 # source_acls.values.each {|av|2093 # if av & ACL_NODE_WRITE or av & ACL_NODE_DELETE # => has right to delete2094 # has_right_to_delete = true2095 # break # => break from 'each' iterator2096 # end2097 # }2098 target_acls.values.each {|tav|2099 if tav & ACL_NODE_WRITE or tav & ACL_NODE_DELETE # => has right to delete2100 target_has_right_to_delete = true2101 break # => break from 'each' iterator2102 end2103 }2104 if target_has_right_to_delete == false2105 rethash[:success] = false2106 rethash[:status] = ERROR_COPY_FILE2107 else2108 retb = DatabaseUtility::VirtualFileSystemUtility.copy_virtual_files_in_clipboard opr_id, copy_sid, copy_source_folder_hashkey, copy_target_folder_hashkey, target_cont_location2109 if retb2110 FolderDatum.has_updated(copy_sid, copy_source_folder_hashkey, NO_UPDATE_TYPE, true)2111 FolderDatum.has_updated(copy_sid, copy_target_folder_hashkey, NEW_CHILD, true)2112 # SessionManager.set_location_dirty(copy_sid, (source_cont_location == vfolder_a' ? 'file_listA' : 'file_listB'), true)2113 # SessionManager.set_location_dirty(copy_sid, (target_cont_location == 'folder_a' ? 'file_listA' : 'file_listB'), true)2114 rethash[:success] = true2115 rethash[:status] = INFO_COPY_FILE_SUCCESS2116 else2117 rethash[:success] = false2118 rethash[:status] = ERROR_COPY_FILE2119 end2120 end2121 when 'throw_files' #=> empty trash cann2122 # remove file from storage2123 rethash = {}2124 n = paramshash.length # => I need it!2125 throw_files = n - 5 # => I hate this kind of logic but client send me fucking json data!2126 remove_sid = my_session_id2127 parent_key = ''2128 # remove_cont_location = paramshash[:cont_location]2129 # extract keys and file names2130 remove_file_keys = Array.new2131 1.upto(throw_files) {|i|2132 # rmkey = paramshash["#{i-1}"][:hash_key]2133 rmf = RecyclerDatum.find_by_hash_key paramshash["#{i-1}"][:hash_key]2134 unless rmf.present?2135 next2136 end2137 rmkey = rmf[:spin_node_hashkey]2138 if rmkey == nil2139 rmkey = paramshash["#{i-1}"][:hash_key]2140 end2141 remove_file_keys.push(rmkey)2142 # remove_file_names << paramshash["#{i-1}"][:file_name]2143 # if i == 12144 # parent_key = SpinLocationManager.get_parent_key(rmkey)2145 # end2146 }2147 retc = DatabaseUtility::VirtualFileSystemUtility.throw_virtual_files remove_sid, remove_file_keys2148 # if retb.length == throw_files # => success, 'throw_files' files are remoevd2149 if retc >= throw_files # => success, 'throw_files' files are remoevd2150 # remove_source_folder_hashkey = SpinLocationManager.get_parent_key(remove_file_keys[0])2151 # FolderDatum.has_updated(remove_sid, remove_source_folder_hashkey, true)2152 # FolderDatum.has_updated(move_sid, move_target_folder_hashkey, true)2153 # SessionManager.set_location_dirty(remove_sid, (remove_cont_location == 'folder_a' ? 'file_listA' : 'file_listB'), true)2154 # my_cont_location = SessionManager.get_current_location(remove_sid)2155 # domain_key = SessionManager.get_selected_domain(remove_sid, my_cont_location)2156 # unless parent_key.blank?2157 # FolderDatum.select_folder(remove_sid, parent_key, my_cont_location, domain_key)2158 # end2159 rethash[:success] = true2160 rethash[:status] = INFO_THROW_FILES_SUCCESS2161 else2162 rethash[:success] = false2163 rethash[:status] = ERROR_THROW_FILES2164 end2165 when 'throw_all_files' #=> empty trash cann2166 # remove file from storage2167 rethash = {}2168 remove_sid = my_session_id2169 uid = SessionManager.get_uid remove_sid2170 parent_key = ''2171 # remove_cont_location = paramshash[:cont_location]2172 # extract keys and file names2173 remove_file_keys = Array.new2174 throw_files=02175 rmf = RecyclerDatum.where(["spin_uid = ?", uid])2176 rmf.each {|r|2177 rmkey = r[:spin_node_hashkey]2178 if rmkey == nil2179 rmkey = r[:hash_key]2180 end2181 remove_file_keys.push(rmkey)2182 throw_files+=12183 }2184 retc = DatabaseUtility::VirtualFileSystemUtility.throw_virtual_files remove_sid, remove_file_keys2185 # if retb.length == throw_files # => success, 'throw_files' files are remoevd2186 if retc >= throw_files # => success, 'throw_files' files are remoevd2187 rethash[:success] = true2188 rethash[:status] = INFO_THROW_FILES_SUCCESS2189 else2190 rethash[:success] = false2191 rethash[:status] = ERROR_THROW_FILES2192 end2193 when 'escape_files' #=> retreive from trash cann2194 # remove file from storage2195 n = paramshash.length # => I need it!2196 retrieve_files = n - 5 # => I hate this kind of logic but client send me fucking json data!2197 retrieve_sid = my_session_id2198 # extract keys and file names2199 retrieve_file_keys = []2200 1.upto(retrieve_files) {|i|2201 # retrieve_file_keys << paramshash["#{i-1}"][:hash_key]2202 # remove_file_names << paramshash["#{i-1}"][:file_name]2203 # rmkey = paramshash["#{i-1}"][:hash_key]2204 rmf = RecyclerDatum.find_by_hash_key paramshash["#{i-1}"][:hash_key]2205 if rmf.blank?2206 rethash[:success] = false2207 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST2208 rethash[:errors] = 'No file record is found'2209 return rethash2210 end2211 rmkey = rmf[:spin_node_hashkey]2212 retrieve_file_keys.push(rmkey)2213 }2214 retb = DatabaseUtility::VirtualFileSystemUtility.retrieve_virtual_files retrieve_sid, retrieve_file_keys2215 if retb.length >= retrieve_files # => success, 'retrieve_files' files are remoevd2216 my_cont_location = SessionManager.get_current_location(my_session_id)2217 domain_key = SessionManager.get_selected_domain(my_session_id, my_cont_location)2218 FolderDatum.reset_partial_root(my_session_id, my_cont_location, domain_key)2219 FolderDatum.fill_folders(my_session_id, my_cont_location, domain_key, nil, PROCESS_FOR_UNIVERSAL_REQUEST, false, 1)2220 rethash[:success] = true2221 rethash[:status] = INFO_RETREIVE_FILES_SUCCESS2222 else2223 rethash[:success] = false2224 rethash[:status] = ERROR_RETREIVE_FILES2225 rethash[:errors] = 'å
ã«æ»ããªããã¡ã¤ã«ãããã¾ã'2226 end2227 when 'change_file_property'2228 # set folder privilege2229 user_agent = $http_user_agent2230 file_hashkey = ''2231 #if /HTTP_Request2.+/ =~ user_agent # => PHP API 2015/10/222232 if user_agent == "BoomboxAPI"2233 file_hashkey = paramshash[:hash_key]2234 else # => from UI2235 file_rec = FileDatum.find_by_hash_key paramshash[:hash_key]2236 if file_rec.blank?2237 rethash[:success] = false2238 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST2239 rethash[:errors] = 'No file record is found'2240 return rethash2241 end2242 file_hashkey = file_rec[:spin_node_hashkey]2243 end2244 properties = Hash.new2245 if paramshash[:file_name].present?2246 properties[:file_name] = paramshash[:file_name]2247 end2248 if paramshash[:description].present?2249 properties[:description] = paramshash[:description]2250 end2251 if paramshash[:keyword].present?2252 properties[:keyword] = paramshash[:keyword]2253 end2254 if paramshash[:title].present?2255 properties[:title] = paramshash[:title]2256 end2257 if paramshash[:subtitle].present?2258 properties[:subtitle] = paramshash[:subtitle]2259 end2260 # get numbered hashes2261 # list_files = Array.new2262 # hash_params = Hash.new2263 # paramshash.each { |key,value|2264 # if /[0-9]+/ =~ key # => number2265 # list_files.append value2266 # else # => string2267 # hash_params[key] = value2268 # end2269 # }2270 retb = DatabaseUtility::VirtualFileSystemUtility.change_virtual_file_properties my_session_id, file_hashkey, properties2271 if retb == false2272 rethash[:success] = false2273 rethash[:errors] = "Failed to change file name"2274 else2275 rethash[:status] = "File name has changed"2276 end2277 when 'change_file_extension'2278 # set folder privilege2279 user_agent = $http_user_agent2280 file_hashkey = ''2281 if /HTTP_Request2.+/ =~ user_agent # => PHP API2282 file_hashkey = paramshash[:hash_key]2283 else # => from UI2284 file_rec = FileDatum.find_by_hash_key paramshash[:hash_key]2285 if file_rec.blank?2286 rethash[:success] = false2287 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST2288 rethash[:errors] = 'No file record is found'2289 return rethash2290 end2291 file_hashkey = file_rec[:spin_node_hashkey]2292 end2293 properties = Hash.new2294 # properties[:file_name] = paramshash[:file_name]2295 # properties[:description] = paramshash[:description]2296 # properties[:keyword] = paramshash[:keyword]2297 # properties[:title] = paramshash[:title]2298 # properties[:subtitle] = paramshash[:subtitle]2299 # get numbered hashes2300 list_files = Array.new2301 hash_params = Hash.new2302 paramshash.each {|key, value|2303 if /[0-9]+/ =~ key # => number2304 list_files.append value2305 else # => string2306 properties[key] = value2307 end2308 }2309 retb = DatabaseUtility::VirtualFileSystemUtility.change_virtual_file_extension my_session_id, file_hashkey, properties2310 if retb == false2311 rethash[:success] = false2312 rethash[:status] = "Failed to change file name"2313 else2314 rethash[:status] = "File name has changed"2315 end2316 when 'change_file_details'2317 # set folder privilege2318 user_agent = $http_user_agent2319 file_hashkey = ''2320 if /HTTP_Request2.+/ =~ user_agent # => PHP API2321 file_hashkey = paramshash[:hash_key]2322 else # => from UI2323 file_rec = FileDatum.find_by_hash_key paramshash[:hash_key]2324 if file_rec.blank?2325 rethash[:success] = false2326 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST2327 rethash[:errors] = 'No file record is found'2328 return rethash2329 end2330 file_hashkey = file_rec[:spin_node_hashkey]2331 end2332 properties = Hash.new2333 properties[:details] = paramshash[:details]2334 retb = DatabaseUtility::VirtualFileSystemUtility.change_virtual_file_details my_session_id, file_hashkey, properties2335 if retb == false2336 rethash[:success] = false2337 rethash[:status] = "Failed to change file name"2338 else2339 rethash[:status] = "File name has changed"2340 properties = Hash.new2341 properties[:file_name] = paramshash[:file_name]2342 properties[:description] = paramshash[:description]2343 properties[:keyword] = paramshash[:keyword]2344 properties[:title] = paramshash[:title]2345 properties[:subtitle] = paramshash[:subtitle]2346 retp = DatabaseUtility::VirtualFileSystemUtility.change_virtual_file_properties my_session_id, file_hashkey, properties2347 if retp == false2348 rethash[:success] = false2349 rethash[:status] = "Failed to change file name"2350 end2351 end2352 when 'change_folder_name'2353 folder_key = ''2354 target_key = ''2355 folder_name = ''2356 folder_rec = {}2357 user_agent = $http_user_agent2358 in_list = false2359 if /HTTP_Request2.+/ =~ user_agent # => PHP API2360 folder_key = paramshash[:hash_key]2361 else # => from UI2362 folder_rec = FolderDatum.find_by_hash_key paramshash[:hash_key]2363 if folder_rec.blank?2364 folder_rec = FileDatum.find_by_hash_key paramshash[:hash_key]2365 if folder_rec.blank?2366 rethash[:success] = false2367 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST2368 rethash[:errors] = 'No folder record is found at change_folder_name'2369 return rethash2370 end2371 folder_name = folder_rec[:file_name]2372 in_list = true2373 else2374 folder_name = folder_rec[:text]2375 end2376 folder_key = folder_rec[:spin_node_hashkey]2377 end2378 rethash[:success] = true2379 retb = DatabaseUtility::VirtualFileSystemUtility.change_virtual_file_name my_session_id, paramshash[:cont_location], folder_key, paramshash[:text]2380 if retb == false2381 rethash[:success] = false2382 rethash[:status] = "Failed to change folder name"2383 else2384 # folder_hashkey = folder_key2385 if in_list2386 target_key = SpinLocationManager.get_parent_key(folder_key, NODE_DIRECTORY)2387 else2388 target_key = folder_key2389 end2390 domain_key = SessionManager.get_selected_domain(my_session_id, paramshash[:cont_location])2391 # DomainDatum.set_domain_dirty(my_session_id, paramshash[:cont_location])2392 # FolderDatum.remove_folder_rec(my_session_id, paramshash[:cont_location], folder_key)2393 # FolderDatum.load_folder_recs(my_session_id, parent_key, domain_key, paramshash[:cont_location])2394 FolderDatum.reset_partial_root(my_session_id, paramshash[:cont_location], domain_key)2395 FolderDatum.fill_folders(my_session_id, paramshash[:cont_location])2396 FolderDatum.select_folder my_session_id, target_key, paramshash[:cont_location]2397 # FolderDatum.reset_partial_root(my_session_id,paramshash[:cont_location], domain_key)2398 # FolderDatum.set_partial_root(my_session_id,paramshash[:cont_location], parent_key, domain_key)2399 copy_locations = CONT_LOCATIONS_LIST - [paramshash[:cont_location]]2400 copy_locations.each {|copy_location|2401 FolderDatum.copy_folder_data_from_location_to_location(my_session_id, paramshash[:cont_location], copy_location)2402 }2403 rethash[:status] = "File name has changed"2404 end2405 when 'change_domain_name'2406 domain_key = ''2407 user_agent = $http_user_agent2408 if /HTTP_Request2.+/ =~ user_agent # => PHP API2409 domain_key = paramshash[:hash_key]2410 else # => from UI2411 domain_data_rec = DomainDatum.find_by_hash_key paramshash[:hash_key]2412 if domain_data_rec.blank?2413 rethash[:success] = false2414 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST2415 rethash[:errors] = 'No domain_data_rec record is found'2416 return rethash2417 end2418 domain_key = domain_data_rec[:spin_domain_hash_key]2419 end2420 rethash[:success] = true2421 rethash[:success] = true2422 new_domain_name = paramshash[:domain_name]2423 retb = DatabaseUtility::VirtualFileSystemUtility.change_virtual_domain_name my_session_id, domain_key, new_domain_name2424 if retb == false2425 rethash[:success] = false2426 rethash[:status] = ERROR_FAILED_TO_CHANGE_DOMAIN_NAME2427 rethash[:errors] = "Failed to change domain name"2428 else2429 DomainDatum.has_updated(my_session_id, domain_key)2430 rethash[:success] = true2431 rethash[:status] = INFO_CHANGE_DOMAIN_NAME_SUCCESS2432 rethash[:result] = "Domain name has changed to " + new_domain_name2433 end2434 when 'change_file_name'2435 rethash[:success] = true2436 file_attributes = Hash.new2437 file_attributes[:file_name] = paramshash[:file_name]2438 file_attributes[:cont_location] = paramshash[:cont_location]2439 file_attributes[:title] = paramshash[:title]2440 file_attributes[:subtitle] = paramshash[:subtitle]2441 file_attributes[:keyword] = paramshash[:keyword]2442 file_attributes[:description] = paramshash[:description]2443 file_attributes[:file_type] = paramshash[:file_type]2444 file_attributes[:file_version] = paramshash[:file_version]2445 file_attributes[:created_date] = paramshash[:created_date]2446 file_attributes[:creator] = paramshash[:creator]2447 file_attributes[:modified_date] = paramshash[:modified_date]2448 file_attributes[:modifier] = paramshash[:modifier]2449 file_attributes[:owner] = paramshash[:owner]2450 file_attributes[:ownership] = paramshash[:ownership]2451 file_attributes[:file_readable_status] = paramshash[:file_readable_status]2452 file_attributes[:file_writable_status] = paramshash[:file_writable_status]2453 file_attributes[:url] = paramshash[:url]2454 retb = DatabaseUtility::VirtualFileSystemUtility.change_virtual_file_properties my_session_id, paramshash[:hash_key], file_attributes2455 if retb == false2456 rethash[:success] = false2457 rethash[:status] = "Failed to change file name"2458 else2459 rethash[:status] = "File name has changed"2460 end2461 when 'unlock_file'2462 frec = FileDatum.find_by_hash_key_and_session_id paramshash[:hash_key], my_session_id2463 if frec.blank?2464 rethash[:success] = false2465 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST2466 rethash[:errors] = 'No file record is found'2467 return rethash2468 end2469 lock_ret = SpinNode.clear_lock frec[:spin_node_hashkey]2470 if !lock_ret2471 rethash[:success] = false2472 rethash[:status] = ERROR_FAILED_TO_UNLOCK_FILE2473 rethash[:errors] = "Failed to set lock of " + paramshash[:hash_key]2474 else2475 rethash[:status] = INFO_UNLOCK_FILE_SUCCESS2476 rethash[:success] = true2477 end2478 when 'lock_file'2479 lock_file_hash_key = paramshash[:hash_key]2480 frec = FileDatum.find_by_session_id_and_hash_key_and_cont_location my_session_id, lock_file_hash_key, 'folder_a'2481 if frec.blank?2482 rethash[:success] = false2483 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST2484 rethash[:errors] = 'No file record is found'2485 return rethash2486 end2487 lock_node_hash_key = frec[:spin_node_hashkey]2488 spin_node_upd = Hash.new2489 spin_node_upd[:upd_lock_status] = FSTAT_LOCKED2490 spin_node_upd[:upd_lock_mode] = FSTAT_WRITE_LOCKED2491 lock_ret = SpinNode.set_lock2 my_session_id, lock_node_hash_key, spin_node_upd2492 if !lock_ret2493 rethash[:success] = false2494 rethash[:status] = ERROR_FAILED_TO_LOCK_FILE2495 rethash[:errors] = "Failed to set lock of " + lock_node_hash_key2496 else2497 rethash[:status] = INFO_LOCK_FILE_SUCCESS2498 rethash[:success] = true2499 end2500 when 'delete_file'2501 # delete file from list and put it in the recycler2502 # session_id, cont_location, hash_key, file_writable_status:bool, lock:int, file_name2503 # delete_file_name = paramshash[:fileg_name]2504 # paramshash.keys.each {|k| printf "%s = %s\n",k,paramshash[k]}2505 delete_sid = my_session_id2506 # delete_contlocation = paramshash[:cont_location]2507 delete_file_key = paramshash[:hash_key]2508 user_agent = $http_user_agent2509 if /HTTP_Request2.+/ =~ user_agent # => PHP API2510 delete_file_key = paramshash[:hash_key]2511 else # => from UI2512 file_data_rec = FileDatum.find_by_hash_key paramshash[:hash_key]2513 if file_data_rec.blank?2514 rethash[:success] = false2515 rethash[:status] = ERROR_FILE_IS_NOT_IN_LIST_DATA2516 rethash[:errors] = "æå®ããããã¡ã¤ã«ãè¦ã¤ããã¾ãã"2517 return rethash2518 else2519 delete_file_key = file_data_rec[:spin_node_hashkey]2520 end2521 end2522 if paramshash[:file_writable_status] == false or paramshash[:file_writable_status] == "false" or SpinAccessControl.is_deletable(my_session_id, delete_file_key) != true # not writable or login dir# => not writable2523 # this should not be deleted2524 rethash[:success] = false2525 rethash[:status] = ERROR_NOT_WRITABLE2526 rethash[:errors] = "æå®ããããã¡ã¤ã«ã¯ç§»åã§ãã¾ãã"2527 return rethash2528 end2529 parent_key = SpinLocationManager.get_parent_key(delete_file_key)2530 # # => get versions2531 # delete_file_loc = SpinLocationManager.key_to_location(delete_file_key, ANY_TYPE)2532 # delete_files = SpinNode.where :node_x_coord => delete_file_loc[X],:node_y_coord => delete_file_loc[Y]2533 # # delete_file_keys = []2534 # delete_files.each {|delf|2535 Rails.logger.warn(">> delete_file : call delete_virtual_file")2536 rethash = DatabaseUtility::VirtualFileSystemUtility.delete_virtual_file delete_sid, delete_file_key, true, true # => the last argument is trash_it flag2537 # delete_file_keys.push delf[:spin_node_hashkey]2538 # }2539 if rethash[:success]2540 # folder_key = SpinLocationManager.get_parent_key(delete_file_key)2541 domain_key = SessionManager.get_selected_domain(my_session_id, paramshash[:cont_location])2542 FolderDatum.select_folder(my_session_id, parent_key, paramshash[:cont_location], domain_key)2543 FolderDatum.has_updated(delete_sid, parent_key, DISMISS_CHILD, true)2544 if (DELETE_NOTIFICATION & SpinNotifyControl.has_notification(delete_sid, parent_key, NODE_DIRECTORY)) != 02545 trashed_vps = SpinLocationManager.get_key_vpath(delete_sid, parent_key, NODE_DIRECTORY)2546 SpinNotifyControl.notify_delete(delete_sid, trashed_vps)2547 end2548 # SessionManager.set_location_dirty(delete_sid, delete_contlocation, true)11112549 # rethash[:success] = true2550 rethash[:status] = INFO_TRASH_FILE_SUCCESS2551 else2552 # rethash[:success] = false2553 # rethash[:status] = ERROR_TRASH_FILE2554 end2555 when 'notify_delete'2556 delete_sid = my_session_id2557 notify_node_vpath = paramshash[:virtual_path]2558 SpinNotifyControl.notify_delete(delete_sid, notify_node_vpath)2559 rethash[:success] = true2560 rethash[:status] = INFO_BASE2561 when 'notify_new'2562 domain_key = SessionManager.get_selected_domain(my_session_id, 'folder_a')2563 frec = FileDatum.find_by_hash_key_and_session_id paramshash[:hash_key], my_session_id2564 if frec.blank?2565 rethash[:success] = false2566 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST2567 rethash[:errors] = 'No file record is found'2568 return rethash2569 end2570 ssid = my_session_id2571 notify_node = frec[:spin_node_hashkey]2572 notify_url = frec[:url]2573 # if new_file_list_datum[:file_version] > 12574 SpinNotifyControl.notify_modification(ssid, current_folder_key, notify_node, notufy_url, domain_hash_key)2575 rethash[:success] = true2576 rethash[:status] = INFO_BASE2577 when 'notify_modification'2578 domain_key = SessionManager.get_selected_domain(my_session_id, 'folder_a')2579 frec = FileDatum.find_by_hash_key_and_session_id paramshash[:hash_key], my_session_id2580 if frec.blank?2581 rethash[:success] = false2582 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST2583 rethash[:errors] = 'No file record is found'2584 return rethash2585 end2586 ssid = my_session_id2587 notify_node = frec[:spin_node_hashkey]2588 notify_url = frec[:url]2589 SpinNotifyControl.notify_modification(ssid, current_folder_key, fn[:spin_node_hashkey], new_file_list_datum[:url], domain_hash_key)2590 rethash[:success] = true2591 rethash[:status] = INFO_BASE2592 when 'delete_folder'2593 # delete file from list and put it in the recycler2594 # session_id, cont_location, hash_key, file_writable_status:bool, lock:int, file_name2595 # delete_file_name = paramshash[:file_name]2596 # paramshash.keys.each {|k| printf "%s = %s\n",k,paramshash[k]}2597 delete_sid = my_session_id2598 # delete_contlocation = paramshash[:cont_location]2599 delete_file_key = paramshash[:hash_key]2600 folder_data_rec = {}2601 rethash[:deleted_node_type] = NODE_DIRECTORY2602 user_agent = $http_user_agent2603 if /HTTP_Request2.+/ =~ user_agent # => PHP API2604 delete_file_key = paramshash[:hash_key]2605 else # => from UI2606 target_folder_key = nil2607 current_folder_key = SpinSession.select(:spin_current_directory).find_by_spin_session_id(my_session_id)2608 if current_folder_key.blank?2609 rethash[:success] = false2610 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST2611 rethash[:errors] = 'No current_folder_key record is found'2612 return rethash2613 end2614 if paramshash[:original_place] == 'folder_tree'2615 folder_data_rec = FolderDatum.find_by_hash_key paramshash[:hash_key]2616 if folder_data_rec.blank?2617 rethash[:success] = false2618 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST2619 rethash[:errors] = 'No folder_data_rec record is found'2620 return rethash2621 end2622 if folder_data_rec == nil2623 folder_data_rec = FileDatum.find_by_hash_key paramshash[:hash_key]2624 if folder_data_rec.blank?2625 rethash[:success] = false2626 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST2627 rethash[:errors] = 'No folder_data_rec record is found'2628 return rethash2629 end2630 end2631 rethash[:deleted_node_type] = NODE_DIRECTORY2632 # target_folder_key = FolderDatum.get_parent_folder my_session_id current_folder_key2633 else # => from file list2634 folder_data_rec = FileDatum.find_by_hash_key paramshash[:hash_key]2635 if folder_data_rec.blank?2636 rethash[:success] = false2637 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST2638 rethash[:errors] = 'No folder_data_rec record is found'2639 return rethash2640 end2641 rethash[:deleted_node_type] = (folder_data_rec[:file_type] == 'folder' ? NODE_DIRECTORY : NODE_FILE)2642 # target_folder_key = current_folder_key2643 end2644 target_folder_key = FolderDatum.get_parent_folder my_session_id, current_folder_key2645 if folder_data_rec == nil2646 rethash[:success] = false2647 rethash[:status] = ERROR_INVALID_HASH_KEY2648 # rethash[:errors] = "Failed to delete file : hash key is invalid"2649 rethash[:errors] = "æå®ããããã©ã«ããè¦ã¤ããã¾ãã"2650 return rethash2651 end2652 delete_file_key = folder_data_rec[:spin_node_hashkey]2653 end2654 if paramshash[:folder_writable_status] == false or paramshash[:folder_writable_status] == "false" or SpinAccessControl.is_deletable(my_session_id, delete_file_key) != true # not writable or login dir2655 # this should not be deleted2656 rethash[:success] = false2657 rethash[:status] = ERROR_NOT_WRITABLE2658 rethash[:errors] = "ãã®ãã©ã«ãã¯åé¤ã§ãã¾ãã"2659 return rethash2660 end2661 folder_key = SpinLocationManager.get_parent_key(delete_file_key)2662 Rails.logger.warn(">> delete_folder : call delete_virtual_file")2663 rethash = DatabaseUtility::VirtualFileSystemUtility.delete_virtual_file delete_sid, delete_file_key, true, true # => the last 2 arguments are trash_it flag and is_thrown2664 if rethash[:success]2665 rethash[:status] = (INFO_TRASH_FILE_SUCCESS | INFO_RENDERING_DONE)2666 domain_key = SessionManager.get_selected_domain(my_session_id, paramshash[:cont_location])2667 FolderDatum.reset_partial_root(my_session_id, paramshash[:cont_location], domain_key)2668 FolderDatum.fill_folders(my_session_id, paramshash[:cont_location], domain_key)2669 FolderDatum.has_updated(my_session_id, target_folder_key, DISMISS_CHILD, true)2670 FolderDatum.set_partial_root(my_session_id, paramshash[:cont_location], target_folder_key)2671 FolderDatum.select_folder(my_session_id, folder_key, paramshash[:cont_location], domain_key)2672 if (DELETE_NOTIFICATION & SpinNotifyControl.has_notification(delete_sid, folder_key, NODE_DIRECTORY)) != 02673 trashed_vps = SpinLocationManager.get_key_vpath(delete_sid, folder_key, NODE_DIRECTORY)2674 SpinNotifyControl.notify_delete(delete_sid, trashed_vps, folder_key)2675 end2676 else2677 rethash[:status] = INFO_RENDERING_DONE2678 end2679 when 'secret_files_delete_node', 'delete_node'2680 # delete file from list and put it in the recycler2681 # session_id, cont_location, hash_key, file_writable_status:bool, lock:int, file_name2682 # delete_file_name = paramshash[:file_name]2683 # paramshash.keys.each {|k| printf "%s = %s\n",k,paramshash[k]}2684 delete_sid = my_session_id2685 # delete_contlocation = paramshash[:cont_location]2686 delete_file_key = paramshash[:hash_key]2687 folder_data_rec = {}2688 user_agent = $http_user_agent2689 #if /HTTP_Request2.+/ =~ user_agent # => PHP API2690 if user_agent == "BoomboxAPI"2691 delete_file_key = paramshash[:hash_key]2692 else # => from UI2693 #if paramshash[:original_place] == 'folder_tree'2694 # folder_data_rec = FolderDatum.find_by_hash_key paramshash[:hash_key]2695 # if folder_data_rec == nil2696 # folder_data_rec = FileDatum.find_by_hash_key paramshash[:hash_key]2697 # end2698 #else2699 # folder_data_rec = FileDatum.find_by_hash_key paramshash[:hash_key]2700 #end2701 #if folder_data_rec == nil2702 # rethash[:success] = false2703 # rethash[:status] = ERROR_INVALID_HASH_KEY2704 # # rethash[:errors] = "Failed to delete file : hash key is invalid"2705 # rethash[:errors] = "æå®ããããã©ã«ããè¦ã¤ããã¾ãã"2706 # return rethash2707 #end2708 #delete_file_key = folder_data_rec[:spin_node_hashkey]2709 end2710 if paramshash[:folder_writable_status] == false or paramshash[:folder_writable_status] == "false" or SpinAccessControl.is_deletable(my_session_id, delete_file_key) != true # not writable or login dir2711 # this should not be deleted2712 rethash[:success] = false2713 rethash[:status] = ERROR_NOT_WRITABLE2714 rethash[:errors] = "ãã®ãã¼ãã¯æ¨©éããªãããåé¤ã§ãã¾ãã"2715 return rethash2716 end2717 is_domains = SpinDomain.secret_files_is_domain(my_session_id, delete_file_key)2718 count = is_domains[:domains].count2719 if (count > 0)2720 rethash[:success] = false2721 rethash[:status] = ERROR_NOT_WRITABLE2722 rethash[:errors] = "ãã®ãã¼ãã¯ãã¡ã¤ã³ãããããåé¤ã§ãã¾ãã"2723 return rethash2724 end2725 folder_key = SpinLocationManager.get_parent_key(delete_file_key)2726 Rails.logger.warn(">> delete_folder : call delette_virtual_file")2727 rethash = DatabaseUtility::VirtualFileSystemUtility.delete_virtual_file delete_sid, delete_file_key, false, false # => the last 2 arguments are trash_it flag and is_thrown2728 if rethash[:success]2729 rethash[:status] = (INFO_TRASH_FILE_SUCCESS | INFO_RENDERING_DONE)2730 domain_key = SessionManager.get_selected_domain(my_session_id, paramshash[:cont_location])2731 #以ä¸ã®ï¼è¡ã¯BOOMBOXAPIã§ã¯ä¸è¦ 2015/11/62732 #FolderDatum.reset_partial_root(my_session_id, paramshash[:cont_location], domain_key)2733 #FolderDatum.fill_folders(my_session_id, paramshash[:cont_location], domain_key)2734 #FolderDatum.select_folder(my_session_id, folder_key, paramshash[:cont_location], domain_key)2735 if (DELETE_NOTIFICATION & SpinNotifyControl.has_notification(delete_sid, folder_key, NODE_DIRECTORY)) != 02736 trashed_vps = SpinLocationManager.get_key_vpath(delete_sid, folder_key, NODE_DIRECTORY)2737 SpinNotifyControl.notify_delete(delete_sid, trashed_vps, folder_key)2738 end2739 else2740 rethash[:status] = INFO_RENDERING_DONE2741 end2742 when 'secret_files_add_domain_list'2743 ret = SpinDomain.secret_files_add_domain(my_session_id, paramshash[:hash_key])2744 if ret[:success] == true2745 rethash[:success] = true2746 rethash[:status] = INFO_BOOMBOX_API_ADD_DOMAIN_LIST_SUCCESS2747 rethash[:result] = {}2748 rethash[:result] = ret2749 else2750 rethash[:success] = false2751 rethash[:errors] = "add_domain_list: " + ret[:errors]2752 end2753 when 'secret_files_delete_domain_list'2754 ret = SpinDomain.secret_files_delete_domain(my_session_id, paramshash[:hash_key])2755 if ret.present?2756 if ret[:success] == true2757 rethash[:success] = true2758 rethash[:status] = INFO_BOOMBOX_API_DELETE_DOMAIN_LIST_SUCCESS2759 rethash[:count] = ret[:count]2760 else2761 rethash = ret2762 rethash[:success] = false2763 rethash[:status] = ERROR_BOOMBOX_API_DELETE_DOMAIN_LIST_FAILED2764 end2765 else2766 rethash[:success] = false2767 rethash[:status] = ERROR_BOOMBOX_API_DELETE_DOMAIN_LIST_FAILED2768 rethash[:errors] = 'ãµã¼ãã®æ»ãå¤ãNULLã§ããã¨ã¤ãªã¢ã¹ã®åé¤ã«å¤±æãã¾ããã'2769 end2770 when 'get_domain_list'2771 # def self.fill_domain_data_table ssid, my_uid, location, mtime2772 # get my group id2773 # if ssid == ADMIN_SESSION_ID2774 # rethash[:uid] = ACL_SUPERUSER_UID2775 # rethash[:gid] = ACL_SUPERUSER_GID2776 # rethash[:gids] = [ ACL_SUPERUSER_UID ]2777 # return rethash2778 # end2779 rethash = {}2780 #ssrec = SpinSession.readonly.select("spin_uid").find(:first, :conditions=>["spin_session_id = ?", my_session_id])2781 ssrec = SpinSession.readonly.find_by_sql(['select spin_uid from spin_sessions where spin_session_id = ?', my_session_id])2782 if ssrec.blank?2783 rethash[:status] = false;2784 rethash[:status] = ERROR_BOOMBOX_API_GET_DOMAIN_LIST_GET_SESSION;2785 rethash[:errors] = "ã»ãã·ã§ã³ããUIDãå¤å¥ã§ããªãã§ãã";2786 return rethash;2787 end2788 my_uid = ssrec[0][:spin_uid]2789 # my_gid = ssrec[:spin_gid]2790 # spin_user_obj = SpinUser.readonly.select("spin_gid").find(["spin_uid = ?", my_uid])2791 spin_user_obj = SpinUser.readonly.find_by_sql(['select spin_gid from spin_users where spin_uid = ?', my_uid])2792 if spin_user_obj == nil2793 rethash[:status] = false;2794 rethash[:status] = ERROR_BOOMBOX_API_GET_DOMAIN_LIST_GET_DOMAINS;2795 rethash[:errors] = "ã¦ã¼ã¶æ
å ±ããã°ã«ã¼ããå¤å¥ã§ããªãã§ãã";2796 return rethash;2797 end2798 my_gid = spin_user_obj[0][:spin_gid] # => primary gruop id2799 #if primary_group_id_only2800 # rethash[:uid] = my_uid2801 # rethash[:gid] = my_gid2802 # return rethash2803 #end2804 #pgids = SpinGroupMember.get_parent_gids(my_gid)2805 my_gids = SpinGroupMember.get_user_groups my_uid2806 if my_gid == nil2807 rethash[:status] = false;2808 rethash[:status] = ERROR_BOOMBOX_API_GET_DOMAIN_LIST_GET_GROUPMEMBER;2809 rethash[:errors] = "ã°ã«ã¼ãã¡ã³ãã¼æ
å ±ããã¦ã¼ã¶ã®ã°ã«ã¼ããå¤å¥ã§ããªãã§ãã";2810 return rethash;2811 end2812 c_domains = SpinDomain.search_accessible_domains my_session_id, my_gids2813 unless c_domains.length > 02814 rethash[:status] = false;2815 rethash[:status] = ERROR_BOOMBOX_API_GET_DOMAIN_LIST_GET_DOMAINS;2816 rethash[:errors] = "ãã®ã¦ã¼ã¶ã«ãã¡ã¤ã³ãæãã¾ãã";2817 return rethash;2818 else2819 rethash[:success] = true;2820 rethash[:status] = INFO_BOOMBOX_API_GET_DOMAIN_LIST_SUCCESS;2821 #count = 02822 rethash[:list] = {}2823 c_domains.each_with_index {|d_list, index|2824 rethash[:list][index] = {}2825 rethash[:list][index][:spin_domain_name] = d_list[:spin_domain_name]2826 rethash[:list][index][:spin_did] = d_list[:spin_did]2827 rethash[:list][index][:spin_domain_disp_name] = d_list[:spin_domain_disp_name]2828 rethash[:list][index][:hash_key] = d_list[:hash_key]2829 rethash[:list][index][:spin_domain_root] = d_list[:spin_domain_root]2830 rethash[:list][index][:domain_root_node_hashkey] = d_list[:domain_root_node_hashkey]2831 #count = count + 12832 }2833 end2834 when 'secret_files_get_file_digest'2835 node_hashkey = paramshash[:hash_key]2836 location = SpinLocationMapping.get_mapping_data(node_hashkey)2837 if location.blank?2838 rethash[:success] = false2839 rethash[:status] = ERROR_BOOMBOX_API_GET_MAPPING_DATA_SLM_COUNT2840 rethash[:errors] = "SPIN_LOCAION_MAPPINGã®æ»ãå¤ã空ã§ãã"2841 return rethash2842 end2843 if location == ERROR_BOOMBOX_API_GET_MAPPING_DATA_SLM_COUNT2844 rethash[:success] = false2845 rethash[:status] = ERROR_BOOMBOX_API_GET_MAPPING_DATA_SLM_COUNT2846 rethash[:errors] = "SPIN_LOCAION_MAPPINGã«åãããã·ã¥å¤ãè¤æ°ããå¯è½æ§ãããã¾ãã"2847 end2848 if File.exist?(location) == false2849 rethash[:success] = false2850 rethash[:status] = ERROR_BOOMBOX_API_GET_MAPPING_DATA_SLM_COUNT2851 rethash[:errors] = location + "ãåé¤ããã¦ããå¯è½æ§ãããã¾ãã "2852 return rethash2853 end2854 startime = Time.now2855 sha256 = Digest::SHA256.file(location).to_s2856 realtime = Time.now - startime2857 filesize = File.size(location)2858 rethash[:success] = true2859 rethash[:status] = INFO_BOOMBOX_API_GET_MAPPING_DATA_SLM_COUNT2860 rethash[:result] = {}2861 rethash[:result][:location] = location2862 rethash[:result][:size] = filesize2863 rethash[:result][:digest] = sha2562864 rethash[:result][:digestime] = realtime2865 when 'get_recycler_data'2866 #recycler_data = {}2867 spin_uid = SessionManager.get_uid my_session_id2868 offset = DEFAULT_OFFSET2869 limit = DEFAULT_PAGE_SIZE2870 n_files = []2871 n_files = RecyclerDatum.limit(limit).offset(offset).where(["spin_uid = ? AND latest = true AND is_thrown = true", spin_uid])2872 total = n_files.count2873 rethash = {}2874 if total < 02875 rethash[:success] = false2876 rethash[:status] = -12877 rethash[:error] = "error....."2878 return rethash2879 end2880 rethash[:success] = true2881 rethash[:status] = INFO_BOOMBOX_API_IHAB_LS_SUCCESS2882 rethash[:list] = {}2883 n = 0;2884 files_list = []2885 n_files.each {|f|2886 files_list.push(f)2887 }2888 files_list.each {|fl|2889 rethash[:list][n] = {}2890 rethash[:list][n][:node_name] = fl[:file_name]2891 rethash[:list][n][:hash_key] = fl[:spin_node_hashkey]2892 rethash[:list][n][:virtual_path] = fl[:virtual_path]2893 rethash[:list][n][:node_type] = fl[:file_type]2894 n = n + 12895 }2896 #return rtn2897 when 'secret_files_ls'2898 # delete file from list and put it in the recycler2899 # session_id, cont_location, hash_key, file_writable_status:bool, lock:int, file_name2900 # delete_file_name = paramshash[:file_name]2901 # paramshash.keys.each {|k| printf "%s = %s\n",k,paramshash[k]}2902 # sid = my_session_id2903 # delete_contlocation = paramshash[:cont_location]2904 ls_node_key = paramshash[:hash_key]2905 folder_data_rec = {}2906 user_agent = $http_user_agent2907 # folder_hashkey = paramshash[:hash_key]2908 #if SpinAccessControl.is_readable(my_session_id, ls_node_key) != true # not writable or login dir2909 # this should not be deleted2910 # rethash[:success] = false2911 # rethash[:status] = ERROR_NOT_WRITABLE2912 # rethash[:errors] = "ãã®ãã©ã«ãã¯è¡¨ç¤ºã§ãã¾ãã"2913 # return rethash2914 #end2915 if SpinAccessControl.is_write_only(my_session_id, ls_node_key) == true # not writable or login dir2916 rethash[:success] = false2917 rethash[:status] = ERROR_NOT_READTABLE2918 rethash[:errors] = "There are no reading right."2919 return rethash2920 end2921 #loc = SpinLocationManager.key_to_location(ls_node_key)2922 #ns = SpinNode.readonly.where("spin_node_hashkey = ? and in_trash_flag = ? and is_pending = ? and is_void = ?",ls_node_key,false,false,false)2923 #ns = SpinNode.readonly.where(:spin_node_hashkey => ls_node_key ,:in_trash_flag => false ,:is_pending => false, :is_void => false)2924 ns = SpinNode.readonly.find_by_sql(['select * from spin_nodes where spin_node_hashkey = ? and in_trash_flag = false and is_pending = false and is_void = false', ls_node_key])2925 #loc_x = ns[0][:node_x_coord]2926 #loc_y = ns[0][:node_y_coord]2927 #trash_flag = ns[0][:in_trash_flag]2928 #pending_flag = ns[0][:is_pending]2929 #void_flag = ns[0][:is_void]2930 #node_type = ns[0][:node_type]2931 # folder_key = SpinLocationManager.get_parent_key(delete_file_key)2932 #Rails.logger.warn(">> secret_files_ls : call secret_files_ls")2933 rethash = {}2934 node_type = -12935 #rethash = Hash.new { |h,k| h[k] = Hash.new(&h.default_proc) }2936 if ns.size == 02937 rethash[:success] = false2938 rethash[:status] = ERROR_BOOMBOX_API_IHAB_LS_LIST_NOT_FOUND2939 rethash[:errors] = "META information couldnot be acquired from a node hash."2940 node_type = 02941 else2942 rethash[:success] = true2943 rethash[:status] = INFO_BOOMBOX_API_IHAB_LS_SUCCESS2944 #domain_key = SessionManager.get_selected_domain(my_session_id, paramshash[:cont_location])2945 #node_loc_x = ns[0][:node_x_coord]2946 #rethash[:loc_y] = ns[0][:node_y_coord]2947 #rethash[:in_trash_flag] = ns[0][:in_trash_flag]2948 #rethash[:pending_flag] = ns[0][:is_pending]2949 #rethash[:void_flag] = ns[0][:is_void]2950 node_type = ns[0][:node_type]2951 end2952 if node_type == 22953 if SpinAccessControl.is_readable(my_session_id, ls_node_key) == true2954 rethash[:list] = {}2955 rethash[:list][0] = {}2956 rethash[:list][0][:node_name] = ns[0][:node_name]2957 rethash[:list][0][:node_type] = ns[0][:node_type]2958 rethash[:list][0][:node_size] = ns[0][:node_size]2959 rethash[:list][0][:node_description] = ns[0][:node_description]2960 rethash[:list][0][:created_by] = ns[0][:created_by]2961 #DBä¸ã®created_atã¯ãã¼ãã«ã«è¿½å ãããæå»ã§ããã¢ãããã¼ãæã«åç
§ããä½ææå»ã¯ctimeã«ãªãã2962 created_at = ns[0][:ctime]2963 rethash[:list][0][:created_at] = created_at.to_i2964 rethash[:list][0][:updated_by] = ns[0][:updated_by]2965 #DBä¸ã®updated_atã¯ãã¼ãã«ã«è¿½å ãããæå»ã§ããã¢ãããã¼ãæã«åç
§ããä½ææå»ã¯mtimeã«ãªãã2966 updated_at = ns[0][:mtime]2967 rethash[:list][0][:updated_at] = updated_at.to_i2968 rethash[:list][0][:virtual_path] = ns[0][:virtual_path]2969 rethash[:list][0][:hashkey] = ns[0][:spin_node_hashkey]2970 rethash[:list][0][:readable_status] = true2971 if SpinAccessControl.is_writable(my_session_id, rethash[:list][0][:hashkey]) == true2972 rethash[:list][0][:writable_status] = true2973 else2974 rethash[:list][0][:writable_status] = false2975 end2976 file_type_icons = $file_type_icons2977 ftype = ns[0][:node_name].split('.')[-1]2978 file_type_icons.each {|key, value|2979 next if ftype.blank?2980 if /#{ftype}/i =~ key2981 rethash[:list][0][:icon_image] = value2982 break2983 end2984 }2985 end2986 elsif node_type == 12987 rethash[:list] = {}2988 node_loc_x_pr = ns[0][:node_x_coord]2989 node_loc_y = ns[0][:node_y_coord] + 12990 node_list = SpinNode.readonly.where(["node_x_pr_coord = ? AND node_y_coord = ? AND in_trash_flag = false AND is_pending = false AND is_void = false AND latest = true", node_loc_x_pr, node_loc_y])2991 node_list = SpinNode.readonly.find_by_sql(['select * from spin_nodes where node_x_pr_coord = ? and node_y_coord = ? and in_trash_flag = false and is_pending = false and is_void = false and latest = true', node_loc_x_pr, node_loc_y])2992 node_list_count = node_list.length2993 count = 02994 if node_list_count > 02995 file_type_icons = $file_type_icons2996 node_list.each_with_index {|nlk, index|2997 node_list_node_type = nlk[:node_type]2998 next if node_list_node_type == 82999 node_list_hashkey = nlk[:spin_node_hashkey]3000 if SpinAccessControl.is_readable(my_session_id, node_list_hashkey) == true3001 rethash[:list][count] = {}3002 rethash[:list][count][:node_name] = nlk[:node_name]3003 rethash[:list][count][:node_type] = nlk[:node_type]3004 rethash[:list][count][:node_size] = nlk[:node_size]3005 rethash[:list][count][:node_description] = nlk[:node_description]3006 rethash[:list][count][:created_by] = nlk[:created_by]3007 #DBä¸ã®created_atã¯ãã¼ãã«ã«è¿½å ãããæå»ã§ããã¢ãããã¼ãæã«åç
§ããä½ææå»ã¯ctimeã«ãªãã3008 created_at = nlk[:ctime]3009 rethash[:list][count][:created_at] = created_at.to_i3010 rethash[:list][count][:updated_by] = nlk[:updated_by]3011 #DBä¸ã®updated_atã¯ãã¼ãã«ã«è¿½å ãããæå»ã§ããã¢ãããã¼ãæã«åç
§ããä½ææå»ã¯mtimeã«ãªãã3012 updated_at = nlk[:mtime]3013 rethash[:list][count][:updated_at] = updated_at.to_i3014 rethash[:list][count][:virtual_path] = nlk[:virtual_path]3015 rethash[:list][count][:hashkey] = nlk[:spin_node_hashkey]3016 rethash[:list][count][:node_version] = nlk[:node_version]3017 if SpinAccessControl.is_writable(my_session_id, rethash[:list][count][:hashkey]) == true3018 rethash[:list][count][:writable_status] = true3019 else3020 rethash[:list][count][:writable_status] = false3021 end3022 rethash[:list][count][:readable_status] = true3023 #if SpinAccessControl.is_readable(my_session_id, rethash[:list][count][:hashkey]) == true3024 # rethash[:list][count][:readable_status] = true3025 #else3026 # rethash[:list][count][:readable_status] = false3027 #end3028 rethash[:list][count][:icon_image] = "file_type_icon/unknown.png"3029 if nlk[:node_type] == 13030 rethash[:list][count][:icon_image] = "file_type_icon/FolderDocument.png"3031 elsif nlk[:node_type] == 23032 ftype = nlk[:node_name].split('.')[-1]3033 file_type_icons.each {|key, value|3034 next if ftype.blank?3035 if /#{ftype}/i =~ key3036 rethash[:list][count][:icon_image] = value3037 break3038 end3039 }3040 #ãã©ã«ãããã¡ã¤ã«ä»¥å¤ã®node_typeãåºã¦ããã以ä¸ã®ã³ã¼ãã使ãã3041 #if rethash[:list][count][:icon_image].blank?3042 # rethash[:list][count][:icon_image] = "file_type_icon/unknown.png"3043 #end3044 #ãã©ã«ãããã¡ã¤ã«ä»¥å¤ã®node_typeãåºã¦ããã使ãã3045 #3046 #3047 end3048 count = count + 13049 end3050 }3051 end3052 else3053 rethash[:success] = false3054 rethash[:status] = ERROR_BOOMBOX_API_IHAB_LS_LIST_NOT_FOUND3055 rethash[:errors] = "META information couldnot be acquired from a node hash."3056 end3057 when 'thread_delete_folder'3058 Rails.logger.warn(">>thread_delete_folder : start")3059 # delete file from list and put it in the recycler3060 # session_id, cont_location, hash_key, file_writable_status:bool, lock:int, file_name3061 # delete_file_name = paramshash[:file_name]3062 # paramshash.keys.each {|k| printf "%s = %s\n",k,paramshash[k]}3063 delete_sid = my_session_id3064 delete_uid = SessionManager.get_uid(delete_sid, true)3065 # delete_contlocation = paramshash[:cont_location]3066 delete_file_key = paramshash[:hash_key]3067 rethash[:deleted_node_type] = NODE_DIRECTORY3068 folder_data_rec = {}3069 user_agent = $http_user_agent3070 parent_hash_key = ''3071 node_name = ''3072 #if /HTTP_Request2.+/ =~ user_agent # => PHP API3073 if user_agent == "BoomboxAPI"3074 delete_file_key = paramshash[:hash_key]3075 else # => from UI3076 target_folder_key = nil3077 current_folder_key = SpinSession.select(:spin_current_directory).find_by_spin_session_id(my_session_id)3078 if current_folder_key.blank?3079 rethash[:success] = false3080 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST3081 rethash[:errors] = 'No current_folder_key record is found'3082 return rethash3083 end3084 if paramshash[:original_place] == 'folder_tree'3085 folder_data_rec = FolderDatum.find_by_hash_key paramshash[:hash_key]3086 if folder_data_rec.blank?3087 folder_data_rec = FileDatum.find_by_hash_key paramshash[:hash_key]3088 if folder_data_rec.blank?3089 rethash[:success] = false3090 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST3091 rethash[:errors] = 'No folder_data_rec record is found'3092 return rethash3093 end3094 end3095 parent_hash_key = (folder_data_rec.present? and folder_data_rec[:parent_hash_key].present?) ? folder_data_rec[:parent_hash_key] : ''3096 node_name = folder_data_rec[:folder_name]3097 parent_folder_rec = FolderDatum.get_parent_folder my_session_id, folder_data_rec[:spin_node_hashkey]3098 # parent_folder_rec = FolderDatum.get_parent_folder my_session_id, current_folder_key[:spin_current_directory]3099 target_folder_key = parent_folder_rec[:spin_node_hashkey]3100 rethash[:deleted_node_type] = NODE_DIRECTORY3101 else3102 folder_data_rec = FileDatum.find_by_hash_key paramshash[:hash_key]3103 if folder_data_rec.blank?3104 rethash[:success] = false3105 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST3106 rethash[:errors] = 'No folder_data_rec record is found'3107 return rethash3108 end3109 parent_hash_key = (folder_data_rec.present? and folder_data_rec[:parent_hash_key].present?) ? folder_data_rec[:parent_hash_key] : ''3110 node_name = folder_data_rec[:file_name]3111 target_folder_key = current_folder_key[:spin_current_directory]3112 rethash[:deleted_node_type] = (folder_data_rec[:file_type] == 'folder' ? NODE_DIRECTORY : NODE_FILE)3113 end3114 if folder_data_rec == nil3115 rethash[:success] = false3116 rethash[:status] = ERROR_INVALID_HASH_KEY3117 # rethash[:errors] = "Failed to delete file : hash key is invalid"3118 rethash[:errors] = "æå®ããããã©ã«ããè¦ã¤ããã¾ãã"3119 return rethash3120 end3121 delete_file_key = folder_data_rec[:spin_node_hashkey]3122 end3123 if paramshash[:folder_writable_status] == false or paramshash[:folder_writable_status] == "false" or SpinAccessControl.is_deletable(my_session_id, delete_file_key) != true # not writable or login dir3124 # this should not be deleted3125 rethash[:success] = false3126 rethash[:status] = ERROR_NOT_WRITABLE3127 rethash[:errors] = "ãã®ãã©ã«ãã¯åé¤ã§ãã¾ãã"3128 return rethash3129 end3130 # ããã¯ç¶æ
æä»å¶å¾¡3131 file_nodes = []3132 if paramshash[:original_place] === 'folder_tree'3133 file_nodes = DatabaseUtility::VirtualFileSystemUtility.search_virtual_file_on_tree delete_file_key3134 else3135 if folder_data_rec[:file_type] === 'folder'3136 file_nodes = DatabaseUtility::VirtualFileSystemUtility.search_virtual_file_on_tree delete_file_key3137 else3138 file_nodes = DatabaseUtility::VirtualFileSystemUtility.search_virtual_file delete_sid, node_name, parent_hash_key, ANY_VALUE, ANY_VALUE, SEARCH_EXISTING_VFILE3139 end3140 end3141 if file_nodes.size() > 03142 file_nodes.each {|file_node|3143 if file_node[:latest]3144 if FSTAT_WRITE_LOCKED == file_node[:lock_mode] && FSTAT_LOCKED == file_node[:lock_status]3145 if delete_uid != file_node[:lock_uid] && -1 != file_node[:lock_uid]3146 rethash[:success] = false3147 rethash[:status] = ERROR_TRASH_FILE3148 rethash[:errors] = 'ä»ã®ã¦ã¼ã¶ã¼ã«ããã¯ããã¦ããããåé¤ã§ãã¾ãã'3149 return rethash3150 end3151 end3152 end3153 }3154 end3155 folder_key = SpinLocationManager.get_parent_key(delete_file_key)3156 Rails.logger.warn(">> thread_delete_folder : new thread")3157 # Rails.logger.warn(">> thread_delete_folder : call set_pending 1") # ã´ãç®±ã«ç§»åããéã®ã¿ã¤ãã³ã°ã§åãã«æã£ã¦ãä»æ¹ãããã¨ãã¯ã³ã¡ã³ããå¤ãã3158 # pc = SpinNode.set_pending(delete_file_key, true)3159 thr_rethash = {}3160 begin3161 delete_thread = Thread.new(delete_sid, delete_file_key, folder_data_rec[:file_type], thr_rethash) {|del_sid, arg_del_key, f_type, thr_reth|3162 Thread.pass3163 if f_type != 'folder'3164 pc = SpinNode.set_pending(arg_del_key, true)3165 else3166 pc = SpinNode.set_pending_all(arg_del_key, true)3167 end3168 # Rails.logger.warn(">> thread_delete_folder : call delete_virtual_file")3169 thr_rethash = DatabaseUtility::VirtualFileSystemUtility.delete_virtual_file del_sid, arg_del_key, true, true # => the last 2 arguments are trash_it flag and is_thrown3170 if thr_rethash[:success]3171 RecyclerDatum.reset_busy(del_sid, arg_del_key)3172 end3173 thr_rethash[:pending_count] = pc3174 }3175 # delete_thread.join3176 rescue3177 log_msg = 'Unhandled excption!'3178 FileManager.logger(delete_sid, log_msg, 'LOCAL', LOG_ERROR)3179 rethash[:success] = false3180 rethash[:status] = ERROR_NOT_WRITABLE3181 rethash[:errors] = "ãã®ãã©ã«ãã¯åé¤ã§ãã¾ãã"3182 return rethash3183 end # => end of thread3184 wait_recycler_proc_count = 103185 while RecyclerDatum.find_by_session_id_and_spin_node_hashkey(delete_sid, delete_file_key).blank? and wait_recycler_proc_count > 03186 sleep 13187 wait_recycler_proc_count -= 13188 end3189 rethash[:success] = true3190 rethash[:status] = (INFO_TRASH_FILE_SUCCESS | INFO_RENDERING_DONE)3191 domain_key = SessionManager.get_selected_domain(my_session_id, paramshash[:cont_location])3192 FolderDatum.reset_partial_root(my_session_id, paramshash[:cont_location], domain_key)3193 #pc = SpinNode.set_pending(delete_file_key, true)3194 FolderDatum.transaction do3195 begin3196 # FolderDatum.find_by_sql('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;')3197 delquery = "DELETE FROM folder_data WHERE session_id = \'#{delete_sid}\' AND spin_node_hashkey = \'#{delete_file_key}\';"3198 FolderDatum.find_by_sql(delquery)3199 rescue ActiveRecord::StaleObjectError3200 FileManager.logger(delete_sid, "folder record is alread removed")3201 end3202 end3203 # FolderDatum.fill_folders(my_session_id, paramshash[:cont_location], domain_key)3204 FolderDatum.has_updated(my_session_id, target_folder_key, DISMISS_CHILD, true)3205 FolderDatum.set_partial_root(my_session_id, paramshash[:cont_location], target_folder_key)3206 FolderDatum.select_folder(my_session_id, folder_key, paramshash[:cont_location], domain_key)3207 when 'set_node_pending'3208 pending_sid = my_session_id3209 # pending_contlocation = paramshash[:cont_location]3210 pending_file_key = paramshash[:hash_key]3211 folder_data_rec = {}3212 user_agent = $http_user_agent3213 if /HTTP_Request2.+/ =~ user_agent # => PHP API3214 pending_file_key = paramshash[:hash_key]3215 else # => from UI3216 if paramshash[:original_place] == 'folder_tree'3217 folder_data_rec = FolderDatum.find_by_hash_key paramshash[:hash_key]3218 if folder_data_rec.blank?3219 folder_data_rec = FileDatum.find_by_hash_key paramshash[:hash_key]3220 if folder_data_rec.blank?3221 rethash[:success] = false3222 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST3223 rethash[:errors] = 'No folder_data_rec record is found'3224 return rethash3225 end3226 end3227 else3228 folder_data_rec = FileDatum.find_by_hash_key paramshash[:hash_key]3229 if folder_data_rec.blank?3230 rethash[:success] = false3231 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST3232 rethash[:errors] = 'No folder_data_rec record is found'3233 return rethash3234 end3235 end3236 if folder_data_rec == nil3237 rethash[:success] = false3238 rethash[:status] = ERROR_INVALID_HASH_KEY3239 # rethash[:errors] = "Failed to delete file : hash key is invalid"3240 rethash[:errors] = "æå®ããããã©ã«ããè¦ã¤ããã¾ãã"3241 return rethash3242 end3243 pending_file_key = folder_data_rec[:spin_node_hashkey]3244 end3245 SpinNode.set_pending(pending_file_key)3246 rethash[:success] = true3247 rethash[:status] = INFO_BASE3248 when 'secret_files_get_domain_privilege'3249 # set folder privilege3250 user_agent = $http_user_agent3251 folder_hashkey = ''3252 #if /HTTP_Request2.+/ =~ user_agent # => PHP API3253 if user_agent == "BoomboxAPI"3254 domain_hashkey = paramshash[:domain_hashkey] #ãã¡ã¤ã³ã®ããã·ã¥å¤3255 vpath_hashkey = paramshash[:vpath_hashkey] #ãã¡ã¤ã³ã®VPATHã®ããã·ã¥å¤3256 #l_offset = paramshash[:start].to_i3257 #l_limit = paramshash[:limit].to_i3258 l_offset = 03259 l_limit = 03260 #recs=GroupDatum.secret_files_get_folder_node_data ssid, GROUP_LIST_FOLDER, l_offset, l_limit, target_hashkey3261 disp_group_list_obj = GroupDatum.secret_files_get_domain_access_list my_session_id, GROUP_LIST_FOLDER, l_offset, l_limit, vpath_hashkey, domain_hashkey3262 rethash = disp_group_list_obj3263 else3264 rethash[:success] = false3265 rethash[:errors] = "BoomboxAPIã§ã¯ããã¾ããã"3266 end3267 when 'secret_files_set_folder_privilege'3268 # set folder privilege3269 user_agent = $http_user_agent3270 folder_hashkey = ''3271 source_cont_location = 'folder_a'3272 #if /HTTP_Request2.+/ =~ user_agent # => PHP API3273 if user_agent == "BoomboxAPI"3274 folder_hashkey = paramshash[:data][:hash_key]3275 privileges = Hash.new3276 set_priv_sid = my_session_id3277 #members = paramshash[:members]3278 temp = paramshash[:members]3279 if (temp.is_a?(Hash))3280 count = 03281 members = []3282 temp.each {|key, value|3283 members[count] = {}3284 members[count] = value3285 count = count + 13286 }3287 else3288 members = paramshash[:members]3289 end3290 privileges[:folder_name] = paramshash[:data][:text]3291 privileges[:folder_hashkey] = folder_hashkey3292 privileges[:cont_location] = paramshash[:data][:cont_location]3293 privileges[:target] = paramshash[:data][:target]3294 privileges[:range] = paramshash[:data][:range]3295 privileges[:owner] = paramshash[:data][:owner_name]3296 privileges[:owner_right] = 'full'3297 privileges[:other_writable] = false # => boolean3298 privileges[:other_readable] = false # => boolean3299 # privileges[:other_writable] = paramshash[:data][:other_writable] # => boolean3300 # privileges[:other_readable] = paramshash[:data][:other_readable] # => boolean3301 privileges[:group_writable] = paramshash[:data][:group_writable] # => boolean3302 privileges[:group_readable] = paramshash[:data][:group_readable] # => boolean3303 # group_editable -> control_right 2014/3/133304 # privileges[:group_editable] = paramshash[:group_editable] # => boolean3305 privileges[:control_right] = paramshash[:data][:control_right] # => boolean3306 # get numbered hashes3307 list_files = Array.new3308 # get file attributes3309 acl_recs = SpinAccessControl.secret_files_set_folder_privilege set_priv_sid, privileges, members3310 if acl_recs >= 03311 if user_agent != "BoomboxAPI"3312 domain_s = SessionManager.get_selected_domain(my_session_id, source_cont_location)3313 DomainDatum.set_domain_dirty(my_session_id, paramshash[:data][:cont_location], domain_s)3314 FolderDatum.reset_partial_root(my_session_id, paramshash[:data][:cont_location], domain_s)3315 reth = FolderDatum.fill_folders(my_session_id, paramshash[:data][:cont_location], domain_s)3316 end3317 rethash[:success] = true3318 rethash[:status] = INFO_SET_FOLDER_PRIVILEGE_SUCCESS3319 rethash[:result] = acl_recs3320 else3321 rethash[:success] = false3322 rethash[:errors] = "SpinAccessControlããã®æ»ãå¤ãä¸æ£ã§ãã"3323 end3324 else # => from UI3325 rethash[:success] = false3326 rethash[:errors] = "BoomboxAPIã§ã¯ããã¾ããã"3327 end3328 when 'secret_files_set_domain_privilege'3329 # set folder privilege3330 user_agent = $http_user_agent3331 folder_hashkey = ''3332 #if /HTTP_Request2.+/ =~ user_agent # => PHP API3333 if user_agent == "BoomboxAPI"3334 domain_hashkey = paramshash[:data][:hash_key]3335 managed_node_hashkey = paramshash[:data][:managed_node_hashkey]3336 privileges = Hash.new3337 set_priv_sid = my_session_id3338 #members = paramshash[:members]3339 temp = paramshash[:members]3340 if (temp.is_a?(Hash))3341 count = 03342 members = []3343 temp.each {|key, value|3344 members[count] = {}3345 members[count] = value3346 count = count + 13347 }3348 else3349 members = paramshash[:members]3350 end3351 privileges[:folder_name] = paramshash[:data][:text]3352 privileges[:folder_hashkey] = managed_node_hashkey3353 privileges[:cont_location] = paramshash[:data][:cont_location]3354 privileges[:target] = paramshash[:data][:target]3355 privileges[:range] = paramshash[:data][:range]3356 privileges[:owner] = paramshash[:data][:owner_name]3357 privileges[:owner_right] = 'full'3358 privileges[:other_writable] = false # => boolean3359 privileges[:other_readable] = false # => boolean3360 # privileges[:other_writable] = paramshash[:data][:other_writable] # => boolean3361 # privileges[:other_readable] = paramshash[:data][:other_readable] # => boolean3362 privileges[:group_writable] = paramshash[:data][:group_writable] # => boolean3363 privileges[:group_readable] = paramshash[:data][:group_readable] # => boolean3364 # group_editable -> control_right 2014/3/133365 # privileges[:group_editable] = paramshash[:group_editable] # => boolean3366 privileges[:control_right] = paramshash[:data][:control_right] # => boolean3367 # get numbered hashes3368 privileges[:spin_uid_access_right] = ACL_NODE_NO_ACCESS3369 privileges[:spin_world_access_right] = ACL_NODE_NO_ACCESS3370 list_files = Array.new3371 # get file attributes3372 gacl = ((privileges[:group_readable] ? ACL_NODE_READ : ACL_NODE_NO_ACCESS) | (privileges[:group_writable] ? (ACL_NODE_WRITE | ACL_NODE_DELETE) : ACL_NODE_NO_ACCESS) | (privileges[:control_right] ? ACL_NODE_CONTROL : ACL_NODE_NO_ACCESS))3373 rtn = SpinAccessControl.secret_files_add_domain_access_control(my_session_id, managed_node_hashkey, gacl, members, 32768, domain_hashkey)3374 acl_recs = SpinAccessControl.secret_files_set_domain_privilege set_priv_sid, privileges, members, domain_hashkey3375 if acl_recs >= 03376 rethash[:success] = true3377 rethash[:status] = INFO_SET_FOLDER_PRIVILEGE_SUCCESS3378 rethash[:result] = acl_recs3379 else3380 rethash[:success] = false3381 rethash[:errors] = "SpinAccessControlããã®æ»ãå¤ãä¸æ£ã§ãã"3382 end3383 else # => from UI3384 rethash[:success] = false3385 rethash[:errors] = "This isn't BoomboxAPI."3386 end3387 when 'secret_files_dismiss_domain_group' # å
ã¯dissmiss_folder_group3388 user_agent = $http_user_agent3389 folder_hashkey = ''3390 if user_agent == "BoomboxAPI" # => PHP API3391 domain_hashkey = paramshash[:data][:hash_key]3392 managed_node_hashkey = paramshash[:data][:managed_node_hashkey]3393 privileges = Hash.new3394 remove_priv_sid = my_session_id3395 privileges[:folder_name] = paramshash[:data][:text]3396 privileges[:folder_hashkey] = managed_node_hashkey3397 privileges[:cont_location] = paramshash[:data][:cont_location]3398 privileges[:target] = paramshash[:data][:target]3399 privileges[:range] = paramshash[:data][:range]3400 privileges[:owner] = paramshash[:data][:owner]3401 privileges[:other_writable] = paramshash[:data][:other_writable] # => boolean3402 privileges[:other_readable] = paramshash[:data][:other_readable] # => boolean3403 privileges[:group_writable] = paramshash[:data][:group_writable] # => boolean3404 privileges[:group_readable] = paramshash[:data][:group_readable] # => boolean3405 privileges[:group_editable] = paramshash[:data][:group_editable] # => boolean3406 remove_groups = paramshash[:members]3407 # get file attributes3408 acl_recs = SpinAccessControl.remove_folder_privilege remove_priv_sid, privileges, remove_groups, folder_hashkey3409 if acl_recs >= 03410 rethash[:success] = true3411 rethash[:status] = STAT_DATA_NOT_LOADED_YET3412 rethash[:result] = rm_recs3413 else3414 rethash[:success] = false3415 rethash[:errors] = "SpinAccessControlããã®æ»ãå¤ãä¸æ£ã§ãã"3416 end3417 else3418 #å°æ¥çã«ã¯ã¨ã©ã¼ãè¿ãããã«ãã3419 rethash[:success] = false3420 rethash[:errors] = "This isn't Boombox API."3421 end3422 when 'set_folder_privilege'3423 # set folder privilege3424 user_agent = $http_user_agent3425 folder_hashkey = ''3426 source_cont_location = 'folder_a'3427 #if /HTTP_Request2.+/ =~ user_agent # => PHP API3428 if user_agent == "BoomboxAPI"3429 folder_hashkey = paramshash[:data][:hash_key]3430 else # => from UI3431 folder_rec = FolderDatum.find_by_hash_key paramshash[:data][:hash_key]3432 if folder_rec.blank?3433 folder_rec = FileDatum.find_by_hash_key paramshash[:data][:hash_key]3434 if folder_rec.blank?3435 rethash[:success] = false3436 rethash[:status] = ERROR_FAILED_TO_SET_FOLDER_PRIVILEGE3437 rethash[:errors] = "Failed to set folder privilege."3438 return rethash3439 end3440 end3441 folder_hashkey = folder_rec[:spin_node_hashkey]3442 end3443 privileges = Hash.new3444 set_priv_sid = my_session_id3445 members = paramshash[:members]3446 privileges[:folder_name] = paramshash[:data][:text]3447 privileges[:folder_hashkey] = folder_hashkey3448 privileges[:cont_location] = paramshash[:data][:cont_location]3449 privileges[:target] = paramshash[:data][:target]3450 if paramshash[:data][:range].present?3451 privileges[:range] = 'folder'3452 else3453 privileges[:range] = paramshash[:data][:range]3454 end3455 privileges[:owner] = paramshash[:data][:owner_name]3456 privileges[:owner_right] = 'full'3457 privileges[:other_writable] = false # => boolean3458 privileges[:other_readable] = false # => boolean3459 # privileges[:other_writable] = paramshash[:data][:other_writable] # => boolean3460 # privileges[:other_readable] = paramshash[:data][:other_readable] # => boolean3461 privileges[:group_writable] = paramshash[:data][:group_writable] # => boolean3462 privileges[:group_readable] = paramshash[:data][:group_readable] # => boolean3463 # group_editable -> control_right 2014/3/133464 # privileges[:group_editable] = paramshash[:group_editable] # => boolean3465 privileges[:control_right] = paramshash[:data][:control_right] # => boolean3466 # get numbered hashes3467 list_files = Array.new3468 # get file attributes3469 #å®ç¾©ã¨ã®å·®ç°ããã£ãããããã©ã¡ã¼ã¿ã®é çªãå¤æ´ 2015/11/163470 acl_recs = SpinAccessControl.set_folder_privilege set_priv_sid, privileges, members, folder_hashkey3471 if acl_recs >= 03472 domain_s = SessionManager.get_selected_domain(my_session_id, source_cont_location)3473 DomainDatum.set_domain_dirty(my_session_id, paramshash[:data][:cont_location], domain_s)3474 # FolderDatum.reset_partial_root(my_session_id, paramshash[:data][:cont_location], domain_s)3475 reth = FolderDatum.fill_folders(my_session_id, paramshash[:data][:cont_location], domain_s)3476 rethash[:success] = true3477 rethash[:status] = INFO_SET_FOLDER_PRIVILEGE_SUCCESS3478 rethash[:result] = acl_recs3479 else3480 rethash[:success] = false3481 rethash[:status] = ERROR_FAILED_TO_SET_FOLDER_PRIVILEGE3482 end3483 when 'set_folder_notification'3484 user_agent = $http_user_agent3485 folder_hashkey = ''3486 if /HTTP_Request2.+/ =~ user_agent # => PHP API3487 folder_hashkey = paramshash[:data][:hash_key]3488 else # => from UI3489 folder_rec = FolderDatum.find_by_hash_key paramshash[:data][:hash_key]3490 if folder_rec.blank?3491 folder_rec = FileDatum.find_by_hash_key paramshash[:data][:hash_key]3492 if folder_rec.blank?3493 rethash[:success] = false3494 rethash[:status] = ERROR_FAILED_TO_SET_FOLDER_PRIVILEGE3495 rethash[:errors] = "Failed to set folder privilege."3496 return rethash3497 end3498 end3499 folder_hashkey = folder_rec[:spin_node_hashkey]3500 end3501 privileges = Hash.new3502 set_priv_sid = my_session_id3503 members = paramshash[:members]3504 privileges[:file_name] = paramshash[:data][:file_name]3505 privileges[:file_hashkey] = file_hashkey3506 privileges[:cont_location] = paramshash[:data][:cont_location]3507 privileges[:target] = 'folder'3508 if paramshash[:data][:range].present?3509 privileges[:range] = 'folder'3510 else3511 privileges[:range] = paramshash[:data][:range]3512 end3513 # privileges[:range] = paramshash[:data][:range]3514 privileges[:owner] = paramshash[:data][:owner]3515 privileges[:notify_upload] = paramshash[:data][:notify_read] # => boolean3516 privileges[:notify_modify] = paramshash[:data][:notify_modify] # => boolean3517 privileges[:notify_delete] = paramshash[:data][:notify_delete] # => boolean3518 # group_editable -> control_right 2014/3/133519 # privileges[:group_editable] = paramshash[:data][:group_editable] # => boolean3520 # privileges[:control_right] = paramshash[:data][:control_right] # => boolean3521 # get numbered hashes3522 list_files = Array.new3523 hash_params = Hash.new3524 paramshash.each {|key, value|3525 if /[0-9]+/ =~ key # => number3526 list_files.append value3527 else # => string3528 hash_params[key] = value3529 end3530 }3531 # get file attributes3532 acl_recs = SpinNotifyControl.set_folder_notification set_priv_sid, privileges, members, folder_hashkey3533 if acl_recs >= 03534 domain_s = SessionManager.get_selected_domain(my_session_id, source_cont_location)3535 DomainDatum.set_domain_dirty(my_session_id, paramshash[:data][:cont_location], domain_s)3536 FolderDatum.reset_partial_root(my_session_id, paramshash[:data][:cont_location], domain_s)3537 reth = FolderDatum.fill_folders(my_session_id, paramshash[:data][:cont_location], domain_s)3538 rethash[:success] = true3539 rethash[:status] = INFO_SET_FOLDER_PRIVILEGE_SUCCESS3540 rethash[:result] = acl_recs3541 else3542 rethash[:success] = false3543 rethash[:status] = ERROR_FAILED_TO_SET_FOLDER_PRIVILEGE3544 end3545 when 'set_file_privilege'3546 # set folder privilege3547 user_agent = $http_user_agent3548 file_hashkey = ''3549 if /HTTP_Request2.+/ =~ user_agent # => PHP API3550 file_hashkey = paramshash[:data][:hash_key]3551 else # => from UI3552 folder_rec = FileDatum.find_by_hash_key paramshash[:data][:hash_key]3553 if folder_data_rec.blank?3554 rethash[:success] = false3555 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST3556 rethash[:errors] = 'No folder_data_rec record is found at set_file_privilege'3557 return rethash3558 end3559 file_hashkey = folder_rec[:spin_node_hashkey]3560 end3561 privileges = Hash.new3562 set_priv_sid = my_session_id3563 members = paramshash[:members]3564 privileges[:file_name] = paramshash[:data][:file_name]3565 privileges[:file_hashkey] = file_hashkey3566 privileges[:cont_location] = paramshash[:data][:cont_location]3567 privileges[:target] = paramshash[:data][:target]3568 # privileges[:range] = paramshash[:data][:range]3569 privileges[:owner] = paramshash[:data][:owner]3570 privileges[:owner_right] = paramshash[:data][:owner_right]3571 privileges[:other_writable] = paramshash[:data][:other_writable] # => boolean3572 privileges[:other_readable] = paramshash[:data][:other_readable] # => boolean3573 privileges[:group_writable] = paramshash[:data][:group_writable] # => boolean3574 privileges[:group_readable] = paramshash[:data][:group_readable] # => boolean3575 # group_editable -> control_right 2014/3/133576 # privileges[:group_editable] = paramshash[:data][:group_editable] # => boolean3577 privileges[:control_right] = paramshash[:data][:control_right] # => boolean3578 # get numbered hashes3579 list_files = Array.new3580 hash_params = Hash.new3581 paramshash.each {|key, value|3582 if /[0-9]+/ =~ key # => number3583 list_files.append value3584 else # => string3585 hash_params[key] = value3586 end3587 }3588 # get file attributes3589 acl_recs = SpinAccessControl.set_file_privilege set_priv_sid, privileges, members3590 if acl_recs >= 03591 domain_s = SessionManager.get_selected_domain(my_session_id, source_cont_location)3592 DomainDatum.set_domain_dirty(my_session_id, paramshash[:data][:cont_location], domain_s)3593 FolderDatum.reset_partial_root(my_session_id, paramshash[:data][:cont_location], domain_s)3594 reth = FolderDatum.fill_folders(my_session_id, paramshash[:data][:cont_location], domain_s)3595 rethash[:success] = true3596 rethash[:status] = INFO_SET_FOLDER_PRIVILEGE_SUCCESS3597 rethash[:result] = acl_recs3598 else3599 rethash[:success] = false3600 rethash[:status] = ERROR_FAILED_TO_SET_FOLDER_PRIVILEGE3601 end3602 when 'get_group_list'3603 my_session_id = paramshash[:session_id]3604 if paramshash[:id_type].present?3605 id_type = paramshash[:id_type]3606 else3607 id_type = GROUP_MEMBER_ID_TYPE_GROUP #å¤ã¯ï¼ ã¦ã¼ã¶ã®ãã©ã¤ããªã§ãªãã°ã«ã¼ã3608 #id_type = GROUP_MEMBER_ID_TYPE_USER_PRIMARY_GROUP #å¤ã¯ï¼ãã¦ã¼ã¶ã®ãã©ã¤ããªã°ã«ã¼ã3609 end3610 # "session_id"=>"e0c4a5515e746275f5dc94feca20a147cffd192e", "searching_group"=>"x", "target_hash_key"=>""3611 #ssrec = SpinSession.readonly.select("spin_uid").find(:first, :conditions=>["spin_session_id = ?", my_session_id])3612 ssrec = SpinSession.readonly.find_by_sql(['select spin_uid from spin_sessions where spin_session_id = ?', my_session_id])3613 if ssrec.blank?3614 rethash[:success] = false3615 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST3616 rethash[:errors] = 'No session record is found at get_group_list'3617 return rethash3618 end3619 my_uid = ssrec[0][:spin_uid]3620 # my_gid = ssrec[:spin_gid]3621 #spin_user_obj = SpinUser.readonly.select("spin_gid").find(["spin_uid = ?", my_uid])3622 spin_user_obj = SpinUser.find_by_sql(['select spin_gid from spin_users where spin_uid = ?', my_uid])3623 if spin_user_obj.blank?3624 rethash[:status] = false;3625 rethash[:status] = ERROR_BOOMBOX_API_GET_GROUP_LIST;3626 rethash[:errors] = "ã¦ã¼ã¶æ
å ±ããã°ã«ã¼ããå¤å¥ã§ããªãã§ãã";3627 return rethash3628 end3629 my_gid = spin_user_obj[0][:spin_gid].to_i3630 if (my_uid == 0)3631 #n_groups = SpinGroup.readonly.find_by_sql(['select *, spin_gid as member_id from spin_groups where id_type = ?'],id_type)3632 n_groups = SpinGroup.readonly.find_by_sql(['select *, spin_gid as member_id from spin_groups'])3633 if n_groups.blank?3634 rethash[:success] = false3635 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST3636 rethash[:errors] = 'No group record is found at get_group_list'3637 return rethash3638 end3639 else3640 #n_groups = SpinGroup.readonly.find_by_sql(['select *, spin_gid as member_id from spin_groups where owner_id = ? and id_type = ?',my_gid,id_type])3641 n_groups = SpinGroup.readonly.find_by_sql(['select *, spin_gid as member_id from spin_groups where (owner_id = ? and id_type = 1) or id_type = 2', my_gid])3642 if n_groups.blank?3643 rethash[:success] = false3644 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST3645 rethash[:errors] = 'No session record is found at get_group_list'3646 return rethash3647 end3648 end3649 rethash[:result] = n_groups3650 rethash[:success] = true3651 rethash[:status] = INFO_BOOMBOX_API_GET_GROUP_LIST_SUCCESS3652 when 'get_member_group_list'3653 my_session_id = paramshash[:session_id]3654 my_group_id = paramshash[:my_group_id].to_i3655 #ssrec = SpinSession.readonly.select("spin_uid").find(:first, :conditions=>["spin_session_id = ?", my_session_id])3656 #ssrec = SpinSession.readonly.find_by_sql(['select spin_uid from spin_sessions where spin_session_id = ?',my_session_id])3657 #my_uid = ssrec[0][:spin_uid]3658 # my_gid = ssrec[:spin_gid]3659 #spin_user_obj = SpinUser.readonly.select("spin_gid").find(["spin_uid = ?", my_uid])3660 #spin_user_obj = SpinUser.readonly.find_by_sql(['select spin_gid from spin_users where spin_uid = ?',my_uid])3661 #if spin_user_obj == nil3662 # rethash[:status] = false;3663 # rethash[:status] = ERROR_BOOMBOX_API_GET_MEMBER_GROUP_LIST;3664 # rethash[:errors] = "ã¦ã¼ã¶æ
å ±ããã°ã«ã¼ããå¤å¥ã§ããªãã§ãã";3665 # return rethash;3666 #end3667 #my_gid = spin_user_obj[0][:spin_gid]3668 n_uids = SpinGroupMember.readonly.find_by_sql(['select *, spin_uid as member_id from spin_group_members where spin_gid = ?', my_group_id])3669 rethash[:result] = {}3670 if n_uids.blank?3671 rethash[:success] = false3672 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST3673 rethash[:errors] = 'No user id record is found at get_group_list'3674 return rethash3675 end3676 #n_uids.each_whih_index{|value, index|3677 # spin_uid = n_uid[:spin_uid].to_i3678 # spin_gid = n_uid[:spin_gid].to_i3679 # rtn = SpinGroup.readonly.find_by_sql(['select * ,spin_gid as member_id from spin_groups where spin_uid = ? and spin_gid = ?', spin_uid, spinuid])3680 # if rtn.present?3681 # rethash[:result][index] = {}3682 # rethash[:result][index] = rtn3683 # end3684 #}3685 rethash[:result] = n_uids3686 rethash[:status] = INFO_BOOMBOX_API_GET_MEMBER_GROUP_LIST_SUCCESS;3687 rethash[:success] = true3688 when 'add_member_my_group'3689 my_session_id = paramshash[:session_id]3690 my_group_id = paramshash[:my_group_id].to_i3691 member_ids = paramshash[:member_ids]3692 # "session_id"=>"e0c4a5515e746275f5dc94feca20a147cffd192e", "searching_group"=>"x", "target_hash_key"=>""3693 #ssrec = SpinSession.readonly.select("spin_uid").find(:first, :conditions=>["spin_session_id = ?", my_session_id])3694 ssrec = SpinSession.readonly.find_by_sql(['select spin_uid from spin_sessions where spin_session_id = ?', my_session_id])3695 if ssrec.blank?3696 rethash[:success] = false3697 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST3698 rethash[:errors] = 'No session record is found at add_member_my_group'3699 return rethash3700 end3701 my_uid = ssrec[0][:spin_uid]3702 # my_gid = ssrec[:spin_gid]3703 #spin_user_obj = SpinUser.readonly.select("spin_gid").find(["spin_uid = ?", my_uid])3704 #spin_user_obj = SpinUser.find_by_sql(['select spin_gid from spin_users where spin_uid = ?',my_uid])3705 #if spin_user_obj == nil3706 # rethash[:status] = false;3707 # rethash[:status] = ERROR_BOOMBOX_API_GET_GROUP_LIST;3708 # rethash[:errors] = "ã¦ã¼ã¶æ
å ±ããã°ã«ã¼ããå¤å¥ã§ããªãã§ãã";3709 # return rethash3710 #end3711 #my_gid = spin_user_obj[0][:spin_gid]3712 if (my_uid != 0)3713 rtn_groups = SpinGroup.readonly.find_by_sql(['select * from spin_groups where owner_id = ? and spin_gid = ?', my_uid, my_group_id])3714 if rtn_groups.count != 13715 rethash[:errors] = "追å å
ã®ã°ã«ã¼ã(#{my_group_id})ã«æ¨©é(#{my_uid})ãããã¾ããã"3716 rethash[:success] = false3717 rethash[:status] = ERROR_BOOMBOX_API_ADD_MEMBER_MY_GROUP3718 return rethash3719 end3720 end3721 member_ids.each {|value|3722 member_id = value[:member_id].to_i3723 next if my_group_id == member_id3724 reth = SpinGroupMember.add_member my_session_id, member_id, my_group_id3725 if reth[:success] == false3726 rethash[:status] = ERROR_BOOMBOX_API_ADD_MEMBER_MY_GROUP3727 return reth3728 end3729 }3730 rethash[:success] = true3731 rethash[:result] = member_ids.count3732 rethash[:status] = INFO_BOOMBOX_API_ADD_MEMBER_MY_GROUP_SUCCESS3733 when 'delete_member_my_group'3734 # add members to my group3735 my_session_id = paramshash[:session_id]3736 my_group_id = paramshash[:my_group_id].to_i3737 member_ids = paramshash[:member_ids]3738 # get numbered hashes3739 removed_members = 03740 member_ids.each {|value|3741 member_id = value[:member_id].to_i3742 reth = SpinGroupMember.delete_member my_session_id, member_id, my_group_id3743 if reth[:success] == false3744 rethash[:success] = false3745 rethash[:status] = reth[:status]3746 rethash[:errors] = reth[:errors]3747 return reth3748 end3749 removed_members += 13750 }3751 if reth[:success] == true3752 rethash[:success] = true3753 rethash[:status] = reth[:status]3754 rethash[:result] = removed_members3755 else3756 rethash[:success] = false3757 rethash[:status] = reth[:status]3758 rethash[:errors] = reth[:errors]3759 end3760 when 'search_all_groups'3761 # "session_id"=>"e0c4a5515e746275f5dc94feca20a147cffd192e", "searching_group"=>"x", "target_hash_key"=>""3762 n_groups = GroupDatum.search_all_groups my_session_id, paramshash[:searching_group]3763 rethash[:n_groups] = n_groups3764 rethash[:success] = true3765 when 'search_group_folder_privilege', 'search_group_file_privilege'3766 folder_location = paramshash[:cont_lcation]3767 # "session_id"=>"e0c4a5515e746275f5dc94feca20a147cffd192e", "searching_group"=>"x", "target_hash_key"=>""3768 n_groups = GroupDatum.search_all_groups my_session_id, paramshash[:searching_group]3769 rethash[:success] = true3770 # when 'search_group_file_privilege'3771 # search_group = paramshash[:searching_group] # => query string3772 # folder_location = paramshash[:cont_lcation]3773 # rethash[:success] = true3774 when 'dismiss_group_members'3775 # add members to my group3776 my_session_id = paramshash[:session_id]3777 my_group_id = paramshash[:my_group].to_i3778 # get numbered hashes3779 list_members = Array.new3780 hash_params = Hash.new3781 paramshash.each {|key, value|3782 if /[0-9]+/ =~ key # => number3783 list_members.append value3784 else # => string3785 hash_params[key] = value3786 end3787 }3788 # get file attributes3789 reth = SpinGroupMember.remove_group_members_from_group my_session_id, my_group_id, list_members3790 if reth[:success] == true3791 rethash[:success] = true3792 rethash[:status] = reth[:status]3793 rethash[:result] = reth[:result]3794 else3795 rethash[:success] = false3796 rethash[:status] = reth[:status]3797 end3798 when 'delete_my_group'3799 # add members to my group3800 my_session_id = paramshash[:session_id]3801 # get attributes3802 my_group_id = paramshash[:my_group].to_i3803 reth = SpinGroup.delete_group my_session_id, my_group_id3804 # reth = SpinGroupMember.append_group_members_to_current_selected_group my_session_id, list_groups, hash_params3805 if reth[:success] == true3806 rethash[:success] = true3807 rethash[:status] = reth[:status]3808 rethash[:result] = reth[:result]3809 else3810 rethash[:success] = false3811 rethash[:status] = reth[:status]3812 end3813 when 'change_my_group_name'3814 # add members to my group3815 my_session_id = paramshash[:session_id]3816 # get attributes3817 my_group_id = paramshash[:my_group].to_i3818 my_new_group_description = paramshash[:group_description]3819 my_new_group_name = paramshash[:changed_group_name]3820 reth = SpinGroup.modify_group_info my_group_id, my_new_group_name, my_new_group_description3821 # reth = SpinGroupMember.append_group_members_to_current_selected_group my_session_id, list_groups, hash_params3822 if reth[:success] == true3823 retgid = SpinGroup.select_group my_session_id, my_new_group_name3824 if retgid < 03825 rethash[:success] = false3826 rethash[:status] = ERROR_SELECTED_GROUP_MISSING3827 rethash[:errors] = "no selected group data"3828 return rethash3829 else3830 rethash[:success] = true3831 rethash[:status] = INFO_SELECT_GROUP_SUCCESS3832 rethash[:result] = retgid3833 end3834 # rethash[:success] = true3835 # rethash[:status] = reth[:status]3836 # rethash[:result] = reth[:result]3837 else3838 rethash[:success] = false3839 rethash[:status] = reth[:status]3840 end3841 when 'append_my_group_members'3842 # add members to my group3843 my_session_id = paramshash[:session_id]3844 gid=paramshash[:gid]3845 # get numbered hashes3846 list_groups = Array.new3847 hash_params = Hash.new3848 paramshash.each {|key, value|3849 if /[0-9]+/ =~ key # => number3850 list_groups.append value3851 else # => string3852 hash_params[key] = value3853 end3854 }3855 # get file attributes3856 if (list_groups.length()>0)3857 reth = SpinGroupMember.append_group_members_to_current_selected_group my_session_id, list_groups, hash_params, gid3858 else3859 rethash[:success] = false3860 rethash[:errors] = 'ã¡ã³ãã¼ãé¸æããã¦ãã¾ããã'3861 return rethash;3862 end3863 if reth[:success] == true3864 rethash[:success] = true3865 rethash[:status] = reth[:status]3866 rethash[:result] = reth[:result]3867 else3868 rethash[:success] = false3869 rethash[:status] = reth[:status]3870 end3871 when 'append_my_folder_members', 'append_my_folder_memebers'3872 # add members to my folder access list3873 # set folder privilege3874 privileges = Hash.new3875 append_group_sid = my_session_id3876 append_folder_location = paramshash[:cont_location]3877 #target_hash_key = paramshash[:target_hash_key]3878 target_hash_key = ''3879 if (paramshash[:target]=='folderPanelA')3880 fd = FolderDatum.find_by_hash_key paramshash[:hash_key];3881 if fd.blank?3882 rethash[:success] = false3883 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST3884 rethash[:errors] = 'No folder record is found at append_my_folder_members'3885 return rethash3886 end3887 target_hash_key=fd[:spin_node_hashkey];3888 else3889 fd = FileDatum.find_by_hash_key paramshash[:hash_key];3890 if fd.blank?3891 rethash[:success] = false3892 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST3893 rethash[:errors] = 'No folder record is found at append_my_folder_members 2'3894 return rethash3895 end3896 target_hash_key=fd[:spin_node_hashkey];3897 end3898 # get numbered hashes3899 append_groups = Array.new3900 hash_params = Hash.new3901 paramshash.each {|key, value|3902 if /[0-9]+/ =~ key # => number3903 append_groups.append value3904 else # => string3905 hash_params[key] = value3906 end3907 }3908 # get file attributes3909 acl_recs = GroupDatum.append_group_to_privilege_list append_group_sid, append_folder_location, append_groups, target_hash_key, GROUP_LIST_FOLDER3910 if acl_recs >= 03911 rethash[:success] = true3912 rethash[:result] = acl_recs3913 else3914 rethash[:success] = false3915 end3916 when 'append_my_file_members'3917 # add members to my folder access list3918 # set folder privilege3919 privileges = Hash.new3920 append_group_sid = my_session_id3921 append_folder_location = paramshash[:cont_location]3922 target_hash_key = paramshash[:target_hash_key]3923 # get numbered hashes3924 append_groups = Array.new3925 hash_params = Hash.new3926 paramshash.each {|key, value|3927 if /[0-9]+/ =~ key # => number3928 append_groups.append value3929 else # => string3930 hash_params[key] = value3931 end3932 }3933 # get file attributes3934 acl_recs = GroupDatum.append_group_to_privilege_list append_group_sid, append_folder_location, append_groups, target_hash_key, GROUP_LIST_FILE3935 if acl_recs >= 03936 rethash[:success] = true3937 rethash[:result] = acl_recs3938 else3939 rethash[:success] = false3940 end3941 when 'dismiss_folder_group'3942 # set folder privilege3943 # set folder privilege3944 user_agent = $http_user_agent3945 folder_hashkey = ''3946 #if /HTTP_Request2.+/ =~ user_agent # => PHP API3947 if user_agent == "BoomboxAPI" # => PHP API3948 folder_hashkey = paramshash[:data][:hash_key]3949 else # => from UI3950 #folder_rec = FolderDatum.find_by_hash_key paramshash[:data][:hash_key]3951 #folder_rec = FileDatum.find_by_hash_key paramshash[:data][:hash_key]3952 #folder_hashkey = folder_rec[:spin_node_hashkey]3953 if (paramshash[:target]=='listGridPanelA')3954 folder_rec=FileDatum.find_by_hash_key paramshash[:data][:hash_key];3955 if folder_rec.blank?3956 rethash[:success] = false3957 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST3958 rethash[:errors] = 'No folder record is found at dismiss_folder_group'3959 return rethash3960 end3961 folder_hashkey = folder_rec[:spin_node_hashkey]3962 else3963 folder_rec=FolderDatum.find_by_hash_key paramshash[:data][:hash_key];3964 if folder_rec.blank?3965 rethash[:success] = false3966 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST3967 rethash[:errors] = 'No folder record is found at dismiss_folder_group 2'3968 return rethash3969 end3970 folder_hashkey = folder_rec[:spin_node_hashkey]3971 end3972 end3973 privileges = Hash.new3974 remove_priv_sid = my_session_id3975 privileges[:folder_name] = paramshash[:data][:text]3976 privileges[:folder_hashkey] = folder_hashkey3977 privileges[:cont_location] = paramshash[:data][:cont_location]3978 privileges[:target] = paramshash[:data][:target]3979 if paramshash[:data][:range].present?3980 privileges[:range] = 'folder'3981 else3982 privileges[:range] = paramshash[:data][:range]3983 end3984 privileges[:owner] = paramshash[:data][:owner]3985 privileges[:other_writable] = paramshash[:data][:other_writable] # => boolean3986 privileges[:other_readable] = paramshash[:data][:other_readable] # => boolean3987 privileges[:group_writable] = paramshash[:data][:group_writable] # => boolean3988 privileges[:group_readable] = paramshash[:data][:group_readable] # => boolean3989 privileges[:group_editable] = paramshash[:data][:group_editable] # => boolean3990 # get numbered hashes3991 remove_groups = paramshash[:members]3992 # hash_params = Hash.new3993 # paramshash.each { |key,value|3994 # if /[0-9]+/ =~ key # => number3995 # remove_groups.append value3996 # else # => string3997 # hash_params[key] = value3998 # end3999 # }4000 # get file attributes4001 acl_recs = SpinAccessControl.remove_folder_privilege remove_priv_sid, privileges, remove_groups, folder_hashkey4002 if acl_recs >= 04003 rm_recs = GroupDatum.remove_group_from_privilege_list remove_priv_sid, remove_groups, GROUP_LIST_FOLDER4004 if rm_recs >= 04005 domain_s = SessionManager.get_selected_domain(my_session_id, paramshash[:data][:cont_location])4006 # DomainDatum.set_domain_dirty(my_session_id, paramshash[:data][:cont_location], domain_s)4007 FolderDatum.reset_partial_root(my_session_id, paramshash[:data][:cont_location], domain_s)4008 # FolderDatum.load_folder_recs(my_session_id, folder_hashkey, domain_s, paramshash[:data][:cont_location])4009 FolderDatum.fill_folders(my_session_id, paramshash[:data][:cont_location], domain_s)4010 FolderDatum.select_folder(my_session_id, folder_hashkey, paramshash[:data][:cont_location], domain_s)4011 rethash[:success] = true4012 rethash[:status] = STAT_DATA_NOT_LOADED_YET4013 rethash[:isDirty] =4014 rethash[:result] = rm_recs4015 else4016 rethash[:success] = false4017 rethash[:errors] = "Failed to remove access right records from GroupData"4018 end4019 else4020 rethash[:success] = false4021 end4022 # acl_recs = SpinAccessControl.set_folder_privilege set_priv_sid, privileges, members4023 # if acl_recs >= 04024 # domain_s = SessionManager.get_selected_domain(my_session_id, source_cont_location)4025 # DomainDatum.set_domain_dirty(my_session_id, paramshash[:data][:cont_location], domain_s)4026 # FolderDatum.reset_partial_root(my_session_id, paramshash[:data][:cont_location], domain_s)4027 # reth = FolderDatum.fill_folders(my_session_id, paramshash[:data][:cont_location], domain_s)4028 # rethash[:success] = true4029 # rethash[:status] = INFO_SET_FOLDER_PRIVILEGE_SUCCESS4030 # rethash[:result] = acl_recs4031 # else4032 # rethash[:success] = false4033 # end4034 when 'dismiss_file_group'4035 # set folder privilege4036 # set folder privilege4037 user_agent = $http_user_agent4038 folder_hashkey = ''4039 if /HTTP_Request2.+/ =~ user_agent # => PHP API4040 folder_hashkey = paramshash[:data][:hash_key]4041 else # => from UI4042 file_rec = FileDatum.find_by_hash_key paramshash[:data][:hash_key]4043 if file_rec.blank?4044 rethash[:success] = false4045 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST4046 rethash[:errors] = 'No folder record is found at dismiss_file_group'4047 return rethash4048 end4049 file_hashkey = file_rec[:spin_node_hashkey]4050 end4051 privileges = Hash.new4052 remove_priv_sid = my_session_id4053 privileges[:file_name] = paramshash[:data][:fle_name]4054 privileges[:file_hashkey] = file_hashkey4055 privileges[:cont_location] = paramshash[:data][:cont_location]4056 privileges[:target] = paramshash[:data][:target]4057 # privileges[:range] = paramshash[:data][:range]4058 privileges[:owner] = paramshash[:data][:owner]4059 privileges[:other_writable] = paramshash[:data][:other_writable] # => boolean4060 privileges[:other_readable] = paramshash[:data][:other_readable] # => boolean4061 privileges[:group_writable] = paramshash[:data][:group_writable] # => boolean4062 privileges[:group_readable] = paramshash[:data][:group_readable] # => boolean4063 privileges[:group_editable] = paramshash[:data][:group_editable] # => boolean4064 # get numbered hashes4065 remove_groups = paramshash[:members]4066 # hash_params = Hash.new4067 # paramshash.each { |key,value|4068 # if /[0-9]+/ =~ key # => number4069 # remove_groups.append value4070 # else # => string4071 # hash_params[key] = value4072 # end4073 # }4074 # get file attributes4075 acl_recs = SpinAccessControl.remove_file_privilege remove_priv_sid, privileges, remove_groups4076 if acl_recs >= 04077 rm_recs = GroupDatum.remove_group_from_privilege_list remove_priv_sid, remove_groups, GROUP_LIST_FILE4078 if rm_recs >= 04079 rethash[:success] = true4080 rethash[:result] = rm_recs4081 else4082 rethash[:success] = false4083 rethash[:errors] = "Failed to remove access right records from GroupData"4084 end4085 else4086 rethash[:success] = false4087 end4088 when 'xmove_folder'4089 user_agent = $http_user_agent4090 move_file_key = ''4091 if /HTTP_Request2.+/ =~ user_agent # => PHP API4092 move_file_key = paramshash[:hash_key]4093 else # => from UI4094 folder_rec = FolderDatum.find_by_hash_key paramshash[:hash_key]4095 if folder_rec.blank?4096 rethash[:success] = false4097 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST4098 rethash[:errors] = 'No folder record is found at xmove_folder'4099 return rethash4100 end4101 move_file_key = folder_rec[:spin_node_hashkey]4102 end4103 # delete file from list and put it in the recycler4104 # session_id, cont_location, hash_key, file_writable_status:bool, lock:int, file_name4105 # move_file_name = paramshash[:file_name]4106 # paramshash.keys.each {|k| printf "%s = %s\n",k,paramshash[k]}4107 move_sid = my_session_id4108 # move_contlocation = paramshash[:cont_location]4109 # move_file_key = paramshash[:hash_key]4110 if paramshash[:folder_writable_status] == true or paramshash[:folder_writable_status] == 'true'4111 move_folder_writable_status = true4112 else4113 move_folder_writable_status = false4114 end4115 target_cont_location = paramshash[:target_cont_location]4116 if target_cont_location == 'folder_a'4117 source_cont_location = 'folder_b'4118 else4119 source_cont_location = 'folder_a'4120 end4121 target_folder_writable_status = paramshash[:target_folder_writable_status]4122 if paramshash[:target_folder_writable_status] == true or paramshash[:targert_folder_writable_status] == 'true'4123 target_folder_writable_status = true4124 else4125 target_folder_writable_status = false4126 end4127 target_hash_key = paramshash[:target_hash_key]4128 # target_folder_name = paramshash[:text]4129 if move_folder_writable_status != true # => not movable4130 # this should not be deleted4131 rethash[:success] = false4132 rethash[:status] = ERROR_MOVE_FILE4133 rethash[:errors] = "Failed to move file : file is not movable"4134 return rethash4135 end4136 retb = DatabaseUtility::VirtualFileSystemUtility.move_virtual_file move_sid, move_file_key, target_hash_key, target_cont_location4137 if retb4138 move_source_folder_hashkey = SpinLocationManager.get_parent_key(move_file_key)4139 FolderDatum.has_updated(move_sid, move_source_folder_hashkey, DISMISS_CHILD, true)4140 FolderDatum.has_updated(move_sid, target_hash_key, NEW_CHILD, true)4141 # SessionManager.set_location_dirty(move_sid, (source_cont_location == 'folder_a' ? 'file_listA' : 'file_listB'), true)4142 # SessionManager.set_location_dirty(move_sid, (target_cont_location == 'folder_a' ? 'file_listA' : 'file_listB'), true)4143 rethash[:success] = true4144 rethash[:status] = INFO_MOVE_FILE_SUCCESS4145 DomainDatum.domains_have_updated(my_session_id, SpinNode.get_domains(move_file_key))4146 else4147 rethash[:success] = false4148 rethash[:status] = ERROR_MOVE_FILEl4149 end4150 when 'create_sub_folder'4151 # coord_value is an array : [x,y,prx,v,h]4152 FileManager.rails_logger(">> create_sub_folder : started at " + Time.now.to_s)4153 error_coord = [-1, -1, -1, -1, nil]4154 flag_make_dir_if_not_exeits = true4155 hk = ''4156 parent_folder = ''4157 parent_is_expanded = false4158 #if paramshash[:original_place] == 'folder_tree' # it is in folder tree4159 if paramshash[:original_place] == 'folderPanelA'4160 folder_rec = FolderDatum.find_by_session_id_and_hash_key_and_cont_location_and_text my_session_id, paramshash[:hash_key], paramshash[:cont_location], paramshash[:text]4161 if folder_rec.blank?4162 rethash[:success] = false4163 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST4164 rethash[:errors] = 'No folder record is found at create_sub_folder'4165 return rethash4166 end4167 hk = folder_rec[:spin_node_hashkey]4168 target_hashkey = folder_rec[:spin_node_hashkey]4169 else4170 folder_rec = FileDatum.find_by_session_id_and_hash_key_and_cont_location_and_file_name my_session_id, paramshash[:hash_key], paramshash[:cont_location], paramshash[:text]4171 if folder_rec.blank?4172 rethash[:success] = false4173 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST4174 rethash[:errors] = 'No folder record is found at create_sub_folder 2'4175 return rethash4176 end4177 hk = folder_rec[:spin_node_hashkey]4178 target_hashkey = folder_rec[:folder_hash_key]4179 # FolderDatum.select_folder(my_session_id, hk, paramshash[:cont_location])4180 end4181 # if paramshash[:folder_hash_key]primary_group4182 # hk = paramshash[:folder_hash_key]4183 # elsif paramshash[:hash_key]4184 # hk = paramshash[:hash_key]4185 # else4186 # hk = nil4187 # end4188 # current_dir = DatabaseUtility::SessionUtility.get_current_directory my_session_id4189 # FileManager.rails_logger(">> get_vpath : started at " + Time.now.to_s)4190 # my_vpath = SpinNode.get_vpath(hk)4191 my_vpath = SpinNode.get_vpath folder_rec[:spin_node_hashkey]4192 #my_vpath = folder_rec[:vpath]4193 # my_vpath=SpinNode.get_virtual_path hk4194 if my_vpath == nil or my_vpath.blank?4195 rethash[:success] = false4196 rethash[:status] = false4197 rethash[:errors] = 'ã¢ã¯ã»ã¹åºæ¥ãªããã¹ãæå®ããã¾ãã'4198 return rethash4199 end4200 new_vpath = my_vpath + '/' + paramshash[:new_folder]4201 parent_folder_node = SpinNode.find_by_spin_node_hashkey hk4202 if parent_folder_node.blank?4203 rethash[:success] = false4204 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST4205 rethash[:errors] = 'No folder record is found at create_sub_folder 3'4206 return rethash4207 end4208 parent_folder = hk4209 # # get void directory nodes under hk4210 # void_dirs = SpinNode.where(["spin_tree_type = 0 AND node_x_pr_coord = ? AND node_y_coord = ? AND node_type = ? AND is_void = true",pn[:node_x_coord],pn[:node_y_coord] + 1,NODE_DIRECTORY])4211 # void_dirs.each {|vd|4212 # vd.destroy4213 # }4214 # FileManager.rails_logger(">> DatabaseUtility::VirtualFileSystemUtility.search_virtual_file : started at " + Time.now.to_s)4215 can_file_nodes = DatabaseUtility::VirtualFileSystemUtility.search_virtual_file my_session_id, paramshash[:new_folder], hk, parent_folder_node[:node_x_coord], parent_folder_node[:node_y_coord], SEARCH_EXISTING_VFILE4216 unless can_file_nodes.blank?4217 can_file_nodes.each {|canf|4218 if canf[:in_trash_flag]4219 rethash[:success] = false4220 rethash[:status] = ERROR_SAME_FILE_PATH_IN_RECYCLER4221 if canf[:node_type] == NODE_FILE4222 rethash[:errors] = 'åããã¹åã®ãã¡ã¤ã«ãã´ãç®±ã®ä¸ã«ããã¾ã'4223 else4224 rethash[:errors] = 'åããã¹åã®ãã©ã«ããã´ãç®±ã®ä¸ã«ããã¾ã'4225 end4226 else4227 rethash[:success] = false4228 rethash[:status] = ERROR_SAME_FILE_PATH_IN_DIRECTORY4229 if canf[:node_type] == NODE_FILE4230 rethash[:errors] = 'åããã¹åã®ãã¡ã¤ã«ããã©ã«ãã®ä¸ã«ããã¾ã'4231 else4232 rethash[:errors] = 'åããã¹åã®ãã©ã«ãããã©ã«ãã®ä¸ã«ããã¾ã'4233 end4234 end4235 return rethash4236 }4237 end4238 # Create directory if it isn't there.4239 # FileManager.rails_logger(">> SpinLocationManager.get_location_coordinates : started at " + Time.now.to_s)4240 coord_value = SpinLocationManager.get_location_coordinates my_session_id, paramshash[:cont_location], new_vpath, flag_make_dir_if_not_exeits, ACL_NO_VALUE, ACL_NO_VALUE, ACL_NO_VALUE4241 if coord_value[X..V] == [-1, -1, -1, -1]4242 rethash[:success] = false4243 rethash[:status] = false4244 rethash[:errors] = coord_value.to_s4245 else4246 created_folder = coord_value[K]4247 # FileManager.rails_logger(">> FolderDatum.add_folder_rec : started at " + Time.now.to_s)4248 FolderDatum.add_folder_rec(my_session_id, coord_value[K], paramshash[:domain_hash_key], paramshash[:cont_location])4249 # FileManager.rails_logger(">>SpinNode.get_parent : started at " + Time.now.to_s)4250 # parent_folder = SpinNode.get_parent(created_folder, NODE_DIRECTORY)4251 # FileManager.rails_logger(">> SpinDomain.get_domain_root_node_key : started at " + Time.now.to_s)4252 domain_root_key = domain_root_key = SpinDomain.get_domain_root_node_key(paramshash[:domain_hash_key])4253 if parent_folder == domain_root_key4254 parent_is_expanded = true4255 parent_folder = created_folder4256 else4257 # FileManager.rails_logger(">> FolderDatum.is_expanded_folder : started at " + Time.now.to_s)4258 parent_is_expanded = FolderDatum.is_expanded_folder(my_session_id, paramshash[:cont_location], parent_folder)4259 end4260 if parent_is_expanded4261 # FileManager.rails_logger(">> DomainDatum.is_dirty_domain : started at " + Time.now.to_s)4262 is_dirty = DomainDatum.is_dirty_domain(my_session_id, paramshash[:cont_location], paramshash[:domain_hash_key])4263 if is_dirty4264 # FileManager.rails_logger(">> FolderDatum.reset_partial_root : started at " + Time.now.to_s)4265 FolderDatum.reset_partial_root(my_session_id, paramshash[:cont_location], paramshash[:domain_hash_key])4266 # FileManager.rails_logger(">> FolderDatum.fill_folders : started at " + Time.now.to_s)4267 FolderDatum.fill_folders(my_session_id, paramshash[:cont_location], paramshash[:domain_hash_key])4268 FolderDatum.set_partial_root(my_session_id, paramshash[:cont_location], target_hashkey, paramshash[:domain_hash_key])4269 rethash = {:success => true, :status => STAT_DATA_NOT_LOADED_YET, :isDirty => true, :parent_node => parent_folder}4270 else4271 # FileManager.rails_logger(">> FolderDatum.load_folder_recs : started at " + Time.now.to_s)4272 FolderDatum.load_folder_recs(my_session_id, parent_folder, paramshash[:domain_hash_key], parent_folder, paramshash[:cont_location], DEPTH_TO_TRAVERSE, SessionManager.get_last_session(my_session_id))4273 # FileManager.rails_logger(">> FolderDatum.select_folder : started at " + Time.now.to_s)4274 FolderDatum.select_folder(my_session_id, parent_folder, paramshash[:cont_location], paramshash[:domain_hash_key])4275 # FileManager.rails_logger(">> FolderDatum.reset_partial_root : started at " + Time.now.to_s)4276 FolderDatum.reset_partial_root(my_session_id, paramshash[:cont_location], paramshash[:domain_hash_key])4277 # FileManager.rails_logger(">> FolderDatum.set_partial_root : started at " + Time.now.to_s)4278 FolderDatum.set_partial_root(my_session_id, paramshash[:cont_location], target_hashkey, paramshash[:domain_hash_key])4279 rethash = {:success => true, :status => STAT_DATA_NOT_LOADED_YET, :isDirty => false, :parent_node => parent_folder}4280 end4281 else4282 # FileManager.rails_logger(">> DomainDatum.is_dirty_domain : started at " + Time.now.to_s)4283 is_dirty = DomainDatum.is_dirty_domain(my_session_id, paramshash[:cont_location], paramshash[:domain_hash_key])4284 if is_dirty4285 # FileManager.rails_logger(">> FolderDatum.reset_partial_root : started at " + Time.now.to_s)4286 FolderDatum.reset_partial_root(my_session_id, paramshash[:cont_location], paramshash[:domain_hash_key])4287 # FileManager.rails_logger(">> FolderDatum.fill_folders : started at " + Time.now.to_s)4288 FolderDatum.fill_folders(my_session_id, paramshash[:cont_location], paramshash[:domain_hash_key])4289 # FileManager.rails_logger(">> FolderDatum.select_folder : started at " + Time.now.to_s)4290 FolderDatum.select_folder(my_session_id, parent_folder, paramshash[:cont_location], paramshash[:domain_hash_key])4291 FolderDatum.set_partial_root(my_session_id, paramshash[:cont_location], target_hashkey, paramshash[:domain_hash_key])4292 rethash = {:success => true, :status => STAT_DATA_NOT_LOADED_YET, :isDirty => true, :parent_node => parent_folder}4293 else4294 # FileManager.rails_logger(">> FolderDatum.load_folder_recs : started at " + Time.now.to_s)4295 FolderDatum.load_folder_recs(my_session_id, parent_folder, paramshash[:domain_hash_key], parent_folder, paramshash[:cont_location], DEPTH_TO_TRAVERSE, SessionManager.get_last_session(my_session_id))4296 # FileManager.rails_logger(">> FolderDatum.select_folder : started at " + Time.now.to_s)4297 FolderDatum.select_folder(my_session_id, parent_folder, paramshash[:cont_location], paramshash[:domain_hash_key])4298 # FileManager.rails_logger(">> FolderDatum.reset_partial_root : started at " + Time.now.to_s)4299 FolderDatum.reset_partial_root(my_session_id, paramshash[:cont_location], paramshash[:domain_hash_key])4300 # FileManager.rails_logger(">> FolderDatum.set_partial_root : started at " + Time.now.to_s)4301 FolderDatum.set_partial_root(my_session_id, paramshash[:cont_location], target_hashkey, paramshash[:domain_hash_key])4302 rethash = {:success => true, :status => STAT_DATA_NOT_LOADED_YET, :isDirty => false, :parent_node => parent_folder}4303 end4304 end4305 FolderDatum.select_folder my_session_id, parent_folder, paramshash[:cont_location], paramshash[:domain_hash_key]4306 locations = CONT_LOCATIONS_LIST4307 locations -= [paramshash[:cont_location]]4308 # FolderDatum.select_folder my_session_id, parent_folder, paramshash[:cont_location], paramshash[:domain_hash_key]4309 # FileManager.rails_logger(">> FolderDatum.has_updated : started at " + Time.now.to_s)4310 FolderDatum.has_updated(my_session_id, parent_folder, NEW_CHILD)4311 # locations.each {|loc|4312 ## FileManager.rails_logger(">> FolderDatum.copy_folder_data_from_location_to_location : started at " + Time.now.to_s)4313 # reth = FolderDatum.copy_folder_data_from_location_to_location my_session_id, paramshash[:cont_location], loc, paramshash[:domain_hash_key]4314 # }\\\\\4315 DomainDatum.set_domain_dirty(my_session_id, paramshash[:cont_location], paramshash[:domain_hash_key])4316 # FolderDatum.set_parent_folders_dirty target_hash_key4317 # FolderDatum.set_folder_dirty target_hash_key4318 FileManager.rails_logger(">> create_sub_folder : finished at " + Time.now.to_s)4319 FileDatum.fill_file_list my_session_id, paramshash[:cont_location], target_hashkey4320 end4321 when 'create_root_folder'4322 # coord_value is an array : [x,y,prx,v,h]4323 error_coord = [-1, -1, -1, -1]4324 flag_make_dir_if_not_exeits = true4325 hk = nil4326 if paramshash[:folder_hash_key]4327 hk = paramshash[:folder_hash_key]4328 elsif paramshash[:hash_key]4329 hk = paramshash[:hash_key]4330 else4331 hk = nil4332 end4333 # current_dir = DatabaseUtility::SessionUtility.get_current_directory my_session_id4334 coord_value = SpinLocationManager.get_location_coordinates my_session_id, 'root_node_location', paramshash[:new_folder_name], flag_make_dir_if_not_exeits, ACL_NO_VALUE, ACL_NO_VALUE, ACL_NO_VALUE4335 # coord_value = SpinLocationManager.get_location_coordinates paramshash[:new_root_folder], flag_make_dir_if_not_exeits4336 if coord_value[X..V] == error_coord4337 rethash[:success] = false4338 rethash[:status] = false4339 rethash[:errors] = coord_value.to_s4340 else4341 rethash[:success] = true4342 rethash[:status] = true4343 rethash[:result] = coord_value4344 hash_key = SpinLocationManager.location_to_key(coord_value, NODE_DIRECTORY)4345 DomainDatum.domains_have_updated(my_session_id, SpinNode.get_domains(hash_key))4346 FolderDatum.has_updated(my_session_id, hash_key, NEW_CHILD)4347 # FolderDatum.set_folder_dirty hash_key4348 end4349 when 'create_folder'4350 # coord_value is an array : [x,y,prx,v,h]4351 error_coord = [-1, -1, -1, -1]4352 flag_make_dir_if_not_exeits = true4353 hk = nil4354 if paramshash[:folder_hash_key]4355 hk = paramshash[:folder_hash_key]4356 elsif paramshash[:hash_key]4357 hk = paramshash[:hash_key]4358 else4359 hk = nil4360 end4361 # current_dir = DatabaseUtility::SessionUtility.get_current_directory my_session_id4362 coord_value = SpinLocationManager.get_location_coordinates my_session_id, paramshash[:cont_location], paramshash[:new_root_folder], flag_make_dir_if_not_exeits, ACL_NO_VALUE, ACL_NO_VALUE, ACL_NO_VALUE4363 if coord_value[X..V] == error_coord4364 rethash[:success] = false4365 rethash[:status] = false4366 rethash[:errors] = coord_value.to_s4367 else4368 rethash[:success] = true4369 rethash[:status] = true4370 rethash[:result] = coord_value4371 # DomainDatum.domains_have_updated( my_session_id, SpinNode.get_domains( SpinLocationManager.location_to_key(coord_value, NODE_DIRECTORY) ) )4372 target_hash_key = SpinLocationManager.location_to_key(coord_value, NODE_DIRECTORY)4373 DomainDatum.domains_have_updated(my_session_id, SpinNode.get_domains(target_hash_key))4374 FolderDatum.has_updated(my_session_id, target_hash_key, NEW_CHILD)4375 end4376 when 'ui_upload_file'4377 # create meta data for uploading file4378 # //items[0].value (request_type =) "upload_file"4379 # //items[1].value (session_id =) ********4380 # //items[2].value (cont_location =) "folder_a"/"folder_b"4381 # //items[3].value (hash_key =) ************4382 # //items[4].value (text =) uploadå
ãã©ã«ãå4383 # //items[5].value (upload_filename=) uploadãã¡ã¤ã«å4384 # //items[6].value (another_name =) uploadãã¡ã¤ã«å(session_id + hashkey) # then return redirect url of file manager4385 unless FileManager.is_alive(my_session_id) == true4386 # => not writable4387 rethash[:success] = false4388 rethash[:status] = ERROR_SYSTEM_FILE_MANAGER_DIED4389 return rethash4390 end4391 if FileManager.is_busy4392 # => not writable4393 rethash[:success] = false4394 rethash[:status] = ERROR_SYSTEM_FILE_MANAGER_BUSY4395 return rethash4396 end4397 upload_file_name = paramshash[:upload_filename].gsub("C:\\fakepath\\", "")4398 upload_dir_key = paramshash[:text]4399 paramshash.keys.each {|k| printf "%s = %s\n", k, paramshash[k]}4400 upload_sid = my_session_id4401 folder_data_rec = FolderDatum.find_by_hash_key paramshash[:hash_key]4402 if folder_rec.blank?4403 rethash[:success] = false4404 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST4405 rethash[:errors] = 'No folder record is found at ui_upload_file'4406 return rethash4407 end4408 upload_dir_key = folder_data_rec[:spin_node_hashkey]4409 pcnode = nil4410 file_nodes = DatabaseUtility::VirtualFileSystemUtility.search_virtual_file upload_sid, upload_file_name, upload_dir_key, ANY_VALUE, ANY_VALUE, SEARCH_EXISTING_VFILE4411 vfile_key = ''4412 file_nodes.each {|file_node|4413 if file_node[:latest]4414 pcnode = file_node4415 end4416 if file_node[:in_trash_flag]4417 rethash[:success] = false4418 rethash[:status] = ERROR_SAME_FILE_PATH_IN_RECYCLER4419 rethash[:errors] = 'åããã¹åã®ãã¡ã¤ã«ãã´ãç®±ã®ä¸ã«ããã¾ã'4420 return rethash4421 end4422 next if file_node[:is_pending] or file_node[:is_void]4423 # => yes there is!4424 unless SpinAccessControl.is_writable upload_sid, file_node[:spin_node_hashkey], ACL_TYPE_FILE4425 # => not writable4426 rethash[:success] = false4427 rethash[:status] = ERROR_NOT_WRITABLE4428 rethash[:errors] = 'ãã¡ã¤ã«ãæ¸ãè¾¼ã権éãæãã¾ãã'4429 return rethash4430 else4431 break4432 end4433 }4434 vloc = NoXYPV4435 # => Is there a node that is pending upload status?4436 if pcnode.present?4437 ActiveRecord::Base.lock_optimistically = false4438 catch(:update_spin_nodes_again) {4439 SpinLocationMapping.trasnaction do4440 begin4441 pclocman = SpinLocationMapping.readonly.find_by_node_hash_key(pcnode[:spin_node_hashkey])4442 if pclocman.present?4443 if pclocman[:size_of_data] == pcnode[:node_size] and pclocman[:size_of_data_upper] == pcnode[:node_size_upper] # => upload is completed4444 vloc = SpinNode.create_virtual_file upload_sid, upload_file_name, upload_dir_key, REQUEST_VERSION_NUMBER, nil, true, true4445 else # => upload is not completed4446 vloc[X] = pcnode[:node_x_coord]4447 vloc[Y] = pcnode[:node_y_coord]4448 vloc[PRX] = pcnode[:node_x_pr_coord]4449 vloc[V] = pcnode[:node_version]4450 vloc[K] = pcnode[:spin_node_hashkey]4451 end4452 else # => There is a node record but no location mapping record4453 vloc[X] = pcnode[:node_x_coord]4454 vloc[Y] = pcnode[:node_y_coord]4455 vloc[PRX] = pcnode[:node_x_pr_coord]4456 vloc[V] = pcnode[:node_version]4457 vloc[K] = pcnode[:spin_node_hashkey]4458 end4459 pcnode[:is_pending] = false4460 pcnode.save4461 rescue ActiveRecord::StaleObjectError4462 sleep(AR_RETRY_WAIT_MSEC)4463 throw :update_spin_nodes_again4464 end4465 end # => end of transaction4466 }4467 else4468 vloc = SpinNode.create_virtual_file upload_sid, upload_file_name, upload_dir_key, REQUEST_VERSION_NUMBER, nil, true, true4469 end4470 vfile_key = vloc[K]4471 if vfile_key == nil4472 # => failed to create new node ( may be another process is uploading file at the same location )4473 msg = 'Error : failed to create virtual file at upload_file : [' + upload_sid + ', ' + upload_file_name + ', ' + upload_dir_key + ']'4474 FileManager.rails_logger(msg)4475 rethash[:success] = false4476 rethash[:status] = ERROR_FAILED_TO_CREATE_NEW_NODE_REC4477 return rethash4478 end4479 rsa_key_pem = SpinNode.get_root_rsa_key4480 pdata = ''4481 fmargs = ''4482 retry_encrypt = ENCRYPTION_RETRY_COUNT4483 catch(:encrypt_again_6) {4484 begin4485 pdata = my_session_id + vfile_key + upload_file_name4486 # make encrypted data4487 file_manager_params = Security.public_key_encrypt2 rsa_key_pem, pdata4488 # and encode into base644489 # fmargs = file_manager_params4490 enc_len = file_manager_params[:data].length4491 if enc_len < (KEY_SIZE / 8)4492 if retry_encrypt > 04493 retry_encrypt -= 14494 sleep(AR_RETRY_WAIT_MSEC)4495 throw :encrypt_again_64496 end4497 end4498 fmargs = Security.urlsafe_encode_base64(file_manager_params[:length].to_s + file_manager_params[:data])4499 if ENV['RAILS_ENV'] != 'production'4500 my_host = $http_host.split(/:|\//)[-2]4501 # => get URL server4502 my_url_host = SpinFileServer.find_by_server_name('127.0.0.1:18881')4503 if my_url_host.present?4504 my_host = my_url_host[:spin_url_server_name]4505 end4506 # if my_host.length == 24507 rethash[:redirect_uri] = my_host + "/filemanager/uploader/upload_proc?fmargs=" + fmargs4508 else4509 rethash[:redirect_uri] = '/secret_files/uploader/upload_proc?fmargs=' + fmargs4510 end4511 # my_host = $http_host.split(/:/)4512 # if my_host.length == 24513 # rethash[:redirect_uri] = "http://#{my_host[0]}:18881/filemanager/uploader/upload_proc?fmargs=" + fmargs4514 # else4515 # rethash[:redirect_uri] = '/secret_files/uploader/upload_proc?fmargs=' + fmargs4516 # end4517 rethash[:success] = true4518 FolderDatum.set_folder_dirty my_session_id, upload_dir_key4519 rescue OpenSSL::PKey::RSAError4520 if retry_encrypt > 04521 retry_encrypt -= 14522 sleep(AR_RETRY_WAIT_MSEC)4523 throw :encrypt_again_64524 end4525 rethash[:success] = false4526 rethash[:status] = ERROR_UPLOAD_FILE4527 rethash[:errors] = 'Failed to generate encrypted URL by OpenSSL::PKey::RSA'4528 rescue4529 if retry_encrypt > 04530 retry_encrypt -= 14531 sleep(AR_RETRY_WAIT_MSEC)4532 throw :encrypt_again_64533 end4534 rethash[:success] = false4535 rethash[:status] = ERROR_UPLOAD_FILE4536 rethash[:errors] = 'Failed to generate encrypted urlsafe URL'4537 end4538 }4539 when 'create_thumbnail'4540 unless FileManager.is_alive(my_session_id) == true4541 rethash[:success] = false4542 rethash[:status] = ERROR_SYSTEM_FILE_MANAGER_DIED4543 return rethash4544 end4545 if FileManager.is_busy4546 rethash[:success] = false4547 rethash[:status] = ERROR_SYSTEM_FILE_MANAGER_BUSY4548 return rethash4549 end4550 unless paramshash[:hash_key]4551 msg = 'Error : failed to create thumbnail file : hash_key is not specified'4552 FileManager.rails_logger(msg)4553 rethash[:success] = false4554 rethash[:status] = ERROR_FAILED_TO_CREATE_THUMBNAIL4555 rethash[:errors] = msg4556 return rethash4557 end4558 thumbnail_hash_key = paramshash[:hash_key]4559 thumbnail_file_name = paramshash[:file_name]4560 respj = SpinNode.create_thumbnail_file(my_session_id, thumbnail_hash_key, thumbnail_file_name)4561 FileManager.rails_logger(respj.to_s)4562 reth = JSON.parse(respj.to_s)4563 unless reth["success"]4564 # => failed to create new node ( may be another process is uploading file at the same location )4565 msg = 'Error : failed to create thumbnail file for : [' + my_session_id + ', ' + thumbnail_hash_key + ':' + ']'4566 FileManager.rails_logger(msg)4567 rethash[:success] = false4568 rethash[:status] = ERROR_FAILED_TO_CREATE_THUMBNAIL4569 rethash[:errors] = msg4570 return rethash4571 end4572 rethash[:success] = true4573 rethash[:status] = INFO_CREATE_THUMBNAIL_SUCCESS4574 rethash[:result] = reth["result"]4575 when 'remove_thumbnail'4576 unless FileManager.is_alive(my_session_id) == true4577 rethash[:success] = false4578 rethash[:status] = ERROR_SYSTEM_FILE_MANAGER_DIED4579 return rethash4580 end4581 if FileManager.is_busy4582 rethash[:success] = false4583 rethash[:status] = ERROR_SYSTEM_FILE_MANAGER_BUSY4584 return rethash4585 end4586 unless paramshash[:hash_key]4587 msg = 'Error : failed to remove thumbnail file : hash_key is not specified'4588 FileManager.rails_logger(msg)4589 rethash[:success] = false4590 rethash[:status] = ERROR_FAILED_TO_REMOVE_THUMBNAIL4591 rethash[:errors] = msg4592 return rethash4593 end4594 thumbnail_hash_key = paramshash[:hash_key]4595 # check thumbnail is or not4596 thumbnail_is = SpinLocationManager.thumbnail_exists(thumbnail_hash_key)4597 unless thumbnail_is4598 msg = 'Error : No thumbnail file for : [' + my_session_id + ', ' + thumbnail_hash_key + ':' + ']'4599 rethash[:success] = false4600 rethash[:status] = ERROR_FAILED_TO_REMOVE_THUMBNAIL4601 rethash[:errors] = msg4602 return rethash4603 end4604 respj = SpinNode.remove_thumbnail_file(my_session_id, thumbnail_hash_key)4605 #respj.to_s: ãã¡ã¤ã«ããã¼ã¸ã£ã«è¿ãã¨ãã¯æååã«å¤æãã¦æ¸¡ããªããã°ãªããªãã4606 FileManager.rails_logger(respj.to_s)4607 reth = JSON.parse(respj.to_s)4608 unless reth["success"]4609 # => failed to create new node ( may be another process is uploading file at the same location )4610 msg = 'Error : failed to remove thumbnail file for : [' + my_session_id + ', ' + thumbnail_hash_key + ':' + ']'4611 FileManager.rails_logger(msg)4612 rethash[:success] = false4613 rethash[:status] = ERROR_FAILED_TO_REMOVE_THUMBNAIL4614 rethash[:errors] = msg4615 return rethash4616 end4617 rethash[:success] = true4618 rethash[:status] = INFO_CREATE_THUMBNAIL_SUCCESS4619 rethash[:result] = reth["result"]4620 when 'set_dir_sticky'4621 my_uid = ANY_UID4622 node_hash_key = ''4623 if paramshash[:user_name]4624 my_uid = SpinUser.get_uid(paramshash[:user_name])4625 end4626 if paramshash[:hash_key]4627 node_hash_key = paramshash[:hash_key]4628 end4629 respb = SpinNode.set_sticky(my_session_id, node_hash_key, my_uid)4630 unless respb4631 # => failed to create new node ( may be another process is uploading file at the same location )4632 msg = 'Error : failed to set directory sticky : [' + my_session_id + ', ' + node_hash_key + ':' + ']'4633 FileManager.rails_logger(msg)4634 rethash[:success] = false4635 rethash[:status] = ERROR_FAILED_TO_SET_DIRECTORY_STICKY4636 rethash[:errors] = 'ã¹ãã£ããã¼ãããã®è¨å®ã«å¤±æãã¾ãã'4637 return rethash4638 end4639 rethash[:success] = true4640 rethash[:status] = INFO_SET_DIRECTORY_STICKY_SUCCESS4641 when 'reset_dir_sticky'4642 my_uid = ANY_UID4643 node_hash_key = ''4644 if paramshash[:user_name]4645 my_uid = SpinUser.get_uid(paramshash[:user_name])4646 end4647 if paramshash[:hash_key]4648 node_hash_key = paramshash[:hash_key]4649 end4650 respb = SpinNode.set_sticky(my_session_id, node_hash_key, my_uid)4651 unless respb4652 # => failed to create new node ( may be another process is uploading file at the same location )4653 msg = 'Error : failed to reset directory sticky : [' + my_session_id + ', ' + node_hash_key + ':' + ']'4654 FileManager.rails_logger(msg)4655 rethash[:success] = false4656 rethash[:status] = ERROR_FAILED_TO_SET_DIRECTORY_STICKY4657 rethash[:errors] = 'ã¹ãã£ããã¼ãããã®ãªã»ããã«å¤±æãã¾ãã'4658 return rethash4659 end4660 rethash[:success] = true4661 rethash[:status] = INFO_SET_DIRECTORY_STICKY_SUCCESS4662 when 'recover_trash_error'4663 respb = RecyclerDatum.recover_pending_trash_operation(my_session_id)4664 unless respb4665 # => failed to create new node ( may be another process is uploading file at the same location )4666 msg = 'Error : failed to recover nodes from trashbox : [' + my_session_id + ']'4667 FileManager.rails_logger(msg)4668 rethash[:success] = false4669 rethash[:status] = ERROR_FAILED_TO_RECOVER_TRAHSH_ERROR4670 return rethash4671 end4672 rethash[:success] = true4673 rethash[:status] = INFO_RECOVER_TRAHSH_ERROR_SUCCESS4674 when 'upload_file'4675 # create meta data for uploading file4676 # //items[0].value (request_type =) "upload_file"4677 # //items[1].value (session_id =) ********4678 # //items[2].value (cont_location =) "folder_a"/"folder_b"4679 # //items[3].value (hash_key =) ************4680 # //items[4].value (text =) uploadå
ãã©ã«ãåde4681 # //items[5].value (upload_filename=) uploadãã¡ã¤ã«å4682 # //items[6].value (another_name =) uploadãã¡ã¤ã«å(session_id + hashkey) # then return redirect url of file manager4683 # upload_file_name = paramshash[:upload_filename].gsub("C:\\fakepath\\","")4684 unless FileManager.is_alive(my_session_id) == true4685 # => not writable4686 rethash[:success] = false4687 rethash[:status] = ERROR_SYSTEM_FILE_MANAGER_DIED4688 rethash[:errors] = 'A file manager, you cannot communicate.'4689 FileManager.rails_logger(rethash[:errors])4690 FileManager.logger(my_session_id, rethash[:errors])4691 return rethash4692 end4693 if FileManager.is_busy4694 # => not writable4695 rethash[:success] = false4696 rethash[:status] = ERROR_SYSTEM_FILE_MANAGER_BUSY4697 rethash[:errors] = 'A file manager is Busy. Please communicate after it has passed for a while.'4698 FileManager.rails_logger(rethash[:errors])4699 FileManager.logger(my_session_id, rethash[:errors])4700 return rethash4701 end4702 upload_file_name = paramshash[:upload_filename].gsub(/\\u([\da-fA-F]{4})/) {[$1].pack('H*').unpack('n*').pack('U*')}4703 if paramshash[:upload_filename].include?('\\')4704 tmp_path_array = paramshash[:upload_filename].split(/\\/)4705 upload_file_name = tmp_path_array[-1]4706 end4707 upload_dir_key = ''4708 paramshash.keys.each {|k| printf "%s = %s\n", k, paramshash[k]}4709 upload_sid = my_session_id4710 upload_uid = SessionManager.get_uid(upload_sid, true)4711 target_hashkey = nil4712 # folder_data_rec = FolderDatum.find_by_hash_key paramshash[:hash_key]4713 user_agent = $http_user_agent4714 #if /HTTP_Request2.+/ =~ user_agent # => PHP API4715 if user_agent == "BoomboxAPI" # => PHP API4716 upload_dir_key = paramshash[:hash_key]4717 else # => from UI4718 if paramshash[:original_place] == 'folder_tree' # it is in folder tree4719 folder_rec = FolderDatum.find_by_hash_key paramshash[:hash_key]4720 unless folder_rec.blank?4721 upload_dir_key = folder_rec[:spin_node_hashkey]4722 else4723 upload_dir_key = paramshash[:hash_key]4724 end4725 #upload_dir_key = folder_rec[:spin_node_hashkey]4726 else4727 folder_rec = FileDatum.find_by_hash_key paramshash[:hash_key]4728 unless folder_rec.blank?4729 upload_dir_key = folder_rec[:spin_node_hashkey]4730 else4731 upload_dir_key = paramshash[:hash_key]4732 end4733 #upload_dir_key = folder_rec[:spin_node_hashkey]4734 end4735 # folder_data_rec = FolderDatum.find_by_hash_key paramshash[:hash_key]4736 # upload_dir_key = folder_data_rec[:spin_node_hashkey]4737 end4738 pcnode = nil4739 my_upload_file_name = ''4740 vloc = NoXYPV4741 vfile_key = ''4742 SpinAccessControl.transaction do4743 # SpinLockSpinNodes.find_by_sql('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;')4744 # SpinLockSpinNodes.find_by_sql('LOCK TABLE spin_lock_spin_nodes IN EXCLUSIVE MODE;')4745 # lock_records = SpinLockSpinNodes.find(1)4746 file_nodes = DatabaseUtility::VirtualFileSystemUtility.search_virtual_file upload_sid, upload_file_name, upload_dir_key, ANY_VALUE, ANY_VALUE, SEARCH_EXISTING_VFILE4747 if file_nodes.size() > 04748 file_nodes.each {|file_node|4749 if file_node[:latest]4750 if FSTAT_WRITE_LOCKED == file_node[:lock_mode] && FSTAT_LOCKED == file_node[:lock_status]4751 if upload_uid != file_node[:lock_uid] && -1 != file_node[:lock_uid]4752 rethash[:success] = false4753 rethash[:status] = ERROR_UPLOAD_FILE4754 #rethash[:errors] = 'ä»ã®ã¦ã¼ã¶ã¼ã«ããã¯ããã¦ãããã¡ã¤ã«ã¯ã¢ãããã¼ãã§ãã¾ãã'4755 rethash[:errors] = 'The other users cannot upload a locked file.'4756 return rethash4757 end4758 end4759 pcnode = file_node4760 end4761 if file_node[:in_trash_flag]4762 rethash[:success] = false4763 rethash[:status] = ERROR_SAME_FILE_PATH_IN_RECYCLER4764 rethash[:errors] = 'A file of the same pathname is in the trash can.'4765 #rethash[:errors] = 'åããã¹åã®ãã¡ã¤ã«ãã´ãç®±ã®ä¸ã«ããã¾ã'4766 FileManager.rails_logger(rethash[:errors])4767 FileManager.logger(my_session_id, rethash[:errors])4768 return rethash4769 end4770 next if file_node[:is_pending] or file_node[:is_void]4771 # => yes there is!4772 unless SpinAccessControl.is_writable upload_sid, file_node[:spin_node_hashkey], ACL_TYPE_FILE4773 # => not writable4774 rethash[:success] = false4775 rethash[:status] = ERROR_NOT_WRITABLE4776 rethash[:errors] = 'ãã¡ã¤ã«ãæ¸ãè¾¼ã権éãæãã¾ãã'4777 #rethash[:errors] = 'ãã¡ã¤ã«ãæ¸ãè¾¼ã権éãæãã¾ãã'4778 FileManager.rails_logger(rethash[:errors])4779 FileManager.logger(my_session_id, rethash[:errors])4780 return rethash4781 else4782 break4783 end4784 }4785 end4786 my_upload_file_name = upload_file_name4787 end # => end of transaction4788 # => Is there a node that is pending upload status?4789 if pcnode.present?4790 catch(:update_spin_nodes_again) {4791 SpinLocationMapping.transaction do4792 begin4793 pclocman = SpinLocationMapping.readonly.find_by_node_hash_key(pcnode[:spin_node_hashkey])4794 if pclocman.present?4795 if pclocman[:size_of_data] == pcnode[:node_size] and pclocman[:size_of_data_upper] == pcnode[:node_size_upper] # => upload is completed4796 vloc = SpinNode.create_virtual_file upload_sid, upload_file_name, upload_dir_key, REQUEST_VERSION_NUMBER, nil, true, true4797 else # => upload is not completed4798 vloc[X] = pcnode[:node_x_coord]4799 vloc[Y] = pcnode[:node_y_coord]4800 vloc[PRX] = pcnode[:node_x_pr_coord]4801 vloc[V] = pcnode[:node_version]4802 vloc[K] = pcnode[:spin_node_hashkey]4803 end4804 else # => There is a node record but no location mapping record4805 vloc[X] = pcnode[:node_x_coord]4806 vloc[Y] = pcnode[:node_y_coord]4807 vloc[PRX] = pcnode[:node_x_pr_coord]4808 vloc[V] = pcnode[:node_version]4809 vloc[K] = pcnode[:spin_node_hashkey]4810 end4811 pcnode[:is_pending] = false4812 pcnode.save4813 rescue ActiveRecord::StaleObjectError4814 sleep(AR_RETRY_WAIT_MSEC)4815 throw :update_spin_nodes_again4816 end4817 end # => end of transaction4818 } # => end of catch4819 else4820 vloc = SpinNode.create_virtual_file upload_sid, upload_file_name, upload_dir_key, REQUEST_VERSION_NUMBER, nil, true, true4821 end4822 vfile_key = vloc[K]4823 # vfile_key = SpiNode.create_virtual_file upload_sid, upload_file_name, upload_dir_key, nil, true, true4824 if vfile_key == nil4825 # => failed to create new node ( may be another process is uploading file at the same location )4826 msg = 'Error : failed to create virtual file at upload_file : [' + upload_sid + ', ' + upload_file_name + ', ' + upload_dir_key + ']'4827 FileManager.rails_logger(msg)4828 rethash[:success] = false4829 rethash[:status] = ERROR_FAILED_TO_CREATE_NEW_NODE_REC4830 rethash[:errors] = msg4831 FileManager.rails_logger(rethash[:errors])4832 FileManager.logger(my_session_id, rethash[:errors])4833 return rethash4834 end4835 # ããã¯ç¶æ
å¼ãç¶ã4836 if nil != pcnode4837 spin_node_upd = Hash.new4838 spin_node_upd[:upd_lock_uid] = pcnode[:lock_uid]4839 spin_node_upd[:upd_lock_status] = pcnode[:lock_status]4840 spin_node_upd[:upd_lock_mode] = pcnode[:lock_mode]4841 lock_ret = SpinNode.set_lock upload_uid, upload_dir_key, upload_file_name, upload_sid, spin_node_upd4842 if !lock_ret4843 rethash[:success] = false4844 rethash[:status] = ERROR_UPLOAD_FILE4845 rethash[:errors] = "Failed to set lock of " + upload_file_name4846 FileManager.rails_logger(rethash[:errors])4847 FileManager.logger(my_session_id, rethash[:errors])4848 return rethash4849 end4850 end4851 rsa_key_pem = SpinNode.get_root_rsa_key4852 pdata = ''4853 fmargs = ''4854 retry_encrypt = ENCRYPTION_RETRY_COUNT4855 catch(:encrypt_again_7) {4856 begin4857 pdata = my_session_id + vfile_key + upload_file_name4858 # make encrypted data4859 file_manager_params = Security.public_key_encrypt2 rsa_key_pem, pdata4860 # and encode into base644861 # fmargs = file_manager_params4862 enc_len = file_manager_params[:data].length4863 if enc_len < (KEY_SIZE / 8)4864 if retry_encrypt > 04865 retry_encrypt -= 14866 sleep(AR_RETRY_WAIT_MSEC)4867 throw :encrypt_again_74868 end4869 end4870 fmargs = Security.urlsafe_encode_base64(file_manager_params[:length].to_s + file_manager_params[:data])4871 if ENV['RAILS_ENV'] != 'production'4872 my_host = $http_host.split(/:|\//)[-2]4873 # => get URL server4874 my_url_host = SpinFileServer.find_by_server_name('127.0.0.1:18881')4875 if my_url_host.present?4876 my_host = my_url_host[:spin_url_server_name]4877 end4878 # if my_host.length == 24879 rethash[:redirect_uri] = my_host + "/filemanager/uploader/upload_proc?fmargs=" + fmargs4880 else4881 rethash[:redirect_uri] = '/secret_files/uploader/upload_proc?fmargs=' + fmargs4882 end4883 rethash[:success] = true4884 FolderDatum.set_folder_dirty my_session_id, upload_dir_key4885 rescue OpenSSL::PKey::RSAError4886 if retry_encrypt > 04887 retry_encrypt -= 14888 sleep(AR_RETRY_WAIT_MSEC)4889 throw :encrypt_again_74890 end4891 rethash[:success] = false4892 rethash[:status] = ERROR_UPLOAD_FILE4893 rethash[:errors] = 'Failed to generate encrypted URL by OpenSSL::PKey::RSA'4894 FileManager.rails_logger(rethash[:errors])4895 FileManager.logger(my_session_id, rethash[:errors])4896 rescue4897 if retry_encrypt > 04898 retry_encrypt -= 14899 sleep(AR_RETRY_WAIT_MSEC)4900 throw :encrypt_again_74901 end4902 rethash[:success] = false4903 rethash[:status] = ERROR_UPLOAD_FILE4904 rethash[:errors] = 'Failed to generate encrypted urlsafe URL'4905 FileManager.rails_logger(rethash[:errors])4906 FileManager.logger(my_session_id, rethash[:errors])4907 end4908 }4909 unless $http_user_agent == 'BoomboxAPI'4910 target_folder = FolderDatum.find_by_session_id_and_spin_node_hashkey(my_session_id, upload_dir_key)4911 # target_folder = FolderDatum.get_parent_folder(my_session_id, upload_dir_key);4912 if target_folder.present?4913 target_hashkey = target_folder[:spin_node_hashkey]4914 else4915 target_hashkey = SessionManager.get_selected_folder(my_session_id, "folder_a")4916 end4917 # FolderDatum.set_partial_root(my_session_id,paramshash[:cont_location], upload_dir_key)F4918 unless FolderDatum.is_dirty_folder(my_session_id, 'folder_a', target_hashkey)4919 session_rec = SpinSession.readonly.find_by_spin_session_id my_session_id4920 if session_rec.blank?4921 rethash[:success] = false4922 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST4923 rethash[:errors] = 'No folder record is found at upload_file'4924 return rethash4925 end4926 FolderDatum.fill_folders(paramshash[:session_id], "folder_a", session_rec[:selected_domain_a], target_hashkey, PROCESS_FOR_UNIVERSAL_REQUEST, false, 3)4927 FolderDatum.has_updated(upload_sid, upload_dir_key, NEW_CHILD, true)4928 #FolderDatum.add_child_to_parent upload_dir_key, target_hashkey, my_session_id4929 FolderDatum.set_folder_dirty upload_sid, target_hashkey4930 # FolderDatum.set_parent_folders_dirty target_hashkey4931 end4932 FileDatum.fill_file_list paramshash[:session_id], "folder_a", target_hashkey4933 res_msg = '>> upload_file (Rails) : result = ' + rethash.to_s4934 FileManager.logger(my_session_id, res_msg, 'LOCAL')4935 else4936 res_msg = '>> upload_file (BoomboxAPI) : result = ' + rethash.to_s4937 FileManager.logger(my_session_id, res_msg, 'LOCAL')4938 end # => end of UI agent4939 when 'upload_file_virtual_path'4940 # create meta data for uploading file4941 # //items[0].value (request_type =) "upload_file"4942 # //items[1].value (session_id =) ********4943 # //items[2].value (cont_location =) "folder_a"/"folder_b"4944 # //items[3].value (hash_key =) ************4945 # //items[4].value (text =) uploadå
ãã©ã«ãåde4946 # //items[5].value (upload_filename=) uploadãã¡ã¤ã«å4947 # //items[6].value (another_name =) uploadãã¡ã¤ã«å(session_id + hashkey) # then return redirect url of file manager4948 # upload_file_name = paramshash[:upload_filename].gsub("C:\\fakepath\\","")4949 unless FileManager.is_alive(my_session_id) == true4950 # => not writable4951 rethash[:success] = false4952 rethash[:status] = ERROR_SYSTEM_FILE_MANAGER_DIED4953 return rethash4954 end4955 if FileManager.is_busy4956 # => not writable4957 rethash[:success] = false4958 rethash[:status] = ERROR_SYSTEM_FILE_MANAGER_BUSY4959 return rethash4960 end4961 upload_file_name = paramshash[:upload_filename]4962 if paramshash[:upload_filename].include?('\\')4963 tmp_path_array = paramshash[:upload_filename].split(/\\/)4964 upload_file_name = tmp_path_array[-1]4965 end4966 upload_dir_key = ''4967 upload_dir_vpath = ''4968 paramshash.keys.each {|k| printf "%s = %s\n", k, paramshash[k]}4969 upload_sid = my_session_id4970 upload_uid = SessionManager.get_uid(upload_sid, true)4971 upload_dir_vpath = paramshash[:upload_directory]4972 upload_dir_key = SpinLocationManager.get_vpath_key(upload_dir_vpath)4973 pcnode = nil4974 file_nodes = DatabaseUtility::VirtualFileSystemUtility.search_virtual_file upload_sid, upload_file_name, upload_dir_key, ANY_VALUE, ANY_VALUE, SEARCH_EXISTING_VFILE4975 vfile_key = ''4976 if file_nodes.size() > 04977 file_nodes.each {|file_node|4978 if file_node[:latest]4979 if FSTAT_WRITE_LOCKED == file_node[:lock_mode] && FSTAT_LOCKED == file_node[:lock_status]4980 if upload_uid != file_node[:lock_uid] && -1 != file_node[:lock_uid]4981 rethash[:success] = false4982 rethash[:status] = ERROR_UPLOAD_FILE4983 rethash[:errors] = 'ä»ã®ã¦ã¼ã¶ã¼ã«ããã¯ããã¦ãããã¡ã¤ã«ã¯ã¢ãããã¼ãã§ãã¾ãã'4984 return rethash4985 end4986 end4987 pcnode = file_node4988 end4989 if file_node[:in_trash_flag]4990 rethash[:success] = false4991 rethash[:status] = ERROR_SAME_FILE_PATH_IN_RECYCLER4992 rethash[:errors] = 'åããã¹åã®ãã¡ã¤ã«ãã´ãç®±ã®ä¸ã«ããã¾ã'4993 return rethash4994 end4995 next if file_node[:is_pending] or file_node[:is_void]4996 # => yes there is!4997 unless SpinAccessControl.is_writable upload_sid, file_node[:spin_node_hashkey], ACL_TYPE_FILE4998 # => not writable4999 rethash[:success] = false5000 rethash[:status] = ERROR_NOT_WRITABLE5001 rethash[:errors] = 'ãã¡ã¤ã«ãæ¸ãè¾¼ã権éãæãã¾ãã'5002 return rethash5003 else5004 break5005 end5006 }5007 end5008 my_upload_file_name = upload_file_name5009 vloc = NoXYPV5010 # => Is there a node that is pending upload status?5011 if pcnode.present?5012 pclocman = SpinLocationMapping.readonly.find_by_node_hash_key(pcnode[:spin_node_hashkey])5013 if pclocman.present?5014 if pclocman[:size_of_data] == pcnode[:node_size] and pclocman[:size_of_data_upper] == pcnode[:node_size_upper] # => upload is completed5015 vloc = SpinNode.create_virtual_file upload_sid, upload_file_name, upload_dir_key, REQUEST_VERSION_NUMBER, nil, true, true5016 else # => upload is not completed5017 vloc[X] = pcnode[:node_x_coord]5018 vloc[Y] = pcnode[:node_y_coord]5019 vloc[PRX] = pcnode[:node_x_pr_coord]5020 vloc[V] = pcnode[:node_version]5021 vloc[K] = pcnode[:spin_node_hashkey]5022 end5023 else # => There is a node record but no location mapping record5024 vloc[X] = pcnode[:node_x_coord]5025 vloc[Y] = pcnode[:node_y_coord]5026 vloc[PRX] = pcnode[:node_x_pr_coord]5027 vloc[V] = pcnode[:node_version]5028 vloc[K] = pcnode[:spin_node_hashkey]5029 end5030 pcnode[:is_pending] = false5031 pcnode.save5032 else5033 vloc = SpinNode.create_virtual_file upload_sid, upload_file_name, upload_dir_key, REQUEST_VERSION_NUMBER, nil, true, true5034 end5035 vfile_key = vloc[K]5036 # vfile_key = SpiNode.create_virtual_file upload_sid, upload_file_name, upload_dir_key, nil, true, true5037 if vfile_key == nil5038 # => failed to create new node ( may be another process is uploading file at the same location )5039 msg = 'Error : failed to create virtual file at upload_file : [' + upload_sid + ', ' + upload_file_name + ', ' + upload_dir_key + ']'5040 FileManager.rails_logger(msg)5041 rethash[:success] = false5042 rethash[:status] = ERROR_FAILED_TO_CREATE_NEW_NODE_REC5043 return rethash5044 end5045 # ããã¯ç¶æ
å¼ãç¶ã5046 if nil != pcnode5047 spin_node_upd = Hash.new5048 spin_node_upd[:upd_lock_uid] = pcnode[:lock_uid]5049 spin_node_upd[:upd_lock_status] = pcnode[:lock_status]5050 spin_node_upd[:upd_lock_mode] = pcnode[:lock_mode]5051 lock_ret = SpinNode.set_lock upload_uid, upload_dir_key, upload_file_name, upload_sid, spin_node_upd5052 if !lock_ret5053 rethash[:success] = false5054 rethash[:status] = ERROR_UPLOAD_FILE5055 rethash[:errors] = "Failed to set lock of " + upload_file_name5056 return rethash5057 end5058 end5059 rsa_key_pem = SpinNode.get_root_rsa_key5060 pdata = ''5061 fmargs = ''5062 retry_encrypt = ENCRYPTION_RETRY_COUNT5063 catch(:encrypt_again_8) {5064 begin5065 pdata = my_session_id + vfile_key + upload_file_name5066 # make encrypted data5067 file_manager_params = Security.public_key_encrypt2 rsa_key_pem, pdata5068 # and encode into base645069 # fmargs = file_manager_params5070 enc_len = file_manager_params[:data].length5071 if enc_len < (KEY_SIZE / 8)5072 if retry_encrypt > 05073 retry_encrypt -= 15074 sleep(AR_RETRY_WAIT_MSEC)5075 throw :encrypt_again_85076 end5077 end5078 fmargs = Security.urlsafe_encode_base64(file_manager_params[:length].to_s + file_manager_params[:data])5079 if ENV['RAILS_ENV'] != 'production'5080 my_host = $http_host.split(/:|\//)[-2]5081 # => get URL server5082 my_url_host = SpinFileServer.find_by_server_name('127.0.0.1:18881')5083 if my_url_host.present?5084 my_host = my_url_host[:spin_url_server_name]5085 end5086 # if my_host.length == 25087 rethash[:redirect_uri] = my_host + "/filemanager/uploader/upload_proc?fmargs=" + fmargs5088 else5089 rethash[:redirect_uri] = '/secret_files/uploader/upload_proc?fmargs=' + fmargs5090 end5091 # my_host = $http_host.split(/:|\//)[-2]5092 # if my_host.length == 25093 # rethash[:redirect_uri] = "http://#{my_host[0]}:18881/filemanager/uploader/upload_proc?fmargs=" + fmargs5094 # else5095 # rethash[:redirect_uri] = '/secret_files/uploader/upload_proc?fmargs=' + fmargs5096 # end5097 rethash[:success] = true5098 FolderDatum.set_folder_dirty my_session_id, upload_dir_key5099 rescue OpenSSL::PKey::RSAError5100 if retry_encrypt > 05101 retry_encrypt -= 15102 sleep(AR_RETRY_WAIT_MSEC)5103 throw :encrypt_again_85104 end5105 rethash[:success] = false5106 rethash[:status] = ERROR_UPLOAD_FILE5107 rethash[:errors] = 'Failed to generate encrypted URL by OpenSSL::PKey::RSA'5108 rescue5109 if retry_encrypt > 05110 retry_encrypt -= 15111 sleep(AR_RETRY_WAIT_MSEC)5112 throw :encrypt_again_85113 end5114 rethash[:success] = false5115 rethash[:status] = ERROR_UPLOAD_FILE5116 rethash[:errors] = 'Failed to generate encrypted urlsafe URL'5117 end5118 }5119 # pdata = my_session_id + vfile_key + my_upload_file_name5120 # # make encrypted data5121 # file_manager_params = Security.public_key_encrypt2 rsa_key_pem, pdata5122 # # and encode into base645123 # # fmargs = file_manager_params5124 # fmargs = Security.urlsafe_encode_base64(file_manager_params[:length].to_s + file_manager_params[:data])5125 # # then URI escape5126 # # uri_fmargs = Security.escape_base64 fmargs5127 # # rethash[:redirect_uri] = 'http://192.168.2.119:18080/secret_files/uploader/upload_proc?fmargs=' + fmargs5128 # my_host = $http_host.split(/:/)5129 # if $http_port != 805130 # rethash[:redirect_uri] = "http://#{my_host[0]}:18881/filemanager/uploader/upload_proc?fmargs=" + fmargs5131 # else5132 # rethash[:redirect_uri] = '/secret_files/uploader/upload_proc?fmargs=' + fmargs5133 # end5134 # rethash[:success] = true5135 # # folder_key = SpinLocationManager.get_parent_key(delete_file_key)5136 # FolderDatum.has_updated(upload_sid, upload_dir_key, NEW_CHILD, true)5137 # FolderDatum.set_folder_dirty upload_sid, upload_dir_key5138 when 'search_files'5139 rethash[:success] = true5140 # set folder privilege5141 conditions = Hash.new5142 search_sid = my_session_id5143 location = 'folder_a'5144 if paramshash[:cont_location].present?5145 location = paramshash[:cont_location]5146 end5147 search_hash_key = paramshash[:hash_key]5148 search_folder = FolderDatum.select("spin_node_hashkey").find_by_session_id_and_hash_key_and_cont_location search_sid, search_hash_key, location5149 if search_folder.blank?5150 rethash[:success] = false5151 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST5152 rethash[:errors] = 'No folder record is found at search_files'5153 return rethash5154 end5155 conditions[:target_file_name] = paramshash[:target_file_name]5156 if paramshash[:hash_key].length == 05157 # cwdrec = DatabaseUtility::SessionUtility.get_current_directory(search_sid, location)5158 # conditions[:folder_hash_key] = SpinLocationManager.get_parent_key(cwdrec, NODE_DIRECTORY)5159 conditions[:folder_hash_key] = DatabaseUtility::SessionUtility.get_current_directory(search_sid, location)5160 else5161 conditions[:folder_hash_key] = search_folder[:spin_node_hashkey]5162 end5163 if paramshash[:target_subfolder].present?5164 conditions[:target_subfolder] = paramshash[:target_subfolder] # => bool : indicates search subfolders if true, or this folder only5165 end5166 if paramshash[:target_subfolder].present?5167 conditions[:folder_name] = paramshash[:text]5168 end5169 if paramshash[:target_modifier].present?5170 conditions[:target_modifier] = paramshash[:target_modifier]5171 end5172 if paramshash[:target_creator].present?5173 conditions[:target_creator] = paramshash[:target_creator]5174 end5175 if paramshash[:locked_by_me].present?5176 conditions[:locked_by_me] = paramshash[:locked_by_me] # => bool5177 end5178 if paramshash[:checked_out_by_me].present?5179 conditions[:checked_out_by_me] = paramshash[:checked_out_by_me] # => bool5180 end5181 if paramshash[:target_created_by_me].present?5182 conditions[:target_created_by_me] = paramshash[:target_created_by_me] # => bool5183 end5184 if paramshash[:target_modified_by_me].present?5185 conditions[:target_modified_by_me] = paramshash[:target_modified_by_me] # => bool5186 end5187 if paramshash[:cont_location].present?5188 conditions[:cont_location] = paramshash[:cont_location]5189 end5190 if paramshash[:target_modified_date_begin].present?5191 conditions[:target_modified_date_begin] = paramshash[:target_modified_date_begin] # => yyyy-mm-ddThh:mm:ss5192 end5193 if paramshash[:target_modified_date_end].present?5194 conditions[:target_modified_date_end] = paramshash[:target_modified_date_end] # => yyyy-mm-ddThh:mm:ss5195 end5196 if paramshash[:target_created_date_begin].present?5197 conditions[:target_created_date_begin] = paramshash[:target_created_date_begin] # => yyyy-mm-ddThh:mm:ss5198 end5199 if paramshash[:target_created_date_end].present?5200 conditions[:target_created_date_end] = paramshash[:target_created_date_end] # => yyyy-mm-ddThh:mm:ss5201 end5202 if paramshash[:target_file_size_min].present?5203 conditions[:target_file_size_min] = paramshash[:target_file_size_min] # => B(default),KB,MB,GB,TB...5204 end5205 if paramshash[:target_file_size_max].present?5206 conditions[:target_file_size_max] = paramshash[:target_file_size_max] # => B(default),KB,MB,GB,TB...5207 end5208 if paramshash[:target_check_str_size].present?5209 conditions[:target_check_str_size] = paramshash[:target_check_str_size]5210 end5211 if paramshash[:target_check_str_char].present?5212 conditions[:target_check_str_char] = paramshash[:target_check_str_char]5213 end5214 # get numbered property hashes5215 list_optional_conditions = Array.new5216 hash_params = Hash.new5217 if paramshash[:property].present? and paramshash[:property].length > 05218 paramshash[:property].each {|value|5219 # if /[0-9]+/ =~ key # => number5220 list_optional_conditions.append value # => value is a hash { :option_name => opname, :field_name => fldname, :value => val }5221 # end5222 }5223 end5224 # search files5225 searched_files = SearchConditionDatum.search_files(search_sid, conditions, list_optional_conditions)5226 if searched_files.length >= 05227 rethash[:success] = true5228 rethash[:status] = (searched_files.length == 0 ? INFO_SEARCH_FILE_RESULT_IS_EMPTY : INFO_SEARCH_FILE_RESULT_IS_NOT_EMPTY)5229 rethash[:result] = searched_files5230 FileDatum.fill_search_file_list_data_table search_sid, searched_files, conditions[:folder_hash_key], 'search_result'5231 else5232 rethash[:success] = false5233 end5234 when 'expand_folder' # => ,'expand_target_folder'5235 f = FolderDatum.find_by_hash_key paramshash[:hash_key]5236 if f.present?5237 rethash = FolderDatum.set_expand_folder my_session_id, paramshash[:cont_location], f[:spin_node_hashkey], paramshash[:domain_hash_key]5238 # if rethash[:status] == STAT_DATA_NOT_LOADED_YET5239 # FolderDatum.load_folder_recs(my_session_id, f[:spin_node_hashkey], paramshash[:domain_hash_key], paramshash[:cont_location])5240 # end5241 # if rethash[:isDirty]5242 # FolderDatum.fill_folders(my_session_id, paramshash[:cont_location], paramshash[:domain_hash_key])5243 # # else5244 # # FolderDatum.fill_folders(my_session_id, paramshash[:cont_location], f[:spin_node_hashkey])5245 # end5246 # FolderDatum.select_folder my_session_id, f[:spin_node_hashkey], paramshash[:cont_location], paramshash[:domain_hash_key]5247 # if rethash[:status] != STAT_DATA_ALREADY_LOADED5248 # if rethash[:success]5249 # SessionManager.set_location_dirty my_session_id, paramshash[:cont_location]5250 # end5251 # end5252 # else5253 # rethash[:success] = false5254 # end5255 end5256 # rethash[:success] = truespin5257 when 'open_folder'5258 hk = ''5259 user_agent = $http_user_agent5260 if /HTTP_Request2.+/ =~ user_agent # => PHP API5261 hk = paramshash[:hash_key]5262 else # => from UI5263 file_data_rec = FileDatum.find_by_hash_key paramshash[:hash_key]5264 unless file_data_rec.blank?5265 hk = file_data_rec[:spin_node_hashkey]5266 else5267 rethash = {:success => false, :status => ERROR_FAILED_TO_OPEN_FOLDER, :errors => 'Failed to open folder'}5268 return rethash5269 # hk = paramshash[:hash_key]5270 end5271 #hk = file_data_rec[:spin_node_hashkey]5272 end5273 parent_folder = file_data_rec[:folder_hash_key]5274 fd = FolderDatum.find_by(session_id: my_session_id, spin_node_hashkey: hk, cont_location: paramshash[:cont_location])5275 if fd.blank?5276 # loaded_recs = FolderDatum.load_folder_recs(my_session_id, hk, selected_domain, parent_folder, paramshash[:cont_location], DEPTH_TO_TRAVERSE, SessionManager.get_last_session(my_session_id))5277 # if loaded_recs <= 05278 rethash = {:success => false, :status => ERROR_FAILED_TO_OPEN_FOLDER, :errors => 'Failed to open folder'}5279 return rethash5280 # end5281 end5282 parent_is_expanded = FolderDatum.is_expanded_folder(my_session_id, paramshash[:cont_location], parent_folder)5283 selected_domain = SessionManager.get_selected_domain(my_session_id, paramshash[:cont_location])5284 unless parent_is_expanded5285 reth = FolderDatum.set_expand_folder(my_session_id, paramshash[:cont_location], parent_folder, selected_domain)5286 end5287 # DomainDatum.set_domain_dirty(my_session_id, paramshash[:cont_location], fd[:domain_hash_key])5288 # is_dirty = DomainDatum.is_dirty_domain(my_session_id, paramshash[:cont_location], selected_domain)5289 # is_dirty = FolderDatum.is_dirty_folder_tree my_session_id, paramshash[:cont_location], fd[:parent_hash_key] # current_partial_root = self.find_by_session_id_and_domain_hash_key_and_cont_location_and_is_partial_root sid, target_domain, cont_location, true5290 # FolderDatum.reset_partial_root(my_session_id, paramshash[:cont_location], selected_domain)5291 # if is_dirty5292 # FolderDatum.fill_folders(my_session_id, paramshash[:cont_location], selected_domain, parent_folder)5293 # else5294 # FolderDatum.load_folder_recs(my_session_id, parent_folder, selected_domain, paramshash[:cont_location], 3)5295 # FolderDatum.fill_folders(my_session_id, paramshash[:cont_location], selected_domain)5296 FolderDatum.fill_folders(my_session_id, paramshash[:cont_location], selected_domain, parent_folder)5297 # end5298 if FolderDatum.select_folder(my_session_id, hk, paramshash[:cont_location], selected_domain)5299 # is_dirty = FolderDatum.is_dirty_folder_tree(my_session_id, paramshash[:cont_location], parent_folder) # current_partial_root = self.find_by_session_id_and_domain_hash_key_and_cont_location_and_is_partial_root sid, target_domain, cont_location, true5300 rethash = {:success => true, :status => STAT_DATA_ALREADY_LOADED, :isDirty => is_dirty, :folder_node => hk, :parent_node => parent_folder}5301 else5302 rethash = {:success => false, :status => ERROR_FAILED_TO_OPEN_FOLDER, :errors => 'Failed to open folder'}5303 end5304 # rethash = {:success => true, :status => STAT_DATA_ALREADY_LOADED, :isDirty => is_dirty, :folder_node => hk, :parent_node => parent_folder}5305 # else5306 # reth = FolderDatum.set_expand_folder(my_session_id, paramshash[:cont_location], parent_folder, selected_domain)5307 # # DomainDatum.set_domain_dirty(my_session_id, paramshash[:cont_location], paramshash[:domain_hash_key])5308 # # is_dirty = FolderDatum.is_dirty_folder_tree my_session_id, paramshash[:cont_location], fd[:parent_hash_key] # current_partial_root = self.find_by_session_id_and_domain_hash_key_and_cont_location_and_is_partial_root sid, target_domain, cont_location, true5309 # # is_dirty = DomainDatum.is_dirty_domain(my_session_id, paramshash[:cont_location], paramshash[:domain_hash_key])5310 # # fk = FolderDatum.select_folder my_session_id, hk, paramshash[:cont_location], selected_domain5311 # # if fk == true5312 # # if reth[:isDirty]5313 # # FolderDatum.fill_folders(my_session_id, paramshash[:cont_location], selected_domain)5314 # # else5315 # ## FolderDatum.fill_folders(my_session_id, paramshash[:cont_location], selected_domain)5316 # # FolderDatum.fill_folders(my_session_id, paramshash[:cont_location], selected_domain, parent_folder)5317 # # end5318 # # rethash = { :success => true, :status => STAT_DATA_ALREADY_LOADED, :isDirty => false, :parent_node => parent_folder }5319 # rethash = {:success => true, :status => STAT_DATA_NOT_LOADED_YET, :isDirty => true, :parent_node => parent_folder}5320 # end5321 # rethash[:success] = true5322 when 'expand_node'5323 f = FolderDatum.find_by_hash_key paramshash[:hash_key]5324 if f.blank?5325 rethash[:success] = false5326 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST5327 rethash[:errors] = 'No folder record is found at expand_node'5328 return rethash5329 end5330 rethash = FolderDatum.set_expand_folder my_session_id, paramshash[:cont_location], f[:spin_node_hashkey], paramshash[:domain_hash_key]5331 if rethash[:success]5332 SessionManager.set_location_dirty my_session_id, paramshash[:cont_location]5333 end5334 if rethash[:success]5335 FolderDatum.fill_folders my_session_id, paramshash[:cont_location]5336 end5337 # rethash[:success] = true5338 # when 'expand_target_folder'5339 # f = FolderDatum.find_by_hash_key paramshash[:target_hash_key]5340 ## f = FolderDatum.find_by_hash_key paramshash[:hash_key]5341 # if f != nil5342 # rethash = FolderDatum.set_expand_folder my_session_id, paramshash[:target_cont_location], f[:spin_node_hashkey], paramshash[:domain_hash_key]5343 # FolderDatum.select_folder my_session_id, f[:spin_node_hashkey], paramshash[:target_cont_location]5344 # if rethash[:status] != STAT_DATA_ALREADY_LOADED5345 # if rethash[:success]5346 # SessionManager.set_location_dirty my_session_id, paramshash[:target_cont_location]5347 # end5348 # end5349 # else5350 # rethash[:success] = false5351 # end5352 ## rethash = FolderDatum.set_expand_folder my_session_id, paramshash[:target_cont_location], f[:spin_node_hashkey]5353 ## # rethash = FolderDatum.set_expand_folder my_session_id, paramshash[:target_cont_location], paramshash[:target_hash_key]5354 ## if rethash[:success]5355 ## SessionManager.set_location_dirty my_session_id, paramshash[:target_cont_location]5356 ## end5357 ## if rethash[:success]5358 ## FolderDatum.fill_folders my_session_id, paramshash[:target_cont_location]5359 ## end5360 # # rethash[:success] = true5361 when 'collapse_folder', 'collapse_target_folder'5362 f = FolderDatum.find_by_hash_key paramshash[:hash_key]5363 if f.blank?5364 rethash[:success] = false5365 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST5366 rethash[:errors] = 'No folder record is found at collapse_folder'5367 return rethash5368 end5369 rethash = FolderDatum.set_collapse_folder my_session_id, paramshash[:cont_location], f[:spin_node_hashkey], paramshash[:domain_hash_key]5370 # rethash[:success] = true5371 # when 'collapse_target_folder'5372 # f = FolderDatum.find_by_hash_key paramshash[:target_hash_key]5373 # if f != nil5374 # rethash = FolderDatum.set_collapse_folder my_session_id, paramshash[:target_cont_location], f[:spin_node_hashkey]5375 # else5376 # rethash[:success] = false5377 # end5378 # # rethash = FolderDatum.set_collapse_folder my_session_id, paramshash[:target_cont_location], paramshash[:target_hash_key]5379 # # rethash[:success] = true5380 when 'logout'5381 current_session = paramshash['session_id']5382 # ac = Hash.new5383 cs = SpinSession.find_by_spin_session_id current_session5384 if cs.blank?5385 SpinSession.transaction do5386 my_addr = get_my_address();5387 #rethash[:initial_uri]="http://localhost:3000/secret_files_login/";5388 rethash[:initial_uri]="http://"+my_addr+":3000/secret_files/";5389 #rethash[:initial_uri] = @appl_conf["protocol"] + "://" + @appl_conf["host"] + ( @appl_conf["port"] != 0 ? ( ":" + @appl_conf["port"].to_s ) : "" ) + @appl_conf["start_url"]5390 end # => end of transaction5391 rethash[:success] = false5392 rethash[:status] = ERROR_SESSION_ID_MISSING5393 rethash[:errors] = "no session id"5394 else5395 initial_uri = cs[:initial_uri]5396 # ac = JSON.parse cs[:spin_session_conf]s5397 cs.spin_last_logout = Time.now5398 cs.save5399 rethash[:initial_uri] = initial_uri5400 rethash[:success] = true5401 end5402 #rethash[:success] = true5403 when 'createUser'5404 # coord_value is an array : [x,y,prx,v,hk]5405 # check session id5406 sid = nil5407 my_session_id = paramshash[:session_id]5408 if my_session_id == nil5409 rethash[:success] = false5410 rethash[:status] = ERROR_SESSION_ID_MISSING5411 rethash[:errors] = "no session id"5412 return rethash5413 else5414 if SessionManager.auth_spin_session my_session_id5415 sid = my_session_id5416 else5417 rethash[:success] = false5418 rethash[:status] = ERROR_INVALID_SESSION_ID5419 rethash[:errors] = "session id is invalid"5420 return rethash5421 end5422 end # => end of session id check5423 unless paramshash[:formData].present?5424 rethash[:success] = false5425 rethash[:status] = ERROR_FORM_DATA_MISSING5426 rethash[:errors] = "form data for createUser are missing"5427 return rethash5428 end5429 if paramshash[:cont_location].present?5430 location = paramshash[:cont_location]5431 else5432 location = LOCATION_ANY5433 end5434 rethash = SpinUser.create_user_from_form sid, paramshash[:formData], paramshash[:is_sticky]5435 # rethash = SpinUser.add_user sid, paramshash[:formData]['user_id'], paramshash[:formData]['user_id'], paramshash[:formData]['user_id']5436 # cwd = DatabaseUtility::SessionUtility.set_current_directory_path(sid, vpath, location)5437 # if cwd == nil5438 # rethash[:success] = false5439 # rethash[:status] = ERROR_FAILED_TO_SET_CURRENT_DIRECTORY5440 # rethash[:errors] = "æå®ããããã£ã¬ã¯ããªãã¹ã«ç§»ååºæ¥ã¾ããã§ãã"5441 # else5442 # rethash[:success] = true5443 # rethash[:status] = INFO_SET_CURRENT_DIRECTORY_SUCCESS5444 # rethash[:result] = cwd5445 # end5446 when 'createTemporaryUser'5447 # coord_value is an array : [x,y,prx,v,hk]5448 # check session id5449 sid = nil5450 my_session_id = paramshash[:session_id]5451 if my_session_id == nil5452 rethash[:success] = false5453 rethash[:status] = ERROR_SESSION_ID_MISSING5454 rethash[:errors] = "no session id"5455 return rethash5456 else5457 if SessionManager.auth_spin_session my_session_id5458 sid = my_session_id5459 else5460 rethash[:success] = false5461 rethash[:status] = ERROR_INVALID_SESSION_ID5462 rethash[:errors] = "session id is invalid"5463 return rethash5464 end5465 end # => end of session id check5466 if paramshash[:formData] == nil5467 rethash[:success] = false5468 rethash[:status] = ERROR_FORM_DATA_MISSING5469 rethash[:errors] = "form data for createUser are missing"5470 return rethash5471 end5472 if paramshash[:cont_location].present?5473 location = paramshash[:cont_location]5474 else5475 location = LOCATION_ANY5476 end5477 rethash = SpinUser.create_user_from_form sid, paramshash[:formData], true, false5478 # rethash = SpinUser.add_user sid, paramshash[:formData]['user_id'], paramshash[:formData]['user_id'], paramshash[:formData]['user_id']5479 # cwd = DatabaseUtility::SessionUtility.set_current_directory_path(sid, vpath, location)5480 # if cwd == nil5481 # rethash[:success] = false5482 # rethash[:status] = ERROR_FAILED_TO_SET_CURRENT_DIRECTORY5483 # rethash[:errors] = "æå®ããããã£ã¬ã¯ããªãã¹ã«ç§»ååºæ¥ã¾ããã§ãã"5484 # else5485 # rethash[:success] = true5486 # rethash[:status] = INFO_SET_CURRENT_DIRECTORY_SUCCESS5487 # rethash[:result] = cwd5488 # end5489 when 'add_user'5490 # coord_value is an array : [x,y,prx,v,hk]5491 # check session id5492 sid = nil5493 my_session_id = paramshash[:session_id]5494 if my_session_id == nil5495 rethash[:success] = false5496 rethash[:status] = ERROR_SESSION_ID_MISSING5497 rethash[:errors] = "no session id"5498 return rethash5499 else5500 if SessionManager.auth_spin_session my_session_id5501 sid = my_session_id5502 else5503 rethash[:success] = false5504 rethash[:status] = ERROR_INVALID_SESSION_ID5505 rethash[:errors] = "session id is invalid"5506 return rethash5507 end5508 end # => end of session id check5509 if paramshash[:cont_location].present?5510 location = paramshash[:cont_location]5511 else5512 location = LOCATION_ANY5513 end5514 rethash = SpinUser.add_user sid, paramshash[:user_id], paramshash[:group_id], paramshash[:user_name], paramshash[:password], paramshash[:group_editor], paramshash[:activated]5515 when 'updateUser'5516 # coord_value is an array : [x,y,prx,v,hk]5517 # check session id5518 sid = nil5519 my_session_id = paramshash[:session_id]5520 if my_session_id == nil5521 rethash[:success] = false5522 rethash[:status] = ERROR_SESSION_ID_MISSING5523 rethash[:errors] = "no session id"5524 return rethash5525 else5526 if SessionManager.auth_spin_session my_session_id5527 sid = my_session_id5528 else5529 rethash[:success] = false5530 rethash[:status] = ERROR_INVALID_SESSION_ID5531 rethash[:errors] = "session id is invalid"5532 return rethash5533 end5534 end # => end of session id check5535 if paramshash[:formData] == nil5536 rethash[:success] = false5537 rethash[:status] = ERROR_FORM_DATA_MISSING5538 rethash[:errors] = "form data for createUser are missing"5539 return rethash5540 end5541 if paramshash[:cont_location].present?5542 location = paramshash[:cont_location]5543 else5544 location = LOCATION_ANY5545 end5546 rethash = SpinUser.update_user_from_form sid, paramshash[:formData]5547 when 'selectUser'5548 # coord_value is an array : [x,y,prx,v,hk]5549 # check session id5550 sid = nil5551 my_session_id = paramshash[:session_id]5552 if my_session_id == nil5553 rethash[:success] = false5554 rethash[:status] = ERROR_SESSION_ID_MISSING5555 rethash[:errors] = "no session id"5556 return rethash5557 else5558 if SessionManager.auth_spin_session my_session_id5559 sid = my_session_id5560 else5561 rethash[:success] = false5562 rethash[:status] = ERROR_INVALID_SESSION_ID5563 rethash[:errors] = "session id is invalid"5564 return rethash5565 end5566 end # => end of session id check5567 if paramshash[:formData] == nil5568 rethash[:success] = false5569 rethash[:status] = ERROR_FORM_DATA_MISSING5570 rethash[:errors] = "form data for createUser are missing"5571 return rethash5572 end5573 if paramshash[:cont_location].present?5574 location = paramshash[:cont_location]5575 else5576 location = LOCATION_ANY5577 end5578 #l_offset = params[:start].to_i5579 #l_limit = params[:limit].to_i5580 disp_user_list_obj = SpinUser.select_user_from_form sid, paramshash[:formData]5581 #rethash[:success] = disp_user_list_obj[:success]5582 #rethash[:status] = disp_user_list_obj[:status]5583 rethash = disp_user_list_obj5584 when 'deleteUser'5585 # coord_value is an array : [x,y,prx,v,hk]5586 # check session id5587 sid = nil5588 my_session_id = paramshash[:session_id]5589 if my_session_id == nil5590 rethash[:success] = false5591 rethash[:status] = ERROR_SESSION_ID_MISSING5592 rethash[:errors] = "no session id"5593 return rethash5594 else5595 if SessionManager.auth_spin_session my_session_id5596 sid = my_session_id5597 else5598 rethash[:success] = false5599 rethash[:status] = ERROR_INVALID_SESSION_ID5600 rethash[:errors] = "session id is invalid"5601 return rethash5602 end5603 end # => end of session id check5604 unless paramshash[:formData].present?5605 rethash[:success] = false5606 rethash[:status] = ERROR_FORM_DATA_MISSING5607 rethash[:errors] = "form data for createUser are missing"5608 return rethash5609 end5610 if paramshash[:cont_location].present?5611 location = paramshash[:cont_location]5612 else5613 location = LOCATION_ANY5614 end5615 rethash = SpinUser.delete_user_from_form sid, paramshash[:formData]5616 when 'getUserInfo'5617 # coord_value is an array : [x,y,prx,v,hk]5618 # check session id5619 sid = nil5620 my_session_id = paramshash[:session_id]5621 if my_session_id == nil5622 rethash[:success] = false5623 rethash[:status] = ERROR_SESSION_ID_MISSING5624 rethash[:errors] = "no session id"5625 return rethash5626 else5627 if SessionManager.auth_spin_session my_session_id5628 sid = my_session_id5629 else5630 rethash[:success] = false5631 rethash[:status] = ERROR_INVALID_SESSION_ID5632 rethash[:errors] = "session id is invalid"5633 return rethash5634 end5635 end # => end of session id check5636 #if paramshash[:form_data] == nil5637 # rethash[:success] = false5638 # rethash[:status] = ERROR_FORM_DATA_MISSING5639 # rethash[:errors] = "form data for createUser are missing"5640 # return rethash5641 #end5642 unless paramshash[:user_name].present?5643 rethash[:success] = false5644 rethash[:status] = ERROR_SYSADMIN_FAILED_TO_GET_USER_INFO5645 rethash[:errors] = "user_name is null"5646 return rethash5647 end5648 login_user_uid = SessionManager.get_uid(sid, true)5649 login_uname = SpinUser.get_uname(login_user_uid);5650 spin_uname = paramshash[:user_name]5651 if login_uname != spin_uname and login_user_uid != 05652 rethash[:success] = false5653 rethash[:status] = ERROR_SYSADMIN_FAILED_TO_GET_USER_INFO5654 rethash[:errors] = "Administrator and LoginUser can perform"5655 return rethash5656 end5657 rethash[:success] = true5658 rethash[:status] = INFO_SYSADMIN_GET_USER_INFO_SUCCESS5659 #uid = SpinUser.get_uid spin_uname5660 rtn = SpinUser.readonly.select("spin_uid,spin_gid,spin_login_directory").find_by_spin_uname spin_uname5661 if rtn.blank?5662 rethash[:success] = false5663 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST5664 rethash[:errors] = 'No user record is found at getUserInfo'5665 return rethash5666 end5667 rethash[:result] = {:spin_uid => rtn[:spin_uid], :spin_gid => rtn[:spin_gid], :spin_login_directory => rtn[:spin_login_directory]}5668 return rethash5669 when 'getVpath'5670 # coord_value is an array : [x,y,prx,v,hk]5671 # check session id5672 sid = nil5673 my_session_id = paramshash[:session_id]5674 if my_session_id == nil5675 rethash[:success] = false5676 rethash[:status] = ERROR_SESSION_ID_MISSING5677 rethash[:errors] = "no session id"5678 return rethash5679 else5680 if SessionManager.auth_spin_session my_session_id5681 sid = my_session_id5682 else5683 rethash[:success] = false5684 rethash[:status] = ERROR_INVALID_SESSION_ID5685 rethash[:errors] = "session id is invalid"5686 return rethash5687 end5688 end # => end of session id check5689 #if paramshash[:form_data] == nil5690 # rethash[:success] = false5691 # rethash[:status] = ERROR_FORM_DATA_MISSING5692 # rethash[:errors] = "form data for createUser are missing"5693 # return rethash5694 #end5695 unless paramshash[:node_hash_key].present?5696 rethash[:success] = false5697 rethash[:status] = ERROR_FAILED_TO_GET_VPATH5698 rethash[:errors] = "node_hash_key is null"5699 return rethash5700 end5701 login_user_uid = SessionManager.get_uid(sid, true)5702 login_uname = SpinUser.get_uname(login_user_uid);5703 spin_uname = paramshash[:user_name]5704 if login_uname != spin_uname and login_user_uid != 05705 rethash[:success] = false5706 rethash[:status] = ERROR_FAILED_TO_GET_VPATH5707 rethash[:errors] = "Administrator and LoginUser can perform"5708 return rethash5709 end5710 rethash[:success] = true5711 rethash[:status] = INFO_GET_VPATH_SUCCESS5712 node_hash_key = paramshash[:node_hash_key]5713 virtual_path = SpinNode.get_vpath(node_hash_key)5714 rethash[:result] = {:virtual_path => virtual_path}5715 return rethash5716 when 'create_my_group'5717 # coord_value is an array : [x,y,prx,v,hk]5718 # check session id5719 sid = nil5720 my_session_id = paramshash[:session_id]5721 if my_session_id == nil5722 rethash[:success] = false5723 rethash[:status] = ERROR_SESSION_ID_MISSING5724 rethash[:errors] = "no session id"5725 return rethash5726 else5727 if SessionManager.auth_spin_session my_session_id5728 sid = my_session_id5729 else5730 rethash[:success] = false5731 rethash[:status] = ERROR_INVALID_SESSION_ID5732 rethash[:errors] = "session id is invalid"5733 return rethash5734 end5735 end # => end of session id check5736 my_new_group_name = ''5737 if paramshash[:new_my_group] == nil5738 rethash[:success] = false5739 rethash[:status] = ERROR_GROUP_NAME_MISSING5740 rethash[:errors] = "no new group name"5741 return rethash5742 end # => end of session id check5743 my_new_group_name = paramshash[:new_my_group]5744 if paramshash[:cont_location].present?5745 location = paramshash[:cont_location]5746 else5747 location = LOCATION_ANY5748 end5749 # gid5750 my_new_group_id = ANY_GID # => -15751 if paramshash[:group_id].present? and paramshash[:group_id] != ''5752 my_new_group_id = paramshash[:group_id]5753 end5754 my_new_group_description = '' # => empty5755 if paramshash[:new_group_description] != nil5756 my_new_group_description = paramshash[:new_group_description]5757 end5758 rethash = SpinGroup.create_group my_session_id, my_new_group_name, my_new_group_id, my_new_group_description5759 # rethash = SpinUser.add_user sid, paramshash[:formData]['user_id'], paramshash[:formData]['user_id'], paramshash[:formData]['user_id']5760 # cwd = DatabaseUtility::SessionUtility.set_current_directory_path(sid, vpath, location)5761 # if cwd == nil5762 # rethash[:success] = false5763 # rethash[:status] = ERROR_FAILED_TO_SET_CURRENT_DIRECTORY5764 # rethash[:errors] = "æå®ããããã£ã¬ã¯ããªãã¹ã«ç§»ååºæ¥ã¾ããã§ãã"5765 # else5766 # rethash[:success] = true5767 # rethash[:status] = INFO_SET_CURRENT_DIRECTORY_SUCCESS5768 # rethash[:result] = cwd5769 # end5770 when 'select_my_group'5771 # coord_value is an array : [x,y,prx,v,hk]5772 # check session id5773 sid = nil5774 my_session_id = paramshash[:session_id]5775 if my_session_id == nil5776 rethash[:success] = false5777 rethash[:status] = ERROR_SESSION_ID_MISSING5778 rethash[:errors] = "no session id"5779 return rethash5780 else5781 if SessionManager.auth_spin_session my_session_id5782 sid = my_session_id5783 else5784 rethash[:success] = false5785 rethash[:status] = ERROR_INVALID_SESSION_ID5786 rethash[:errors] = "session id is invalid"5787 return rethash5788 end5789 end # => end of session id check5790 my_selected_group_name = ''5791 if paramshash[:selected_group] == nil5792 rethash[:success] = false5793 rethash[:status] = ERROR_SELECTED_GROUP_MISSING5794 rethash[:errors] = "no selected group data"5795 return rethash5796 end # => end of session id check5797 my_selected_group = paramshash[:selected_group]5798 my_selected_group_name = my_selected_group[:group_name]5799 retgid = SpinGroup.select_group my_session_id, my_selected_group_name5800 if retgid < 05801 rethash[:success] = false5802 rethash[:status] = ERROR_SELECTED_GROUP_MISSING5803 rethash[:errors] = "no selected group data"5804 return rethash5805 else5806 rethash[:success] = true5807 rethash[:status] = INFO_SELECT_GROUP_SUCCESS5808 rethash[:result] = retgid5809 end5810 when 'key_to_location'5811 # coord_value is an array : [x,y,prx,v,hk]5812 # check session id5813 sid = nil5814 if my_session_id == nil5815 rethash[:success] = false5816 rethash[:status] = false5817 rethash[:errors] = "no session id"5818 return rethash5819 else5820 if SessionManager.auth_spin_session my_session_id5821 sid = my_session_id5822 else5823 rethash[:success] = false5824 rethash[:status] = false5825 rethash[:errors] = "session id is not valid"5826 return rethash5827 end5828 end # => end of session id check5829 flag_make_dir_if_not_exeits = true5830 user_agent = $http_user_agent5831 hk = nil5832 if /HTTP_Request2.+/ =~ user_agent # => PHP API5833 hk = paramshash[:hash_key]5834 else # => from UI5835 file_data_rec = FileDatum.find_by_hash_key paramshash[:hash_key]5836 if file_data_rec.present? #COnfigured at 20150416 by imai5837 hk = file_data_rec[:spin_domain_hash_key]5838 else5839 hk = paramshash[:hash_key]5840 end5841 end5842 # if paramshash[:hash_key]5843 # hk = paramshash[:hash_key]5844 # else5845 # hk = nil5846 # end5847 if paramshash[:node_type].present?5848 nt = paramshash[:node_type]5849 else5850 nt = NODE_DIRECTORY5851 end5852 coord_value = SpinLocationManager.key_to_location hk, nt5853 if coord_value == [-1, -1, -1, -1]5854 rethash[:success] = false5855 rethash[:status] = false5856 rethash[:errors] = coord_value.to_s5857 else5858 rethash[:success] = true5859 rethash[:status] = true5860 rethash[:result] = coord_value5861 end5862 when 'get_vfile_attributes'5863 # coord_value is an array : [x,y,prx,v,hk]5864 # check session id5865 sid = nil5866 if my_session_id == nil5867 rethash[:success] = false5868 #rethash[:status] = false5869 rethash[:status] = ERROR_SESSION_ID_MISSING5870 rethash[:errors] = "no session id"5871 return rethash5872 else5873 if SessionManager.auth_spin_session my_session_id5874 sid = my_session_id5875 else5876 rethash[:success] = false5877 #rethash[:status] = false5878 rethash[:status] = ERROR_SESSION_ID_MISSING5879 rethash[:errors] = "session id is not valid"5880 return rethash5881 end5882 end # => end of session id check5883 if paramshash[:virtual_path].present?5884 SpinNode.transaction do5885 # SpinNode.find_by_sql('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;')5886 virtual_path = paramshash[:virtual_path]5887 nodes = SpinNode.where(["virtual_path = ? AND node_type <> ? AND latest = true AND in_trash_flag = false AND is_void = false", virtual_path, NODE_THUMBNAIL]).order("node_version DESC")5888 node = nil5889 if nodes.blank?5890 rethash[:success] = false5891 rethash[:status] = ERROR_FAILED_TO_GET_ATTRIBUTES5892 rethash[:errors] = "Specified node doesn\'t exist"5893 return rethash5894 else5895 node = nodes[0]5896 end5897 #node = SpinNode.find(["virtual_path = ? AND node_type <> ?",virtual_path,NODE_THUMBNAIL]).order("node_version DESC")5898 # node = SpinNode.where(["spin_node_tree = 0 AND virtual_path = ? AND in_trash_flag = false AND is_void = false",virtual_path]).order("node_version DESC")5899 if node.blank?5900 # unless nodes.length > 05901 rethash[:success] = false5902 rethash[:status] = ERROR_FAILED_TO_GET_ATTRIBUTES5903 rethash[:errors] = "Specified node doesn\'t exist"5904 else5905 # node = nodes[0]5906 # rethash[:success] = true5907 # rethash[:status] = INFO_GET_ATTRIBUTES_SUCCESS5908 mt = 05909 ct = 05910 ntree = 05911 unless node[:mtime].present?5912 mt = 05913 else5914 mt = node[:mtime].to_i5915 end5916 unless node[:ctime].present?5917 ct = 05918 else5919 ct = node[:ctime].to_i5920 end5921 unless node[:spin_node_tree].present?5922 ntree = 05923 else5924 ntree = node[:spin_node_tree].to_i5925 end5926 ns_upper = (node[:node_size_upper].present? ? node[:node_size_upper] : 0)5927 ns = (node[:node_size].present? ? node[:node_size] : 0)5928 vfile_size = (MAX_INTEGER + 1) * ns_upper + ns5929 ver = node[:node_version]5930 location_mapping = SpinLocationMapping.readonly.find_by_spin_node_tree_and_node_hash_key(ntree, node[:spin_node_hashkey])5931 has_thumbnail = true5932 if location_mapping.blank? or location_mapping[:thumbnail_location_path].present? == false5933 has_thumbnail = false5934 end5935 rethash[:success] = true5936 rethash[:status] = INFO_GET_ATTRIBUTES_SUCCESS5937 rethash[:result] = {:file_name => node[:node_name], :hash_key => node[:spin_node_hashkey], :mtime => mt, :ctime => ct, :size => vfile_size, :version => ver, :thumbnail => has_thumbnail, :is_pending => node[:is_pending]}5938 end5939 end # => end of ActiveRecord::Base.transaction5940 else # => virtual_path os nil!5941 rethash[:success] = false5942 rethash[:status] = ERROR_FAILED_TO_GET_ATTRIBUTES5943 rethash[:errors] = "Virtual path is not specified"5944 end5945 when 'xget_vfile_attributes'5946 # coord_value is an array : [x,y,prx,v,hk]5947 # check session id5948 sid = nil5949 if my_session_id == nil5950 rethash[:success] = false5951 rethash[:status] = false5952 rethash[:errors] = "no session id"5953 return rethash5954 else5955 if SessionManager.auth_spin_session my_session_id5956 sid = my_session_id5957 else5958 rethash[:success] = false5959 rethash[:status] = false5960 rethash[:errors] = "session id is not valid"5961 return rethash5962 end5963 end # => end of session id check5964 if paramshash[:virtual_path].present?5965 # ActiveRecord::Base.transaction do5966 virtual_path = paramshash[:virtual_path]5967 node_hashkey = SpinLocationManager.get_vpath_key(virtual_path)5968 if node_hashkey == nil5969 rethash[:success] = false5970 rethash[:status] = ERROR_FAILED_TO_GET_ATTRIBUTES5971 rethash[:errors] = "Virtual path doesn\'t exist or is invalid."5972 end5973 node = SpinNode.find_by_spin_node_hashkey node_hashkey5974 if node.blank?5975 rethash[:success] = false5976 rethash[:status] = ERROR_FAILED_TO_GET_ATTRIBUTES5977 rethash[:errors] = "Specified node doesn\'t exist"5978 else5979 rethash[:success] = true5980 rethash[:status] = INFO_GET_ATTRIBUTES_SUCCESS5981 mt = 05982 ct = 05983 unless node[:mtime]5984 mt = 05985 else5986 mt = node[:mtime].to_i5987 end5988 unless node[:ctime]5989 ct = 05990 else5991 ct = node[:ctime].to_i5992 end5993 ns_upper = (node[:node_size_upper] ? node[:node_size_upper] : 0)5994 ns = (node[:node_size] ? node[:node_size] : 0)5995 ver = node[:node_version]5996 rethash[:result] = {:file_name => node[:node_name], :hash_key => node_hashkey, :mtime => mt, :ctime => ct, :size => ((MAX_INTEGER + 1) * ns_upper + ns), :version => ver}5997 end5998 # end # => end of ActiveRecord::Base.transaction5999 else # => virtual_path os nil!6000 rethash[:success] = false6001 rethash[:status] = ERROR_FAILED_TO_GET_ATTRIBUTES6002 rethash[:errors] = "Virtual path is not specified"6003 end6004 when 'get_domain_info'6005 # coord_value is an array : [x,y,prx,v,hk]6006 # check session id6007 sid = nil6008 if my_session_id == nil6009 rethash[:success] = false6010 rethash[:status] = false6011 rethash[:errors] = "no session id"6012 return rethash6013 else6014 if SessionManager.auth_spin_session my_session_id6015 sid = my_session_id6016 else6017 rethash[:success] = false6018 rethash[:status] = false6019 rethash[:errors] = "session id is not valid"6020 return rethash6021 end6022 end # => end of session id check6023 if paramshash[:domain_disp_name].present?6024 domain_name = paramshash[:domain_disp_name]6025 elsif paramshash[:domain_name].present?6026 domain_name = paramshash[:domain_name]6027 else6028 domain_name = DOMAIN_ANY6029 end6030 domains = []6031 if domain_name == DOMAIN_ANY6032 domains = SpinDomain.where(["id > 0"])6033 else6034 domains = SpinDomain.where :spin_domain_name => domain_name6035 end6036 if domains.length > 06037 rethash[:success] = true6038 rethash[:status] = domains.length6039 rethash[:result] = domains6040 else6041 rethash[:success] = true6042 rethash[:status] = INFO_NO_DOMAIN6043 rethash[:result] = domain_name6044 end6045 when 'get_domain_root_by_name'6046 # coord_value is an array : [x,y,prx,v,hk]6047 # check session id6048 sid = nil6049 if my_session_id == nil6050 rethash[:success] = false6051 rethash[:status] = false6052 rethash[:errors] = "no session id"6053 return rethash6054 else6055 if SessionManager.auth_spin_session my_session_id6056 sid = my_session_id6057 else6058 rethash[:success] = false6059 rethash[:status] = false6060 rethash[:errors] = "session id is not valid"6061 return rethash6062 end6063 end # => end of session id check6064 if paramshash[:domain_disp_name].present?6065 domain_name = paramshash[:domain_disp_name]6066 elsif paramshash[:domain_name].present?6067 domain_name = paramshash[:domain_name]6068 else6069 domain_name = DOMAIN_ANY6070 end6071 domains = []6072 if domain_name == DOMAIN_ANY6073 domains = SpinDomain.where(["id > 0"])6074 else6075 domains = SpinDomain.select("spin_domain_root").where :spin_domain_disp_name => domain_name6076 end6077 if domains.length > 06078 rethash[:success] = true6079 rethash[:status] = domains.size6080 rethash[:result] = domains6081 else6082 rethash[:success] = true6083 rethash[:status] = INFO_NO_DOMAIN6084 rethash[:result] = domain_name6085 end6086 when 'get_cwd'6087 # coord_value is an array : [x,y,prx,v,hk]6088 # check session id6089 sid = nil6090 if my_session_id == nil6091 rethash[:success] = false6092 rethash[:status] = false6093 rethash[:errors] = "no session id"6094 return rethash6095 else6096 if SessionManager.auth_spin_session my_session_id6097 sid = my_session_id6098 else6099 rethash[:success] = false6100 rethash[:status] = false6101 rethash[:errors] = "session id is not valid"6102 return rethash6103 end6104 end # => end of session id check6105 if paramshash[:cont_location].present?6106 location = paramshash[:cont_location]6107 else6108 location = LOCATION_ANY6109 end6110 cwd = DatabaseUtility::SessionUtility.get_current_directory_path(sid, location)6111 if cwd == nil6112 rethash[:success] = false6113 rethash[:status] = ERROR_FAILED_TO_GET_CURRENT_DIRECTORY6114 rethash[:errors] = "Failed to get the current directory"6115 else6116 rethash[:success] = true6117 rethash[:status] = INFO_GET_CURRENT_DIRECTORY_SUCCESS6118 rethash[:result] = cwd6119 end6120 when 'set_cwd'6121 # coord_value is an array : [x,y,prx,v,hk]6122 # check session id6123 sid = nil6124 if my_session_id == nil6125 rethash[:success] = false6126 rethash[:status] = false6127 rethash[:errors] = "no session id"6128 return rethash6129 else6130 if SessionManager.auth_spin_session my_session_id6131 sid = my_session_id6132 else6133 rethash[:success] = false6134 rethash[:status] = false6135 rethash[:errors] = "session id is not valid"6136 return rethash6137 end6138 end # => end of session id check6139 if paramshash[:virtual_path].present?6140 vpath = paramshash[:virtual_path]6141 else6142 vpath = "/"6143 end6144 if paramshash[:cont_location].present?6145 location = paramshash[:cont_location]6146 else6147 location = LOCATION_ANY6148 end6149 cwd = DatabaseUtility::SessionUtility.set_current_directory_path(sid, vpath, location)6150 if cwd == nil6151 rethash[:success] = false6152 rethash[:status] = ERROR_FAILED_TO_SET_CURRENT_DIRECTORY6153 rethash[:errors] = "æå®ããããã£ã¬ã¯ããªãã¹ã«ç§»ååºæ¥ã¾ããã§ãã"6154 else6155 FolderDatum.select_folder(my_session_id, SpinLocationManager.get_vpath_key(cwd), LOCATION_A)6156 my_current_folder = SpinLocationManager.get_vpath_key(cwd)6157 FileDatum.fill_file_list(my_session_id, LOCATION_A, my_current_folder)6158 FolderDatum.fill_folders(my_session_id, LOCATION_A, nil, my_current_folder)6159 rethash[:success] = true6160 rethash[:status] = INFO_SET_CURRENT_DIRECTORY_SUCCESS6161 rethash[:result] = cwd6162 end6163 when 'hash_key_s'6164 # check session id6165 sid = nil6166 if my_session_id == nil6167 rethash[:success] = false6168 rethash[:status] = false6169 rethash[:errors] = "no session id"6170 return rethash6171 else6172 if SessionManager.auth_spin_session my_session_id6173 sid = my_session_id6174 else6175 rethash[:success] = false6176 rethash[:status] = false6177 rethash[:errors] = "session id is not valid"6178 return rethash6179 end6180 end # => end of session id check6181 seed = String.new6182 hash_key = String.new6183 if paramshash[:seed]6184 seed = paramshash[:seed]6185 end6186 r = Random.new6187 hash_key = Security.hash_key_s seed + Time.now.to_s + r.rand.to_s6188 if hash_key == nil6189 rethash[:success] = false6190 rethash[:status] = false6191 rethash[:errors] = "Failed to generate hash key in sha1"6192 else6193 rethash[:success] = true6194 rethash[:status] = true6195 rethash[:result] = hash_key6196 end6197 when 'get_location_vpath'6198 # args : node_location = [ x,y,prx,v]6199 # check session id6200 sid = nil6201 if my_session_id == nil6202 rethash[:success] = false6203 rethash[:status] = false6204 rethash[:errors] = "no session id"6205 return rethash6206 else6207 if SessionManager.auth_spin_session my_session_id6208 sid = my_session_id6209 else6210 rethash[:success] = false6211 rethash[:status] = false6212 rethash[:errors] = "session id is not valid"6213 return rethash6214 end6215 end # => end of session id check6216 nl = nil6217 if paramshash[:node_location]6218 nl = paramshash[:node_location]6219 else6220 nl = nil6221 end6222 vpath = SpinLocationManager.get_location_vpath nl6223 if vpath == nil6224 rethash[:success] = false6225 rethash[:status] = false6226 rethash[:errors] = ""6227 else6228 rethash[:success] = true6229 rethash[:status] = true6230 rethash[:result] = vpath6231 end6232 when 'get_vpath_key'6233 # args : node_location = [ x,y,prx,v]6234 vp = nil6235 key = nil6236 if paramshash[:virtual_path]6237 vp = paramshash[:virtual_path]6238 else6239 vp = nil6240 end6241 key = SpinLocationManager.get_vpath_key vp6242 if key == ""6243 rethash[:success] = false6244 rethash[:status] = false6245 rethash[:errors] = ""6246 else6247 rethash[:success] = true6248 rethash[:status] = true6249 rethash[:result] = key6250 end6251 when 'get_and_make_vpath'6252 # ActiveRecord::Base.transaction do6253 # args : node_location = [ x,y,prx,v]6254 vp = nil6255 key = nil6256 owner_uid = NO_USER6257 owner_gid = NO_GROUP6258 u_acl = 156259 g_acl = 76260 w_acl = 06261 acls = nil6262 get_node_attributes = false6263 # check session id6264 sid = nil6265 if my_session_id == nil6266 rethash[:success] = false6267 #rethash[:status] = false6268 rethash[:status] = ERROR_SESSION_ID_MISSING6269 rethash[:errors] = "no session id"6270 return rethash6271 else6272 if SessionManager.auth_spin_session my_session_id6273 sid = my_session_id6274 else6275 rethash[:success] = false6276 #rethash[:status] = false6277 rethash[:status] = ERROR_SESSION_ID_MISSING6278 rethash[:errors] = "session id is not valid"6279 return rethash6280 end6281 end # => end of session id check6282 if paramshash[:virtual_path].present?6283 vp0 = paramshash[:virtual_path].gsub(/\\u([\da-fA-F]{4})/) {[$1].pack('H*').unpack('n*').pack('U*')}6284 vpt = ''6285 dnt = ''6286 if (vp0 =~ /:/) != nil and !vp0.start_with?("/")6287 vpath_parts = vp0.partition(/:/)6288 if vpath_parts.size == 3 # => [domainname, ':', path]6289 vpt = vpath_parts[-1]6290 dnt = vpath_parts[0]6291 unless dnt.starts_with?("/")6292 droot = SpinDomain.get_domain_root_node_by_name dnt6293 vp = droot + '/' + vpt6294 else6295 vp = vpt6296 end6297 msg = '>> get_and_make_vpath : vp0 = ' + vp0 + ', vp = ' + vp6298 FileManager.logger(my_session_id, msg, 'LOCAL')6299 else6300 begin6301 cdom = DomainDatum.find_by_session_id_and_cont_location my_session_id, 'folder_a'6302 if cdom.blank?6303 rethash[:success] = false6304 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST6305 rethash[:errors] = 'No domain record is found'6306 return rethash6307 end6308 my_domain_root_key = cdom[:folder_hash_key]6309 tvp = SpinNode.get_vpath(my_domain_root_key)6310 if tvp != nil6311 vp = tvp + '/' + vp06312 else6313 vp = nil6314 end6315 msg = '>> get_and_make_vpath : vp0 = ' + vp0 + ', vp = ' + vp6316 FileManager.logger(my_session_id, msg, 'LOCAL')6317 rescue ActiveRecord::RecordNotFound6318 vp = nil6319 msg = '>> get_and_make_vpath : vp0 = ' + vp0 + ', vp = nil'6320 FileManager.logger(my_session_id, msg, 'LOCAL', LOG_ERROR)6321 end6322 end6323 else6324 vp = vp06325 msg = '>> get_and_make_vpath : vp0 = ' + vp0 + ', vp = ' + vp6326 FileManager.logger(my_session_id, msg, 'LOCAL')6327 FileManager.rails_logger(msg)6328 end6329 else6330 vp = nil6331 end6332 if paramshash[:uid].present?6333 owner_uid = paramshash[:uid]6334 end6335 if paramshash[:gid].present?6336 owner_gid = paramshash[:gid]6337 end6338 if paramshash[:acl].present?6339 acls = paramshash[:acl]6340 end6341 if paramshash[:make_directory].present?6342 mkdirf = paramshash[:make_directory]6343 else6344 mkdirf = false6345 end6346 if paramshash[:user].present?6347 u_acl = paramshash[:user]6348 end6349 if paramshash[:group].present?6350 g_acl = paramshash[:group]6351 end6352 if paramshash[:world].present?6353 w_acl = paramshash[:world]6354 end6355 if paramshash[:get_node_attributes].present?6356 get_node_attributes = paramshash[:get_node_attributes]6357 end6358 res_msg = ''6359 # set pesimistic lock6360 # ActiveRecord::Base.lock_optimistically = false6361 SpinLocationMapping.transaction do6362 # SpinLockSpinNodes.find_by_sql('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;')6363 # SpinLockSpinNodes.find_by_sql('LOCK TABLE spin_lock_spin_nodes IN EXCLUSIVE MODE;')6364 # lock_records = SpinLockSpinNodes.find(1)6365 loc = SpinLocationManager.get_location_coordinates sid, 'folder_a', vp, mkdirf, owner_uid, owner_gid, u_acl, g_acl, w_acl6366 # pp loc6367 if loc[X..V] == NoXYPV6368 node_rec = SpinNode.readonly.find_by_virtual_path(vp)6369 if node_rec.blank?6370 if mkdirf == false6371 rethash[:success] = true6372 rethash[:status] = INFO_NO_VPATH6373 rethash[:errors] = "Specified vpath dosen\'t exist"6374 rethash[:info] = "Specified vpath dosen\'t exist"6375 rethash[:result] = 06376 else6377 rethash[:success] = false6378 rethash[:status] = ERROR_CREATE_VPATH_FAILED6379 rethash[:errors] = "Failed to create specified vpath : " + vp6380 rethash[:result] = -16381 end6382 else6383 rethash[:success] = true6384 rethash[:status] = true6385 rethash[:result] = key6386 rethash[:virtual_path] = node_rec[:virtual_path]6387 if get_node_attributes == true6388 begin6389 hash_attr = JSON.parse(node_rec[:node_attributes])6390 log_msg = 'node_attributes = ' + hash_attr.to_s6391 FileManager.logger sid, log_msg, 'LOCAL'6392 rethash[:node_attributes] = hash_attr6393 rescue JSON::ParserError6394 log_msg = 'error parsing node_attributes = [ ' + node_rec[:node_attributes] + ' ]'6395 FileManager.logger sid, log_msg, 'LOCAL', LOG_ERROR6396 rethash[:node_attributes] = {:node_name => "NONAME", :node_path => "Not found"}6397 end6398 rethash[:is_deleted] = node_rec[:is_void]6399 rethash[:deleted_at] = node_rec[:spin_updated_at]6400 end6401 end6402 else # => valid loc6403 key = loc[K]6404 key = SpinLocationManager.location_to_key loc, NODE_DIRECTORY6405 unless key.present? # => key doesn't exist6406 node_rec = SpinNode.readonly.find_by_node_x_coord_and_node_y_coord_and_node_x_pr_coord_and_node_vedsion(loc[X], loc[Y], loc[PRX], loc[V])6407 else # => key is!6408 node_rec = SpinNode.readonly.find_by_spin_node_hashkey(key)6409 end6410 unless node_rec.present?6411 rethash[:success] = false6412 rethash[:status] = ERROR_CREATE_VPATH_FAILED6413 rethash[:errors] = "Failed to find specified vpath : " + vp6414 rethash[:result] = -16415 else6416 rethash[:success] = true6417 rethash[:status] = true6418 rethash[:result] = key6419 rethash[:virtual_path] = node_rec[:virtual_path]6420 if get_node_attributes == true6421 begin6422 hash_attr = JSON.parse(node_rec[:node_attributes])6423 log_msg = 'node_attributes = ' + hash_attr.to_s6424 FileManager.logger sid, log_msg, 'LOCAL'6425 rethash[:node_attributes] = hash_attr6426 rescue JSON::ParserError6427 log_msg = 'error parsing node_attributes = [ ' + node_rec[:node_attributes] + ' ]'6428 FileManager.logger sid, log_msg, 'LOCAL', LOG_ERROR6429 rethash[:node_attributes] = {:node_name => "NONAME", :node_path => "Not found"}6430 end6431 rethash[:is_deleted] = node_rec[:is_void]6432 rethash[:deleted_at] = node_rec[:spin_updated_at]6433 end6434 end6435 res_msg = '>> get_and_make_vpath : result = ' + rethash.to_s6436 end6437 end # => end of transaction with lock6438 # ActiveRecord::Base.lock_optimistically = true6439 FileManager.logger(my_session_id, res_msg, 'LOCAL')6440 FileManager.rails_logger(res_msg)6441 when 'clear_folder_tree'6442 clear_sid = my_session_id6443 clear_cont_locations = CONT_LOCATIONS_LIST6444 if paramshash[:clear_sid].present? and paramshash[:clear_sid].blank? == false6445 clear_sid = paramshash[:clear_sid]6446 end6447 if paramshash[:clear_cont_locations].present? and paramshash[:clear_cont_locations].blank? == false6448 clear_cont_locations = paramshash[:clear_cont_locations]6449 end6450 reth = FolderDatum.clear_folder_tree(my_session_id, clear_sid, clear_cont_locations)6451 rethash[:success] = reth[:success]6452 rethash[:status] = reth[:status]6453 when 'system_delete_user'6454 # check session id6455 sid = nil6456 my_session_id = paramshash[:session_id]6457 if my_session_id == nil6458 rethash[:success] = false6459 rethash[:status] = ERROR_SESSION_ID_MISSING6460 rethash[:errors] = "no session id"6461 return rethash6462 else6463 if SessionManager.auth_spin_session my_session_id6464 sid = my_session_id6465 else6466 rethash[:success] = false6467 rethash[:status] = ERROR_INVALID_SESSION_ID6468 rethash[:errors] = "session id is invalid"6469 return rethash6470 end6471 end # => end of session id check6472 #if paramshash[:form_data] == nil6473 # rethash[:success] = false6474 # rethash[:status] = ERROR_FORM_DATA_MISSING6475 # rethash[:errors] = "form data for createUser are missing"6476 # return rethash6477 #end6478 if paramshash[:user_name] == nil6479 rethash[:success] = false6480 rethash[:status] = ERROR_SYSADMIN_FAILED_TO_SYSTEM_DELETE_USER6481 rethash[:errors] = "user_name is null"6482 return rethash6483 end6484 login_user_uid = SessionManager.get_uid(sid, true)6485 login_uname = SpinUser.get_uname(login_user_uid);6486 spin_uname = paramshash[:user_name]6487 if login_user_uid != 06488 rethash[:success] = false6489 rethash[:status] = ERROR_SYSADMIN_FAILED_TO_SYSTEM_DELETE_USER6490 rethash[:errors] = "Only an administrator can perform"6491 return rethash6492 end6493 if spin_uname === "root"6494 rethash[:success] = false6495 rethash[:status] = ERROR_SYSADMIN_FAILED_TO_SYSTEM_DELETE_USER6496 rethash[:errors] = "Administrator cann't delete"6497 return rethash6498 end6499 spin_uid = SpinUser.get_uid(spin_uname);6500 if spin_uid === 06501 rethash[:success] = false6502 rethash[:status] = ERROR_SYSADMIN_FAILED_TO_SYSTEM_DELETE_USER6503 rethash[:errors] = "Administrator cann't delete"6504 return rethash6505 elsif spin_uid < 06506 rethash[:success] = false6507 rethash[:status] = ERROR_SYSADMIN_FAILED_TO_SYSTEM_DELETE_USER6508 rethash[:errors] = "No such user"6509 return rethash6510 end6511 rethash = SpinUser.delete_user(sid, spin_uid)6512 #respjã¯ãã¡ã¤ã«ããã¼ã¸ã£ã®ãã°ã«æ¸¡ãã®ã§æååã«å¤æããªããã°ãªããªãã6513 FileManager.rails_logger(rethash.to_s)6514 #rethash = JSON.parse(respj)6515 #respjã¯æååã«å¤æããå¿
è¦ã¯ãªãããªããªãã¯ã©ã¤ã¢ã³ãã«ç´æ¥æ¸¡ãããã§ããã6516 return rethash6517 when 'system_update_user'6518 sid = nil6519 my_session_id = paramshash[:session_id]6520 if my_session_id == nil6521 rethash[:success] = false6522 rethash[:status] = ERROR_SESSION_ID_MISSING6523 rethash[:errors] = "no session id"6524 return rethash6525 else6526 if SessionManager.auth_spin_session my_session_id6527 sid = my_session_id6528 else6529 rethash[:success] = false6530 rethash[:status] = ERROR_INVALID_SESSION_ID6531 rethash[:errors] = "session id is invalid"6532 return rethash6533 end6534 end # => end of session id check6535 if paramshash[:user_name] == nil6536 rethash[:success] = false6537 rethash[:status] = ERROR_SYSADMIN_FAILED_TO_SYSTEM_UPDATE_USER6538 rethash[:errors] = "user_name is null"6539 return rethash6540 end6541 login_user_uid = SessionManager.get_uid(sid, true)6542 login_uname = SpinUser.get_uname(login_user_uid);6543 spin_uname = paramshash[:user_name]6544 if login_uname != spin_uname and login_user_uid != 06545 rethash[:success] = false6546 rethash[:status] = ERROR_SYSADMIN_FAILED_TO_SYSTEM_UPDATE_USER6547 rethash[:errors] = "Only an administrator and LoginUser can perform"6548 return rethash6549 end6550 spin_uid = SpinUser.get_uid(spin_uname);6551 #rethash[:success] = true6552 #rethash[:status] = INFO_SYSADMIN_SYSTEM_UPDATE_USER6553 change_password_params = {:uid => spin_uid.to_i,6554 :current_password => paramshash[:operator_pw], :new_password => paramshash[:operator_new_pw]}6555 rethash = SpinUser.change_password my_session_id, change_password_params6556 return rethash6557 when 'copy_clipboard'6558 user_agent = $http_user_agent6559 copy_file_key = ''6560 copy_file_name = ''6561 if /HTTP_Request2.+/ =~ user_agent # => PHP API6562 copy_file_key = paramshash[:hash_key]6563 copy_file_name = paramshash[:file_name]6564 else # => from UI6565 if paramshash[:original_place] === 'folderPanelA'6566 file_rec = FolderDatum.find_by_hash_key paramshash[:hash_key]6567 if file_rec.blank?6568 rethash[:success] = false6569 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST6570 rethash[:errors] = 'No file record is found'6571 return rethash6572 end6573 copy_file_key = file_rec[:spin_node_hashkey]6574 copy_file_name = file_rec[:folder_name]6575 else6576 file_rec = FileDatum.find_by_hash_key paramshash[:hash_key]6577 if file_rec.blank?6578 rethash[:success] = false6579 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST6580 rethash[:errors] = 'No folder record is found at copy_clipboard'6581 return rethash6582 end6583 copy_file_key = file_rec[:spin_node_hashkey]6584 copy_file_name = file_rec[:file_name]6585 end6586 end6587 copy_sid = my_session_id6588 copy_file_hash_keys = Array.new6589 copy_file_hash_keys.push copy_file_key6590 r = Random.new6591 t = Time.now6592 opr_id = Security.hash_key_s(copy_sid + copy_file_key + t.to_s + r.rand.to_s)6593 rethash = ClipBoards.put_nodes(opr_id, copy_sid, copy_file_hash_keys, OPERATION_COPY)6594 unless rethash[:success]6595 rethash[:status] = ERROR_COPY_FILE6596 return rethash6597 end6598 rethash[:success] = true6599 rethash[:status] = INFO_COPY_FOLDER_SUCCESS6600 when 'cut_clipboard'6601 user_agent = $http_user_agent6602 copy_file_key = ''6603 copy_file_name = ''6604 parent_hash_key = ''6605 if /HTTP_Request2.+/ =~ user_agent # => PHP API6606 copy_file_key = paramshash[:hash_key]6607 copy_file_name = paramshash[:file_name]6608 else # => from UI6609 if paramshash[:original_place] === 'folderPanelA'6610 file_rec = FolderDatum.find_by_hash_key paramshash[:hash_key]6611 if file_rec.blank?6612 rethash[:success] = false6613 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST6614 rethash[:errors] = 'No file record is found'6615 return rethash6616 end6617 copy_file_key = file_rec[:spin_node_hashkey]6618 copy_file_name = file_rec[:folder_name]6619 parent_hash_key = file_rec[:parent_hash_key]6620 else6621 file_rec = FileDatum.find_by_hash_key paramshash[:hash_key]6622 if file_rec.blank?6623 rethash[:success] = false6624 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST6625 rethash[:errors] = 'No file record is found'6626 return rethash6627 end6628 copy_file_key = file_rec[:spin_node_hashkey]6629 copy_file_name = file_rec[:file_name]6630 parent_hash_key = file_rec[:folder_hash_key]6631 end6632 end6633 copy_sid = my_session_id6634 copy_uid = SessionManager.get_uid(copy_sid, true)6635 # ããã¯ç¶æ
æä»å¶å¾¡6636 file_nodes = []6637 if paramshash[:original_place] === 'file_list'6638 if file_rec[:file_type] === 'folder'6639 file_nodes = DatabaseUtility::VirtualFileSystemUtility.search_virtual_file_on_tree copy_file_key6640 else6641 file_nodes = DatabaseUtility::VirtualFileSystemUtility.search_virtual_file copy_sid, copy_file_name, parent_hash_key, ANY_VALUE, ANY_VALUE, SEARCH_EXISTING_VFILE6642 end6643 else6644 file_nodes = DatabaseUtility::VirtualFileSystemUtility.search_virtual_file_on_tree copy_file_key6645 end6646 if file_nodes.size() > 06647 file_nodes.each {|file_node|6648 if file_node[:latest]6649 if FSTAT_WRITE_LOCKED == file_node[:lock_mode] && FSTAT_LOCKED == file_node[:lock_status]6650 if copy_uid != file_node[:lock_uid] && -1 != file_node[:lock_uid]6651 rethash[:success] = false6652 rethash[:status] = ERROR_MOVE_FILE6653 rethash[:errors] = 'ä»ã®ã¦ã¼ã¶ã¼ã«ããã¯ããã¦ãããã移åã§ãã¾ãã'6654 return rethash6655 end6656 end6657 end6658 }6659 end6660 # check trash can6661 can_file_nodes = DatabaseUtility::VirtualFileSystemUtility.search_virtual_file my_session_id, copy_file_name, copy_target_folder_hashkey, ANY_VALUE, ANY_VALUE, SEARCH_EXISTING_VFILE6662 can_file_nodes.each {|canf|6663 if canf[:in_trash_flag]6664 rethash[:success] = false6665 rethash[:status] = ERROR_SAME_FILE_PATH_IN_RECYCLER6666 if canf[:node_type] == NODE_FILE6667 rethash[:errors] = 'åããã¹åã®ãã¡ã¤ã«ãã´ãç®±ã®ä¸ã«ããã¾ã'6668 else6669 rethash[:errors] = 'åããã¹åã®ãã©ã«ããã´ãç®±ã®ä¸ã«ããã¾ã'6670 end6671 else6672 rethash[:success] = false6673 rethash[:status] = ERROR_SAME_FILE_PATH_IN_DIRECTORY6674 if canf[:node_type] == NODE_FILE6675 rethash[:errors] = 'åããã¹åã®ãã¡ã¤ã«ããã©ã«ãã®ä¸ã«ããã¾ã'6676 else6677 rethash[:errors] = 'åããã¹åã®ãã©ã«ãããã©ã«ãã®ä¸ã«ããã¾ã'6678 end6679 end6680 return rethash6681 }6682 copy_file_hash_keys = Array.new6683 copy_file_hash_keys.push copy_file_key6684 r = Random.new6685 t = Time.now6686 opr_id = Security.hash_key_s(copy_sid + copy_file_key + t.to_s + r.rand.to_s)6687 rethash = ClipBoards.put_nodes(opr_id, copy_sid, copy_file_hash_keys, OPERATION_CUT)6688 unless rethash[:success]6689 return rethash6690 end6691 rethash[:success] = true6692 rethash[:status] = INFO_COPY_FOLDER_SUCCESS6693 when 'clipboard_all_clear'6694 rethash = ClipBoards.clear_nodes_all(my_session_id)6695 unless rethash[:success]6696 return rethash6697 end6698 rethash[:success] = true6699 rethash[:status] = INFO_CLEAR_CLIPBOARD_SUCCESS6700 when 'clipboard_clear'6701 n = paramshash.length # => I need it!6702 clear_files = n - 5 # => I hate this kind of logic but client send me fucking json data!6703 clear_sid = my_session_id6704 1.upto(clear_files) {|i|6705 rethash = ClipBoards.clear_nodes_hashkey(my_session_id, paramshash["#{i-1}"][:node_hash_key])6706 unless rethash[:success]6707 return rethash6708 end6709 }6710 rethash[:success] = true6711 rethash[:status] = INFO_CLEAR_CLIPBOARD_SUCCESS6712 when 'paste_file'6713 copy_sid = my_session_id6714 target_cont_location = 'folder_a'6715 target_folder_rec = FolderDatum.find_by_session_id_and_cont_location_and_selected copy_sid, target_cont_location, true6716 if target_folder_rec.blank?6717 rethash[:success] = false6718 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST6719 rethash[:errors] = 'No folder record is found at paste_file'6720 return rethash6721 end6722 target_hash_key = target_folder_rec[:spin_node_hashkey]6723 target_folder_writable_status = SpinAccessControl.is_writable(copy_sid, target_hash_key, NODE_DIRECTORY)6724 if target_folder_writable_status != true # => not copyable6725 rethash[:success] = false6726 rethash[:status] = ERROR_FAILED_TO_COPY_FOLDER6727 rethash[:errors] = "Failed to copy folder : target folder is not writable"6728 return rethash6729 end6730 n = paramshash.length # => I need it!6731 copy_files = n - 5 # => I hate this kind of logic but client send me fucking json data!6732 if copy_files > 06733 1.upto(copy_files) {|i|6734 cl = ClipBoards.find_by_session_id_and_node_hash_key(copy_sid, paramshash["#{i-1}"][:node_hash_key])6735 if cl.blank?6736 rethash[:success] = false6737 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST6738 rethash[:errors] = 'No clipboard record is found'6739 return rethash6740 end6741 #ãã¡ã¤ã«(ãã©ã«ã)ååå¾6742 copying_node = SpinNode.find_by_spin_node_hashkey cl[:node_hash_key]6743 if copying_node.blank?6744 rethash[:success] = false6745 rethash[:status] = ERROR_FAILED_TO_UPDATE_FILE_LIST6746 rethash[:errors] = 'No node record is found'6747 return rethash...
base_generator.rb
Source:base_generator.rb
...45 super()46 manifest.each do |type, list|47 case type48 when :files49 copy_files(list)50 when :templates51 copy_templates(list)52 else nil53 end54 end55 end56 def manifest; end57 protected58 def copy_files(list)59 list.each do |data|60 source_file = source_path(data[:source])61 File.exist?(source_file) ? copy_with_path(data) : puts_error("File '#{source_file}' was not found.")62 end63 end64 def copy_templates(list)65 list.each do |data|66 destination_path = dest_path(data[:destination])67 source_path = source_path(data[:source])68 if File.exist?(destination_path)69 copy_templates_file_exist(data, destination_path, source_path)70 else71 write_template(destination_path, source_path)72 puts_info "Added template '#{data[:source]}' with params '#{@options}' to destination '#{data[:destination]}'"...
copy_files
Using AI Code Generation
1copy_files('test1', 'test2')2 def copy_files(source, destination)3 def self.copy_files(source, destination)4Copyable.copy_files('test1', 'test2')5 def initialize(name)6person = Person.new('John')7 def initialize(name)8person = Person.new('John')
copy_files
Using AI Code Generation
1 @files = %w(1.txt 2.txt 3.txt)2 file_name = File.join(@src, file)3 if File.exist?(file_name)4 FileUtils.copy(file_name, @dest)
copy_files
Using AI Code Generation
1 FileUtils.cp_r(Dir.glob('*'), @dest)2 def initialize(dest)3my_copyable = MyCopyable.new('/home/username/mydir')4FileUtils.cp_r(Dir.glob('*'), @dest)5FileUtils.cp_r(Dir.glob('*'), @dest)61.rb:1:in `require': cannot load such file -- copyable (LoadError)
copy_files
Using AI Code Generation
1copy_files('source', 'destination')2 def copy_files(source, destination)3copy_files('source', 'destination')4 def copy_files(source, destination)
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!