Пример #1
0
    def web_saveAppState(self):
        up = self.__getUP()
        try:
            name = self.request.arguments['name'][-1]
            state = self.request.arguments['state'][-1]
        except KeyError as excp:
            raise WErr(400, "Missing %s" % excp)
        data = base64.b64encode(zlib.compress(DEncode.encode(state), 9))
        # before we save the state (modify the state) we have to remeber the actual access: ReadAccess and PublishAccess
        result = yield self.threadTask(up.getVarPermissions, name)
        if result['OK']:
            access = result['Value']
        else:
            access = {
                'ReadAccess': 'USER',
                'PublishAccess': 'USER'
            }  # this is when the application/desktop does not exists.
        result = yield self.threadTask(up.storeVar, name, data)
        if not result['OK']:
            raise WErr.fromSERROR(result)
        # change the access to the application/desktop
        result = yield self.threadTask(up.setVarPermissions, name, access)
        if not result['OK']:
            raise WErr.fromSERROR(result)

        self.set_status(200)
        self.finish()
Пример #2
0
  def web_listPublicDesktopStates( self ):
    up = self.__getUP()
    result = yield self.threadTask( up.listAvailableVars )
    if not result[ 'OK' ]:
      raise WErr.fromSERROR( result )
    data = result['Value']
    paramNames = ['UserName', 'Group', 'VO', 'desktop']

    records = []
    for i in data:
      records += [dict( zip( paramNames, i ) )]
    sharedDesktops = {}
    for i in records:
      result = yield self.threadTask( up.getVarPermissions, i['desktop'] )
      if not result[ 'OK' ]:
        raise WErr.fromSERROR( result )
      if result['Value']['ReadAccess'] == 'ALL':
        print i['UserName'], i['Group'], i
        result = yield self.threadTask( up.retrieveVarFromUser , i['UserName'], i['Group'], i['desktop'] )
        if not result[ 'OK' ]:
          raise WErr.fromSERROR( result )
        if i['UserName'] not in sharedDesktops:
          sharedDesktops[i['UserName']] = {}
          sharedDesktops[i['UserName']][i['desktop']] = json.loads( DEncode.decode( zlib.decompress( base64.b64decode( result['Value'] ) ) )[0] )
          sharedDesktops[i['UserName']]['Metadata'] = i
        else:
          sharedDesktops[i['UserName']][i['desktop']] = json.loads( DEncode.decode( zlib.decompress( base64.b64decode( result['Value'] ) ) )[0] )
          sharedDesktops[i['UserName']]['Metadata'] = i
    self.finish( sharedDesktops )
Пример #3
0
    def web_makePublicAppState(self):
        up = self.__getUP()
        try:
            name = self.request.arguments['name'][-1]
        except KeyError as excp:
            raise WErr(400, "Missing %s" % excp)
        try:
            access = self.request.arguments['access'][-1].upper()
        except KeyError as excp:
            access = 'ALL'
        if access not in ('ALL', 'VO', 'GROUP', 'USER'):
            raise WErr(400, "Invalid access")

        revokeAccess = {'ReadAccess': access}
        if access == 'USER':  # if we make private a state,
            # we have to revoke from the public as well
            revokeAccess['PublishAccess'] = 'USER'

        # TODO: Check access is in either 'ALL', 'VO' or 'GROUP'
        result = yield self.threadTask(up.setVarPermissions, name,
                                       revokeAccess)
        if not result['OK']:
            raise WErr.fromSERROR(result)
        self.set_status(200)
        self.finish()
  def __workflowxml(self, transid):

    tsClient = TransformationClient()
    retVal = tsClient.getTransformations({'TransformationID': transid})
    if not retVal['OK']:
      raise WErr.fromSERROR(retVal)
    print retVal['Value']
    return {"success": "true", "result": retVal['Value'][0]['Body']}
Пример #5
0
    def __workflowxml(self, transid):

        tsClient = TransformationClient()
        retVal = tsClient.getTransformations({'TransformationID': transid})
        if not retVal['OK']:
            raise WErr.fromSERROR(retVal)
        print retVal['Value']
        return {"success": "true", "result": retVal['Value'][0]['Body']}
