// Now do the REST PUT try { $keepTrying = True; $tempFailTries = 0; while ($keepTrying) { $irods_info[IRODS_USER_NAME] = $username; // Note: in PHP 5.4, use JSON_UNESCAPED_SLASHES. // we have PHP 5.3, so we have to remove those manually. $irods_json = json_encode($irods_info); $irods_json = str_replace('\\/', '/', $irods_json); // error_log("Trying to create iRODS account with values: " . $irods_json); ///* Sign the data with the portal certificate (Is that correct?) */ //$irods_signed = smime_sign_message($irods_json, $portal_cert, $portal_key); ///* Encrypt the signed data for the iRODS SSL certificate */ //$irods_blob = smime_encrypt($irods_signed, $irods_cert); $addstruct = doRESTCall($irods_url . IRODS_PUT_USER_URI . IRODS_SEND_JSON, $portal_irods_user, $portal_irods_pw, "PUT", $irods_json, "application/json", $irods_cert); //error_log("PUT raw result: " . print_r($addstruct, true)); // look for (\r or \n or \r\n){2} and move past that preg_match("/(\r|\n|\r\n){2}([^\r\n].+)\$/", $addstruct, $m); if (!array_key_exists(2, $m)) { error_log("Malformed PUT result to iRODS - error? Got: " . $addstruct); throw new Exception("Failed to create iRODS account - server error: " . $addstruct); } // error_log("PUT result content: " . $m[2]); $addjson = json_decode($m[2], true); // Parse the result. If code 0, show username and password. Else show the error for now. // Later if username taken, find another. if (!is_null($addjson) && is_array($addjson) && array_key_exists(IRODS_ADD_RESPONSE_CODE, $addjson)) { if ($addjson[IRODS_ADD_RESPONSE_CODE] == IRODS_ERROR::SUCCESS) { $didCreate = True; error_log("irods.php: Created account with username {$username} for " . $user->prettyName());
/** * gets the transcript details for a gene * * @param string $geneName */ function doGetGeneTranscripts($geneName) { // parse the config file $config = parse_ini_file("Config.ini", 1); // generate the servie URL with the function name and params $serviceURL = $config['HearSayREST']['CARNACTranscriptServiceHost'] . 'findByGeneName/' . $geneName; // make the REST call $data = doRESTCall($serviceURL); //error_log($serviceURL . ", " . print_r(json_decode($data), true)); // send the data to the page echo $data; // terminate the data stream die; }
function removeGroup($project_id, $group_name, $user) { if (!isset($project_id) || $project_id == "-1" || !uuid_is_valid($project_id)) { error_log("iRODS removeGroup: not a valid project ID. Nothing to do. {$project_id}"); return -1; } if (!isset($group_name) || is_null($group_name) || $group_name === '') { error_log("iRODS removeGroup: not a valid group name. Nothing to do. {$project_id}, {$group_name}"); return -1; } error_log("iRODS removeGroup {$group_name}"); global $irods_url; global $portal_irods_user; global $portal_irods_pw; global $irods_cert; $removed = -1; // -1=Error, 0=Success, 1=Already gone try { $rmstruct = doRESTCall($irods_url . IRODS_REMOVE_USER_URI1 . $group_name, $portal_irods_user, $portal_irods_pw, "DELETE", "", "", $irods_cert); // look for (\r or \n or \r\n){2} and move past that preg_match("/(\r|\n|\r\n){2}([^\r\n].+)\$/", $rmstruct, $m); if (!array_key_exists(2, $m)) { error_log("iRODS removeGroup: Malformed DELETE result from iRODS - error? Got: " . $rmstruct); throw new Exception("Failed to remove iRODS group - server error: " . $rmstruct); } // FIXME: Comment this out when ready error_log("DELETE result content: " . $m[2]); $rmjson = json_decode($m[2], true); // FIXME: Comment this out when ready error_log("remove group result: " . print_r($rmjson, true)); if (is_array($rmjson)) { $status = null; $msg = null; $groupCmdStatus = null; if (array_key_exists("status", $rmjson)) { $status = $rmjson["status"]; // Return true = 0 if removed the group, -1 on error if ($status == IRODS_STATUS_ERROR) { $removed = -1; } elseif ($status == IRODS_STATUS_SUCCESS) { $removed = 0; } } if (array_key_exists("message", $rmjson)) { $msg = $rmjson["message"]; // error_log("removeGroup result: '$msg'"); } // Mike C says delete when the group doesn't exist returns SUCCESS if (array_key_exists(IRODS_USER_GROUP_COMMAND_STATUS, $rmjson)) { $groupCmdStatus = $rmjson[IRODS_USER_GROUP_COMMAND_STATUS]; if ($groupCmdStatus != IRODS_STATUS_SUCCESS) { if ($groupCmdStatus === IRODS_STATUS_BAD_GROUP) { error_log("iRODS: group {$group_name} not there to delete. ({$groupCmdStatus}: '{$msg}')"); $removed = 1; } else { error_log("iRODS failed to remove group {$group_name}: {$groupCmdStatus}: '{$msg}'"); } } } elseif ($removed === -1) { error_log("iRODS failed to remove group {$group_name}: '{$msg}'"); } } else { $removed = -1; error_log("iRODS malformed return from removeGroup: " . print_r($rmjson, true)); } } catch (Exception $e) { error_log("Error doing iRODS delete to remove group: " . $e->getMessage()); $removed = -1; } // Return 0 if removed the group, -1 on error, 1 if no such group return $removed; }