def update_hostname_references(): portal = Portal('http://portaldev.esri.com', 'admin', 'esri.agp') hostname_map = {'wh94.fltplan.com:8080': 'wh94.fltplan.com'} url_items = portal.search(['id', 'type', 'url'], portalpy.URL_ITEM_FILTER) for item in url_items: url = item.get('url') if url: url = normalize_url(url) host = parse_hostname(url, include_port=True) if host in hostname_map: url = url.replace(host, hostname_map[host]) portal.update_item(item['id'], {'url': url}) webmaps = portal.webmaps() for webmap in webmaps: is_update = False for url in webmap.urls(): normalized_url = normalize_url(url) host = parse_hostname(normalized_url, include_port=True) if host in hostname_map: new_url = normalized_url.replace(host, hostname_map[host]) webmap.data = webmap.data.replace(url, new_url) is_update = True if is_update: portal.update_webmap(webmap)
def update_hostname_references(): portal = Portal('http://portaldev.esri.com', 'admin', 'esri.agp') hostname_map = {'wh94.fltplan.com:8080': 'wh94.fltplan.com'} url_items = portal.search(['id','type','url'], portalpy.URL_ITEM_FILTER) for item in url_items: url = item.get('url') if url: url = normalize_url(url) host = parse_hostname(url, include_port=True) if host in hostname_map: url = url.replace(host, hostname_map[host]) portal.update_item(item['id'], {'url': url}) webmaps = portal.webmaps() for webmap in webmaps: is_update = False for url in webmap.urls(): normalized_url = normalize_url(url) host = parse_hostname(normalized_url, include_port=True) if host in hostname_map: new_url = normalized_url.replace(host, hostname_map[host]) webmap.data = webmap.data.replace(url, new_url) is_update = True if is_update: portal.update_webmap(webmap)
def update_hostname_references_wm(old_hostname, new_hostname, portalObject, users_to_process): portal = portalObject hostname_map = {old_hostname:new_hostname} webmaps = portal.webmaps(build_user_query(users_to_process)) if webmaps: print "checking {} webmaps for users".format(len(webmaps)) for webmap in webmaps: is_update = False for url in webmap.urls(): normalized_url = normalize_url(url) host = parse_hostname(normalized_url, include_port=True) if host in hostname_map: new_url = normalized_url.replace(host, hostname_map[host]) webmap.data = webmap.data.replace(url, new_url) if http_to_https: webmap.data = webmap.data.replace("http:","https:") is_update = True if is_update: print "updating web map: " + str(webmap.info()['id']) wmlist.append(webmap.info()['id']) portal.update_webmap(webmap)
def update_hostname_references_fs(old_name, new_name, portalObject, users_to_process): portal = portalObject hostname_map = {old_name:new_name} url_items = portal.search(['id','type','url'], portalpy.URL_ITEM_FILTER + " AND " + build_user_query(users_to_process)) if url_items: # find and update feature services and map services print "checking {} URL-based items".format(len(url_items)) count = 0 for item in url_items: count += 1 if count%10 == 0:print "processed {} items".format(count) url = item.get('url') id = item.get('id') #if portal.user_item(id)[0]['owner'] not in users_to_process: # break if url: url = normalize_url(url) host = parse_hostname(url, include_port=True) if host in hostname_map: fslist.append(id) print "updating item: " + id url = url.replace(host, hostname_map[host]) portal.update_item(item['id'], {'url': url}) print "done updating URL-based items"