Пример #6
0
 def web_delAppState( self ):
   up = self.__getUP()
   try:
     name = self.request.arguments[ 'name' ][-1]
   except KeyError as excp:
     raise WErr( 400, "Missing %s" % excp )
   result = yield self.threadTask( up.deleteVar, name )
   if not result[ 'OK' ]:
     raise WErr.fromSERROR( result)
   self.finish()
Пример #7
0
 def web_listAppState( self ):
   up = self.__getUP()
   result = yield self.threadTask( up.retrieveAllVars )
   if not result[ 'OK' ]:
     raise WErr.fromSERROR( result )
   data = result[ 'Value' ]
   for k in data:
     #Unpack data
     data[ k ] = json.loads( DEncode.decode( zlib.decompress( base64.b64decode( data[ k ] ) ) )[0] )
   self.finish( data )
Пример #8
0
 def web_delAppState(self):
     up = self.__getUP()
     try:
         name = self.request.arguments['name'][-1]
     except KeyError as excp:
         raise WErr(400, "Missing %s" % excp)
     result = yield self.threadTask(up.deleteVar, name)
     if not result['OK']:
         raise WErr.fromSERROR(result)
     self.finish()
Пример #9
0
 def web_listAppState(self):
     up = self.__getUP()
     result = yield self.threadTask(up.retrieveAllVars)
     if not result['OK']:
         raise WErr.fromSERROR(result)
     data = result['Value']
     for k in data:
         #Unpack data
         data[k] = json.loads(
             DEncode.decode(zlib.decompress(base64.b64decode(data[k])))[0])
     self.finish(data)
Пример #10
0
 def web_changeView( self ):
   up = self.__getUP()
   try:
     desktopName = self.request.arguments[ 'desktop' ][-1]
     view = self.request.arguments[ 'view' ][-1]
   except KeyError as excp:
     raise WErr( 400, "Missing %s" % excp )
   result = yield self.threadTask( up.retrieveVar, desktopName )
   if not result[ 'OK' ]:
     raise WErr.fromSERROR( result )
   data = result['Value']
   oDesktop = json.loads( DEncode.decode( zlib.decompress( base64.b64decode( data ) ) )[0] )
   oDesktop[unicode( 'view' )] = unicode( view )
   oDesktop = json.dumps( oDesktop )
   data = base64.b64encode( zlib.compress( DEncode.encode( oDesktop ), 9 ) )
   result = yield self.threadTask( up.storeVar, desktopName, data )
   if not result[ 'OK' ]:
     raise WErr.fromSERROR( result )
   self.set_status( 200 )
   self.finish()
Пример #11
0
 def web_changeView(self):
     up = self.__getUP()
     try:
         desktopName = self.request.arguments['desktop'][-1]
         view = self.request.arguments['view'][-1]
     except KeyError as excp:
         raise WErr(400, "Missing %s" % excp)
     result = yield self.threadTask(up.retrieveVar, desktopName)
     if not result['OK']:
         raise WErr.fromSERROR(result)
     data = result['Value']
     oDesktop = json.loads(
         DEncode.decode(zlib.decompress(base64.b64decode(data)))[0])
     oDesktop[unicode('view')] = unicode(view)
     oDesktop = json.dumps(oDesktop)
     data = base64.b64encode(zlib.compress(DEncode.encode(oDesktop), 9))
     result = yield self.threadTask(up.storeVar, desktopName, data)
     if not result['OK']:
         raise WErr.fromSERROR(result)
     self.set_status(200)
     self.finish()
Пример #12
0
 def web_listAppState( self ):
   self.__tc.setSetup( False )
   try:
     app = self.request.arguments[ 'app' ][-1]
   except KeyError as excp:
     raise WErr( 400, "Missing %s" % excp )
   up = UserProfileClient( "Web/App/%s" % app )
   result = yield self.threadTask( up.listAvailableVars, { 'UserName' : [ self.getUserName() ] } )
   if not result[ 'OK' ]:
     raise WErr.fromSERROR( result)
   data = result[ 'Value' ]
   self.finish( { 'app': [ e[-1] for e in data ] } )
