Error correction token management

This commit is contained in:
EoleDev 2016-04-14 16:26:09 +02:00
parent 24bb5fefbd
commit b348dbc226

View file

@ -274,8 +274,8 @@ class genTokenOptions
private function saveBackup($name, $data){
$token = $this->serializeToken($data["token"]);
$path = "core/LibOverride/projectTokenData/".$token['saved']["project"]["name"];
//error_log(print_r($path, true), 0);
//$path = "core/LibOverride/projectTokenData/".$token['saved']["project"]["name"];
//error_log("Path a ecrire ".print_r($path, true), 0);
file_put_contents("core/LibOverride/projectTokenData/".$token['saved']["project"]["name"], serialize($token['saved']));
$this->backup['time'] = $token['time'];
$this->backup["roles"] = $token["roles"];
@ -311,10 +311,10 @@ class genTokenOptions
$tokenSerialized = [];
$tokenSerialized["token"]["methods"] = serialize($token->methods);
$tokenSerialized["roles"] = [];
foreach($token->roles as $role){
$tokenSerialized["roles"][serialize($role->id)]["links"] = serialize($role->links);
$tokenSerialized["roles"][serialize($role->id)]["name"] = serialize($role->name);
$tokenSerialized["roles"][$role->id]["links"] = serialize($role->links);
$tokenSerialized["roles"][$role->id]["name"] = serialize($role->name);
}
$tokenSerialized["token"]["expires"] = serialize($token->expires);
@ -326,19 +326,21 @@ class genTokenOptions
$tokenSerialized['saved']["project"]["links"] = serialize($token->project->links);
$tokenSerialized['saved']["project"]["name"] = $token->project->name;
$tokenSerialized['saved']["catalog"] = array();
foreach($token->catalog->services as $service){
$tokenSerialized['saved']["catalog"][serialize($service->id)]["name"] = serialize($service->name);
$tokenSerialized['saved']["catalog"][serialize($service->id)]["description"] = serialize($service->description);
$tokenSerialized['saved']["catalog"][serialize($service->id)]["type"] = serialize($service->type);
$tokenSerialized['saved']["catalog"][$service->id]["name"] = serialize($service->name);
$tokenSerialized['saved']["catalog"][$service->id]["description"] = serialize($service->description);
$tokenSerialized['saved']["catalog"][$service->id]["type"] = serialize($service->type);
foreach($service->endpoints as $end){
$tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["interface"] = serialize($end->interface);
$tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["name"] = serialize($end->name);
$tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["serviceId"] = serialize($end->serviceId);
$tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["region"] = serialize($end->region);
$tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["links"] = serialize($end->links);
$tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["url"] = serialize($end->url);
$tokenSerialized['saved']["catalog"][$service->id]["endpoints"][$end->id]["interface"] = serialize($end->interface);
$tokenSerialized['saved']["catalog"][$service->id]["endpoints"][$end->id]["name"] = serialize($end->name);
$tokenSerialized['saved']["catalog"][$service->id]["endpoints"][$end->id]["serviceId"] = serialize($end->serviceId);
$tokenSerialized['saved']["catalog"][$service->id]["endpoints"][$end->id]["region"] = serialize($end->region);
$tokenSerialized['saved']["catalog"][$service->id]["endpoints"][$end->id]["links"] = serialize($end->links);
$tokenSerialized['saved']["catalog"][$service->id]["endpoints"][$end->id]["url"] = serialize($end->url);
}
$tokenSerialized['saved']["catalog"][serialize($service->id)]["links"] = serialize($service->links);
$tokenSerialized['saved']["catalog"][$service->id]["links"] = serialize($service->links);
}
$tokenSerialized["token"]["extras"] = serialize($token->extras);
$tokenSerialized["user"]["domainId"] = serialize($token->user->domainId);
@ -359,15 +361,16 @@ class genTokenOptions
private function unserializeToken($tokenSerialized){
$Saved = file_get_contents("core/LibOverride/projectTokenData/".$this->backup["project"]);
$Saved = unserialize($Saved);
$api = new Api();
$token = new Models\Token($this->httpClient, $api);
$token->methods = unserialize($tokenSerialized["methods"]);
$token->roles = [];
foreach($this->backup["roles"] as $key => $role){
$tmp = new Models\Role($this->httpClient, $api);
$tmp->id = unserialize($key);
$tmp->id = $key;
$tmp->links = unserialize($role["links"]);
$tmp->name = unserialize($role["name"]);
@ -386,18 +389,19 @@ class genTokenOptions
$token->catalog = new Models\Catalog($this->httpClient, $api);
$token->catalog->services = [];
error_log(print_r($Saved["catalog"], true), 0);
foreach($Saved["catalog"] as $key => $service){
$tmp = new Models\Service($this->httpClient, $api);
$tmp->id = unserialize($key);
$tmp->id = $key;
$tmp->name = unserialize($service["name"]);
$tmp->description = unserialize($service["description"]);
$tmp->type = unserialize($service["type"]);
$tmp->endpoints = [];
foreach($service["endpoints"] as $key => $end){
$tmpEnd = new Models\Endpoint($this->httpClient, $api);
$tmpEnd->id = unserialize($key);
$tmpEnd->id = $key;
$tmpEnd->interface = unserialize($end["interface"]);
$tmpEnd->name = unserialize($end["name"]);
$tmpEnd->serviceId = unserialize($end["serviceId"]);