Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

Commit

Permalink
bug fix with AGSAdministration where a portal security handler was used
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMillerGIS committed Jun 24, 2015
1 parent b2776aa commit 6c70474
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 29 deletions.
15 changes: 12 additions & 3 deletions src/arcrest/manageags/administration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
through the Administration REST API
"""
from ..security.security import ArcGISTokenSecurityHandler,AGOLTokenSecurityHandler, PortalTokenSecurityHandler, OAuthSecurityHandler, PortalServerSecurityHandler
from .._abstract.abstract import BaseAGSServer
from datetime import datetime
import csv
Expand Down Expand Up @@ -54,9 +55,15 @@ def __init__(self, url, securityHandler,
def __init(self):
""" populates server admin information """
params = {
"f" : "json",
"token" : self._securityHandler.token
}
"f" : "json"
}
if self._securityHandler is not None:
if isinstance(self._securityHandler , PortalTokenSecurityHandler):
params['token'] = self._securityHandler.servertoken(serverURL=self._url,referer=self._url)
else:
params['token'] = self._securityHandler.token


json_dict = self._do_get(url=self._url, param_dict=params)
self._json = json.dumps(json_dict)
attributes = [attr for attr in dir(self)
Expand Down Expand Up @@ -309,6 +316,8 @@ def data(self):
"""returns the reference to the data functions as a class"""
if self._resources is None:
self.__init()
if self._resources is None:
return
if "data" in self._resources:
url = self._url + "/data"
return _data.Data(url=url,
Expand Down
3 changes: 1 addition & 2 deletions src/arcrest/manageorg/administration.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,7 @@ def hostingServers(self, portalId=None):
## securityHandler=self._securityHandler,
## proxy_url=self._proxy_url,
## proxy_port=self._proxy_port))
else:
print "Security Handler is not set"

return services
else:
for server in portal.servers['servers']:
Expand Down
49 changes: 25 additions & 24 deletions src/arcresthelper/_abstract/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,30 +87,31 @@ def __init__(self,

admin = arcrest.manageorg.Administration(url=self._org_url,
securityHandler=self._securityHandler)

hostingServers = admin.hostingServers()
for hostingServer in hostingServers:
if isinstance(hostingServer, AGSAdministration):
serData = hostingServer.data

dataItems = serData.rootDataItems
if 'rootItems' in dataItems:
for rootItem in dataItems['rootItems']:
if rootItem == '/enterpriseDatabases':
rootItems = serData.findDataItems(ancestorPath=rootItem,type='fgdb,egdb')
if not rootItems is None and 'items' in rootItems:
for item in rootItems['items']:
if 'info' in item:
if 'isManaged' in item['info'] and item['info']['isManaged'] == True:
conStrDic = {}
conStr = item['info']['connectionString'].split(";")
for conStrValue in conStr:
spltval = conStrValue.split("=")
conStrDic[spltval[0]] = spltval[1]
if 'DBCLIENT' in conStrDic:
if str(conStrDic['DBCLIENT']).upper() == 'postgresql'.upper():
self._featureServiceFieldCase = 'lower'

try:
hostingServers = admin.hostingServers()
for hostingServer in hostingServers:
if isinstance(hostingServer, AGSAdministration):
serData = hostingServer.data

dataItems = serData.rootDataItems
if 'rootItems' in dataItems:
for rootItem in dataItems['rootItems']:
if rootItem == '/enterpriseDatabases':
rootItems = serData.findDataItems(ancestorPath=rootItem,type='fgdb,egdb')
if not rootItems is None and 'items' in rootItems:
for item in rootItems['items']:
if 'info' in item:
if 'isManaged' in item['info'] and item['info']['isManaged'] == True:
conStrDic = {}
conStr = item['info']['connectionString'].split(";")
for conStrValue in conStr:
spltval = conStrValue.split("=")
conStrDic[spltval[0]] = spltval[1]
if 'DBCLIENT' in conStrDic:
if str(conStrDic['DBCLIENT']).upper() == 'postgresql'.upper():
self._featureServiceFieldCase = 'lower'
except e as Exception:
print e
#if 'error' in self._securityHandler.message and token is None:
#if self._securityHandler.message['error']== 401:

Expand Down

0 comments on commit 6c70474

Please sign in to comment.