Пример #13
0
 def web_loadAppState(self):
     up = self.__getUP()
     try:
         name = self.request.arguments['name'][-1]
     except KeyError as excp:
         raise WErr(400, "Missing %s" % excp)
     result = yield self.threadTask(up.retrieveVar, name)
     if not result['OK']:
         raise WErr.fromSERROR(result)
     data = result['Value']
     data, count = DEncode.decode(zlib.decompress(base64.b64decode(data)))
     self.finish(data)
Пример #14
0
 def web_loadAppState( self ):
   up = self.__getUP()
   try:
     name = self.request.arguments[ 'name' ][-1]
   except KeyError as excp:
     raise WErr( 400, "Missing %s" % excp )
   result = yield self.threadTask( up.retrieveVar, name )
   if not result[ 'OK' ]:
     raise WErr.fromSERROR( result)
   data = result[ 'Value' ]
   data, count = DEncode.decode( zlib.decompress( base64.b64decode( data ) ) )
   self.finish( data )
Пример #15
0
 def web_listAppState(self):
     self.__tc.setSetup(False)
     try:
         app = self.request.arguments['app'][-1]
     except KeyError as excp:
         raise WErr(400, "Missing %s" % excp)
     up = UserProfileClient("Web/App/%s" % app)
     result = yield self.threadTask(up.listAvailableVars,
                                    {'UserName': [self.getUserName()]})
     if not result['OK']:
         raise WErr.fromSERROR(result)
     data = result['Value']
     self.finish({'app': [e[-1] for e in data]})
Пример #16
0
 def web_saveAppState( self ):
   up = self.__getUP()
   try:
     name = self.request.arguments[ 'name' ][-1]
     state = self.request.arguments[ 'state' ][-1]
   except KeyError as excp:
     raise WErr( 400, "Missing %s" % excp )
   data = base64.b64encode( zlib.compress( DEncode.encode( state ), 9 ) )
   result = yield self.threadTask( up.storeVar, name, data )
   if not result[ 'OK' ]:
     raise WErr.fromSERROR( result )
   self.set_status( 200 )
   self.finish()
Пример #17
0
 def web_saveAppState(self):
     up = self.__getUP()
     try:
         name = self.request.arguments['name'][-1]
         state = self.request.arguments['state'][-1]
     except KeyError as excp:
         raise WErr(400, "Missing %s" % excp)
     data = base64.b64encode(zlib.compress(DEncode.encode(state), 9))
     result = yield self.threadTask(up.storeVar, name, data)
     if not result['OK']:
         raise WErr.fromSERROR(result)
     self.set_status(200)
     self.finish()
Пример #18
0
    def web_getInstallationData(self):
        """
    Retrieves a list of dictionaries containing components to be displayed by the Component History page
    """
        # Get the selectors values
        req = self.__request()

        client = RPCClient('Framework/ComponentMonitoring')
        result = yield self.threadTask(client.getInstallations,
                                       req['installation'], req['component'],
                                       req['host'], True)
        if result['OK']:
            values = []
            installations = result['Value']
            for i in range(self.pageNumber,
                           self.pageNumber + self.numberOfInstallations):
                if len(installations) > i:
                    installation = installations[i]
                else:
                    break
                uninstalled = '-'
                installedBy = '-'
                uninstalledBy = '-'
                if installation['UnInstallationTime']:
                    uninstalled = installation['UnInstallationTime'].strftime(
                        '%Y-%m-%d %H:%M')
                if installation['InstalledBy']:
                    installedBy = installation['InstalledBy']
                if installation['UnInstalledBy']:
                    uninstalledBy = installation['UnInstalledBy']
                values.append( { 'Name': installation[ 'Instance' ], \
                                 'Module': installation[ 'Component' ][ 'Module' ], \
                                 'Host': installation[ 'Host' ][ 'HostName' ], \
                                 'System': installation[ 'Component' ][ 'System' ], \
                                 'Type': installation[ 'Component' ][ 'Type' ], \
                                 'Installed': installation[ 'InstallationTime' ].strftime( '%Y-%m-%d %H:%M' ), \
                                 'Uninstalled': uninstalled, \
                                 'InstalledBy': installedBy, \
                                 'UninstalledBy': uninstalledBy } )
            timestamp = Time.dateTime().strftime('%Y-%m-%d %H:%M [UTC]')
            total = len(installations)
            callback = {
                'success': 'true',
                'result': values,
                'total': total,
                'date': timestamp
            }
        else:
            raise WErr.fromSERROR(result)
        self.finish(callback)
