Esempio n. 1
0
function get_services()
{
    $cached = get_session_cached(SERVICE_REGISTRY_CACHE_TAG);
    if (count($cached) > 0) {
        // If something is cached, return it.
        return $cached;
    }
    // Nothing in the cache, fetch the services.
    $sr_url = get_sr_url();
    $client = XMLRPCClient::get_client($sr_url);
    $services = $client->get_services();
    $converted_services = array();
    foreach ($services as $service) {
        $converted_service = service_chapi2portal($service);
        // Some services are in SR but invisible to portal
        if (excluded_service($converted_service)) {
            continue;
        }
        $converted_services[] = $converted_service;
    }
    set_session_cached(SERVICE_REGISTRY_CACHE_TAG, $converted_services);
    return $converted_services;
}
Esempio n. 2
0
function set_session_cached_value($skey, $valuekey, $value)
{
    $cache = get_session_cached($skey);
    $cache[$valuekey] = $value;
    set_session_cached($skey, $cache);
}
Esempio n. 3
0
function get_slice_urn($sa_url, $signer, $slice_uid)
{
    $cache = get_session_cached('slice_urn');
    if (array_key_exists($slice_uid, $cache)) {
        return $cache[$slice_uid];
    }
    $client = XMLRPCClient::get_client($sa_url, $signer);
    $options = array('match' => array('SLICE_UID' => $slice_uid), 'filter' => array('SLICE_URN'));
    $options = array_merge($options, $client->options());
    $result = $client->lookup_slices($client->creds(), $options);
    $urns = array_keys($result);
    $urn = $urns[0];
    $cache[$slice_uid] = $urn;
    // remember it
    set_session_cached('slice_urn', $cache);
    return $urn;
}
Esempio n. 4
0
function get_member_urn($ma_url, $signer, $id)
{
    $cache = get_session_cached('member_urn');
    if (array_key_exists($id, $cache)) {
        return $cache[$id];
    } else {
        if (!isset($id) || is_null($id) || count($id) == 0 || count($id) == 1 && (!isset($id[0]) || is_null($id[0]) || $id[0] == '')) {
            error_log("Cannot get_member_urn for empty id: " . print_r($id, true));
            return null;
        }
        $client = XMLRPCClient::get_client($ma_url, $signer);
        $options = array('match' => array('MEMBER_UID' => $id), 'filter' => array('MEMBER_URN'));
        $options = array_merge($options, $client->options());
        $r = $client->lookup_public_member_info($client->creds(), $options);
        if (sizeof($r) > 0) {
            $urns = array_keys($r);
            $urn = $urns[0];
        } else {
            $urn = null;
            // cache failures
        }
        $cache[$id] = $urn;
        set_session_cached('member_urn', $cache);
        return $urn;
    }
}