Пример #19
0
    def web_listPublicDesktopStates(self):
        up = self.__getUP()
        result = yield self.threadTask(up.listAvailableVars)
        if not result['OK']:
            raise WErr.fromSERROR(result)
        data = result['Value']
        paramNames = ['UserName', 'Group', 'VO', 'desktop']

        records = []
        for i in data:
            records += [dict(zip(paramNames, i))]
        sharedDesktops = {}
        for i in records:
            result = yield self.threadTask(up.getVarPermissions, i['desktop'])
            if not result['OK']:
                raise WErr.fromSERROR(result)
            if result['Value']['ReadAccess'] == 'ALL':
                print i['UserName'], i['Group'], i
                result = yield self.threadTask(up.retrieveVarFromUser,
                                               i['UserName'], i['Group'],
                                               i['desktop'])
                if not result['OK']:
                    raise WErr.fromSERROR(result)
                if i['UserName'] not in sharedDesktops:
                    sharedDesktops[i['UserName']] = {}
                    sharedDesktops[i['UserName']][i['desktop']] = json.loads(
                        DEncode.decode(
                            zlib.decompress(base64.b64decode(
                                result['Value'])))[0])
                    sharedDesktops[i['UserName']]['Metadata'] = i
                else:
                    sharedDesktops[i['UserName']][i['desktop']] = json.loads(
                        DEncode.decode(
                            zlib.decompress(base64.b64decode(
                                result['Value'])))[0])
                    sharedDesktops[i['UserName']]['Metadata'] = i
        self.finish(sharedDesktops)
Пример #20
0
 def web_loadAppState( self ):
   self.__tc.setSetup( False )
   try:
     app = self.request.arguments[ 'app' ][-1]
     name = self.request.arguments[ 'name' ][-1]
   except KeyError as excp:
     raise WErr( 400, "Missing %s" % excp )
   up = UserProfileClient( "Web/App/%s" % app )
   result = yield self.threadTask( up.retrieveVar, name )
   if not result[ 'OK' ]:
     raise WErr.fromSERROR( result)
   data = result[ 'Value' ]
   data, count = DEncode.decode( zlib.decompress( base64.b64decode( data ) ) )
   self.set_header( "Content-Type", "application/json" )
   self.finish( data )
Пример #21
0
 def web_saveAppState(self):
     self.__tc.setSetup(False)
     try:
         app = self.request.arguments['app'][-1]
         name = self.request.arguments['name'][-1]
         state = self.request.arguments['state'][-1]
     except KeyError as excp:
         raise WErr(400, "Missing %s" % excp)
     data = base64.b64encode(zlib.compress(DEncode.encode(state), 9))
     up = UserProfileClient("Web/App/%s" % app)
     result = yield self.threadTask(up.storeVar, name, data)
     if not result['OK']:
         raise WErr.fromSERROR(result)
     self.set_status(200)
     self.finish()
Пример #22
0
 def web_saveAppState( self ):
   self.__tc.setSetup( False )
   try:
     app = self.request.arguments[ 'app' ][-1]
     name = self.request.arguments[ 'name' ][-1]
     state = self.request.arguments[ 'state' ][-1]
   except KeyError as excp:
     raise WErr( 400, "Missing %s" % excp )
   data = base64.b64encode( zlib.compress( DEncode.encode( state ), 9 ) )
   up = UserProfileClient( "Web/App/%s" % app )
   result = yield self.threadTask( up.storeVar, name, data )
   if not result[ 'OK' ]:
     raise WErr.fromSERROR( result )
   self.set_status( 200 )
   self.finish()
Пример #23
0
  def web_saveAppState( self ):
    up = self.__getUP()
    try:
      name = self.request.arguments[ 'name' ][-1]
      state = self.request.arguments[ 'state' ][-1]
    except KeyError as excp:
      raise WErr( 400, "Missing %s" % excp )
    data = base64.b64encode( zlib.compress( DEncode.encode( state ), 9 ) )
    # before we save the state (modify the state) we have to remeber the actual access: ReadAccess and PublishAccess
    result = yield self.threadTask( up.getVarPermissions, name )
    if result['OK']:
      access = result['Value']
    else:
      access = {'ReadAccess': 'USER', 'PublishAccess': 'USER'}  # this is when the application/desktop does not exists.
    result = yield self.threadTask( up.storeVar, name, data )
    if not result[ 'OK' ]:
      raise WErr.fromSERROR( result )
    # change the access to the application/desktop
    result = yield self.threadTask( up.setVarPermissions, name, access )
    if not result[ 'OK' ]:
      raise WErr.fromSERROR( result )

    self.set_status( 200 )
    self.finish()
Пример #24
0
 def web_loadAppState(self):
     self.__tc.setSetup(False)
     try:
         app = self.request.arguments['app'][-1]
         name = self.request.arguments['name'][-1]
     except KeyError as excp:
         raise WErr(400, "Missing %s" % excp)
     up = UserProfileClient("Web/App/%s" % app)
     result = yield self.threadTask(up.retrieveVar, name)
     if not result['OK']:
         raise WErr.fromSERROR(result)
     data = result['Value']
     data, count = DEncode.decode(zlib.decompress(base64.b64decode(data)))
     self.set_header("Content-Type", "application/json")
     self.finish(data)
Пример #25
0
 def web_makePublicAppState( self ):
   up = self.__getUP()
   try:
     name = self.request.arguments[ 'name' ][-1]
   except KeyError as excp:
     raise WErr( 400, "Missing %s" % excp )
   try:
     access = self.request.arguments[ 'access' ][-1].upper()
   except KeyError as excp:
     access = 'ALL'
   if access not in ( 'ALL', 'VO', 'GROUP' ):
     raise WErr( 400, "Invalid access" )
   #TODO: Check access is in either 'ALL', 'VO' or 'GROUP'
   result = yield self.threadTask( up.setVarPermissions, name, { 'ReadAccess': access } )
   if not result[ 'OK' ]:
     raise WErr.fromSERROR( result )
   self.set_status( 200 )
   self.finish()
Пример #26
0
 def web_makePublicDesktopState(self):
     up = UserProfileClient("Web/application/desktop")
     try:
         name = self.request.arguments['name'][-1]
     except KeyError as excp:
         raise WErr(400, "Missing %s" % excp)
     try:
         access = self.request.arguments['access'][-1].upper()
     except KeyError as excp:
         access = 'ALL'
     if access not in ('ALL', 'VO', 'GROUP', 'USER'):
         raise WErr(400, "Invalid access")
     # TODO: Check access is in either 'ALL', 'VO' or 'GROUP'
     result = yield self.threadTask(up.setVarPermissions, name,
                                    {'ReadAccess': access})
     if not result['OK']:
         raise WErr.fromSERROR(result)
     self.set_status(200)
     self.finish()
Пример #27
0
    def web_publishAppState(self):
        up = self.__getUP()
        try:
            name = self.request.arguments['name'][-1]
        except KeyError as excp:
            raise WErr(400, "Missing %s" % excp)
        try:
            access = self.request.arguments['access'][-1].upper()
        except KeyError as excp:
            access = 'ALL'

        if access not in ('ALL', 'VO', 'GROUP', 'USER'):
            raise WErr(400, "Invalid access")

        result = yield self.threadTask(up.setVarPermissions, name, {
            'PublishAccess': access,
            'ReadAccess': access
        })
        if not result['OK']:
            raise WErr.fromSERROR(result)
        self.set_status(200)
        self.finish()
Пример #28
0
    def web_getSelectionData(self):
        """
    Returns a list of possible values for each different selector to choose from
    """

        req = self.__request()

        data = {}
        userData = self.getSessionData()

        setup = userData['setup'].split('-')[-1]
        systemList = []
        system = None

        fields = ['name', 'host', 'module', 'system', 'type']

        client = RPCClient('Framework/ComponentMonitoring')
        result = yield self.threadTask(client.getInstallations, {}, {}, {},
                                       True)
        if result['OK']:
            for field in fields:
                data[field] = set()
            for installation in result['Value']:
                data['name'].add(installation['Instance'])
                data['host'].add(installation['Host']['HostName'])
                data['module'].add(installation['Component']['Module'])
                data['system'].add(installation['Component']['System'])
                data['type'].add(installation['Component']['Type'])

            # Order and format the results
            for field in fields:
                data[field] = list(data[field])
                data[field].sort()
                data[field] = map(lambda x: [x], data[field])
        else:
            raise WErr.fromSERROR(result)

        self.finish(data)
Пример #29
0
  def web_makePublicAppState( self ):
    up = self.__getUP()
    try:
      name = self.request.arguments[ 'name' ][-1]
    except KeyError as excp:
      raise WErr( 400, "Missing %s" % excp )
    try:
      access = self.request.arguments[ 'access' ][-1].upper()
    except KeyError as excp:
      access = 'ALL'
    if access not in ( 'ALL', 'VO', 'GROUP', 'USER' ):
      raise WErr( 400, "Invalid access" )

    revokeAccess = { 'ReadAccess': access }
    if access == 'USER':  # if we make private a state,
      # we have to revoke from the public as well
      revokeAccess['PublishAccess'] = 'USER'

    # TODO: Check access is in either 'ALL', 'VO' or 'GROUP'
    result = yield self.threadTask( up.setVarPermissions, name, revokeAccess )
    if not result[ 'OK' ]:
      raise WErr.fromSERROR( result )
    self.set_status( 200 )
    self.finish()
Пример #30
0
    def web_listPublicStates(self):

        session = self.getSessionData()

        user = session["user"]["username"]

        up = self.__getUP()
        retVal = yield self.threadTask(up.getUserProfileNames,
                                       {'PublishAccess': 'ALL'})

        if not retVal['OK']:
            raise WErr.fromSERROR(retVal)

        data = retVal['Value']

        if data == None:
            raise WErr(404, "There are no public states!")

        paramNames = ['user', 'group', 'vo', 'name']

        mydesktops = {
            'name': 'My Desktops',
            'group': '',
            'vo': '',
            'user': '',
            'iconCls': 'my-desktop',
            'children': []
        }
        shareddesktops = {
            'name': 'Shared Desktops',
            'group': '',
            'vo': '',
            'user': '',
            'expanded': 'true',
            'iconCls': 'shared-desktop',
            'children': []
        }

        myapplications = {
            'name': 'My Applications',
            'group': '',
            'vo': '',
            'user': '',
            'children': []
        }
        sharedapplications = {
            'name': 'Shared Applications',
            'group': '',
            'vo': '',
            'user': '',
            'expanded': 'true',
            'iconCls': 'shared-desktop',
            'children': []
        }

        desktopsApplications = {
            'text':
            '.',
            'children': [{
                'name': 'Desktops',
                'group': '',
                'vo': '',
                'user': '',
                'children': [mydesktops, shareddesktops]
            }, {
                'name': 'Applications',
                'group': '',
                'vo': '',
                'user': '',
                'children': [myapplications, sharedapplications]
            }]
        }
        type = ''
        for i in data:
            application = i.replace('Web/application/', '')
            up = UserProfileClient(i)
            retVal = up.listAvailableVars()
            if not retVal['OK']:
                raise WErr.fromSERROR(retVal)
            else:
                states = retVal['Value']

                for state in states:
                    record = dict(zip(paramNames, state))
                    record['app'] = application
                    retVal = yield self.threadTask(up.getVarPermissions,
                                                   record['name'])
                    if not retVal['OK']:
                        raise WErr.fromSERROR(retVal)
                    else:
                        permissions = retVal['Value']
                        if permissions['PublishAccess'] == 'ALL':
                            if application == 'desktop':
                                record['type'] = 'desktop'
                                record['leaf'] = 'true'
                                record['iconCls'] = 'core-desktop-icon',
                                if record['user'] == user:
                                    mydesktops['children'].append(record)
                                else:
                                    shareddesktops['children'].append(record)
                            else:
                                record['type'] = 'application'
                                record['leaf'] = 'true'
                                record['iconCls'] = 'core-application-icon'
                                if record['user'] == user:
                                    myapplications['children'].append(record)
                                else:
                                    sharedapplications['children'].append(
                                        record)

        self.finish(desktopsApplications)
Пример #31
0
  def web_listPublicStates( self ):

    session = self.getSessionData()

    user = session["user"]["username"]

    up = self.__getUP()
    retVal = yield self.threadTask( up.getUserProfileNames, {'PublishAccess':'ALL'} )

    if not retVal[ 'OK' ]:
      raise WErr.fromSERROR( retVal )

    data = retVal['Value']

    if data == None:
      raise WErr(404, "There are no public states!" )

    paramNames = ['user', 'group', 'vo', 'name']

    mydesktops = {'name':'My Desktops',
                  'group':'',
                  'vo':'',
                  'user':'',
                  'iconCls' : 'my-desktop',
                  'children' :[]
                  }
    shareddesktops = {'name':'Shared Desktops',
                      'group':'',
                      'vo':'',
                      'user':'',
                      'expanded': 'true',
                      'iconCls' : 'shared-desktop',
                      'children' :[]
                      }

    myapplications = {'name':'My Applications',
                      'group':'',
                      'vo':'',
                      'user':'',
                      'children' :[]
                      }
    sharedapplications = {'name':'Shared Applications',
                          'group':'',
                          'vo':'',
                          'user':'',
                          'expanded': 'true',
                          'iconCls' : 'shared-desktop',
                          'children' :[]
                          }

    desktopsApplications = {
       'text':'.', 'children': [{'name':'Desktops',
                                 'group':'',
                                 'vo':'',
                                 'user':'',
                                 'children' :[mydesktops,
                                              shareddesktops]
                                 }, {'name':'Applications',
                                    'group':'',
                                    'vo':'',
                                    'user':'',
                                    'children' :[myapplications,
                                                 sharedapplications]
                                    }
                                ]
                            }
    type = ''
    for i in data:
      application = i.replace( 'Web/application/', '' )
      up = UserProfileClient( i )
      retVal = up.listAvailableVars()
      if not retVal['OK']:
        raise WErr.fromSERROR( retVal )
      else:
        states = retVal['Value']

        for state in states:
          record = dict( zip( paramNames, state ) )
          record['app'] = application
          retVal = yield self.threadTask( up.getVarPermissions, record['name'] )
          if not retVal['OK']:
            raise WErr.fromSERROR( retVal )
          else:
            permissions = retVal['Value']
            if permissions['PublishAccess'] == 'ALL':
              if application == 'desktop':
                record['type'] = 'desktop'
                record['leaf'] = 'true'
                record['iconCls'] = 'core-desktop-icon',
                if record['user'] == user:
                  mydesktops['children'].append( record )
                else:
                  shareddesktops['children'].append( record )
              else:
                record['type'] = 'application'
                record['leaf'] = 'true'
                record['iconCls'] = 'core-application-icon'
                if record['user'] == user:
                  myapplications['children'].append( record )
                else:
                  sharedapplications['children'].append( record )


    self.finish( desktopsApplications )