diff --git a/src/app/acknowledgementReceipt/controllers/AcknowledgementReceiptController.php b/src/app/acknowledgementReceipt/controllers/AcknowledgementReceiptController.php
index d9432edaf67ebaaa1ed601756070b7fb947ba66f..a2fb24ee107aa5e9ad5dabbd77a08bca2da57192 100644
--- a/src/app/acknowledgementReceipt/controllers/AcknowledgementReceiptController.php
+++ b/src/app/acknowledgementReceipt/controllers/AcknowledgementReceiptController.php
@@ -23,14 +23,11 @@ use Respect\Validation\Validator;
 use setasign\Fpdi\Tcpdf\Fpdi;
 use Slim\Http\Request;
 use Slim\Http\Response;
-use User\models\UserModel;
 
 class AcknowledgementReceiptController
 {
     public function createPaperAcknowledgement(Request $request, Response $response)
     {
-        $currentUser = UserModel::getByLogin(['login' => $GLOBALS['userId'], 'select' => ['id']]);
-
         $bodyData = $request->getParsedBody();
 
         if (!Validator::arrayType()->notEmpty()->validate($bodyData['resources'])) {
diff --git a/src/app/contentManagement/controllers/JnlpController.php b/src/app/contentManagement/controllers/JnlpController.php
index 713845d62acdc5ea9d7add6258ec955379fdb0a0..c497079ed6a35e2b9520df1b6cbf7ec8fe81d62e 100755
--- a/src/app/contentManagement/controllers/JnlpController.php
+++ b/src/app/contentManagement/controllers/JnlpController.php
@@ -17,22 +17,21 @@ namespace ContentManagement\controllers;
 use Docserver\models\DocserverModel;
 use Slim\Http\Request;
 use Slim\Http\Response;
+use SrcCore\controllers\UrlController;
 use SrcCore\models\CoreConfigModel;
 use SrcCore\models\ValidatorModel;
 use Template\models\TemplateModel;
 
-require_once 'core/class/Url.php';
-
 class JnlpController
 {
     public function generateJnlp(Request $request, Response $response)
     {
-        $data = $request->getParams();
+        $body = $request->getParsedBody();
 
-        $coreUrl = str_replace('rest/', '', \Url::coreurl());
+        $coreUrl = str_replace('rest/', '', UrlController::getCoreUrl());
         $tmpPath = CoreConfigModel::getTmpPath();
         $jnlpUniqueId = CoreConfigModel::uniqueId();
-        $jnlpFileName = $GLOBALS['userId'] . '_maarchCM_' . $jnlpUniqueId;
+        $jnlpFileName = $GLOBALS['id'] . '_maarchCM_' . $jnlpUniqueId;
         $jnlpFileNameExt = $jnlpFileName . '.jnlp';
 
         $allCookies = '';
@@ -42,11 +41,11 @@ class JnlpController
             }
             $allCookies .= $key . '=' . str_replace(' ', '+', $value);
         }
-        if (!empty($data['cookies'])) {
+        if (!empty($body['cookies'])) {
             if (!empty($allCookies)) {
                 $allCookies .= '; ';
             }
-            $allCookies .= $data['cookies'];
+            $allCookies .= $body['cookies'];
         }
 
         $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'modules/content_management/xml/config.xml']);
@@ -125,17 +124,17 @@ class JnlpController
         $tagApplication->appendChild($newAttribute);
 
         $tagArg1 = $jnlpDocument->createElement('argument', $coreUrl . 'rest/jnlp/' . $jnlpUniqueId); //ProcessJnlp
-        $tagArg2 = $jnlpDocument->createElement('argument', $data['objectType']); //Type
-        $tagArg3 = $jnlpDocument->createElement('argument', $data['table']); //Table
-        $tagArg4 = $jnlpDocument->createElement('argument', $data['objectId']); //ObjectId
-        $tagArg5 = $jnlpDocument->createElement('argument', $data['uniqueId']);
+        $tagArg2 = $jnlpDocument->createElement('argument', $body['objectType']); //Type
+        $tagArg3 = $jnlpDocument->createElement('argument', 'table'); //Useless
+        $tagArg4 = $jnlpDocument->createElement('argument', $body['objectId']); //ObjectId
+        $tagArg5 = $jnlpDocument->createElement('argument', 0); //Useless
         $tagArg6 = $jnlpDocument->createElement('argument', "maarchCourrierAuth={$_COOKIE['maarchCourrierAuth']}"); //MaarchCookie
         $tagArg7 = $jnlpDocument->createElement('argument', htmlentities($allCookies)); //AllCookies
         $tagArg8 = $jnlpDocument->createElement('argument', $jnlpFileName); //JnlpFileName
-        $tagArg9 = $jnlpDocument->createElement('argument', $GLOBALS['userId']); //CurrentUser
-        $tagArg10 = $jnlpDocument->createElement('argument', 'false'); //ConvertPdf
-        $tagArg11 = $jnlpDocument->createElement('argument', 'false'); //OnlyConvert
-        $tagArg12 = $jnlpDocument->createElement('argument', 0); //HashFile
+        $tagArg9 = $jnlpDocument->createElement('argument', $GLOBALS['id']); //CurrentUser
+        $tagArg10 = $jnlpDocument->createElement('argument', 'false'); //ConvertPdf //Useless
+        $tagArg11 = $jnlpDocument->createElement('argument', 'false'); //OnlyConvert //Useless
+        $tagArg12 = $jnlpDocument->createElement('argument', 0); //HashFile //Useless
 
 
         $tagJnlp->appendChild($tagInformation);
@@ -197,22 +196,23 @@ class JnlpController
     }
 
 
-    public function processJnlp(Request $request, Response $response, array $aArgs)
+    public function processJnlp(Request $request, Response $response, array $args)
     {
-        $data = $request->getParams();
+        $body = $request->getParsedBody();
 
         $tmpPath = CoreConfigModel::getTmpPath();
 
-        if ($data['action'] == 'editObject') {
-            if ($data['objectType'] == 'templateCreation') {
-                $explodeFile = explode('.', $data['objectId']);
+        if ($body['action'] == 'editObject') {
+            if ($body['objectType'] == 'templateCreation') {
+                //TODO passer l'id et pas le chemin dans objectId
+                $explodeFile = explode('.', $body['objectId']);
                 $ext = $explodeFile[count($explodeFile) - 1];
-                $newFileOnTmp = "tmp_file_{$GLOBALS['userId']}_{$aArgs['jnlpUniqueId']}.{$ext}";
+                $newFileOnTmp = "tmp_file_{$GLOBALS['id']}_{$args['jnlpUniqueId']}.{$ext}";
 
-                $pathToCopy = $data['objectId'];
-            } elseif ($data['objectType'] == 'templateModification') {
+                $pathToCopy = $body['objectId'];
+            } elseif ($body['objectType'] == 'templateModification') {
                 $docserver = DocserverModel::getCurrentDocserver(['typeId' => 'TEMPLATES', 'collId' => 'templates', 'select' => ['path_template']]);
-                $template = TemplateModel::getById(['id' => $data['objectId'], 'select' => ['template_path', 'template_file_name']]);
+                $template = TemplateModel::getById(['id' => $body['objectId'], 'select' => ['template_path', 'template_file_name']]);
                 if (empty($template)) {
                     $xmlResponse = JnlpController::generateResponse(['type' => 'ERROR', 'data' => ['ERROR' => "Template does not exist"]]);
                     $response->write($xmlResponse);
@@ -221,7 +221,27 @@ class JnlpController
 
                 $explodeFile = explode('.', $template['template_file_name']);
                 $ext = $explodeFile[count($explodeFile) - 1];
-                $newFileOnTmp = "tmp_file_{$GLOBALS['userId']}_{$aArgs['jnlpUniqueId']}.{$ext}";
+                $newFileOnTmp = "tmp_file_{$GLOBALS['id']}_{$args['jnlpUniqueId']}.{$ext}";
+
+                $pathToCopy = $docserver['path_template'] . str_replace('#', DIRECTORY_SEPARATOR, $template['template_path']) . $template['template_file_name'];
+            } elseif ($body['objectType'] == 'resourceCreation') {
+                $docserver = DocserverModel::getCurrentDocserver(['typeId' => 'TEMPLATES', 'collId' => 'templates', 'select' => ['path_template']]);
+                $template = TemplateModel::getById(['id' => $body['objectId'], 'select' => ['template_path', 'template_file_name']]);
+                if (empty($template)) {
+                    $xmlResponse = JnlpController::generateResponse(['type' => 'ERROR', 'data' => ['ERROR' => "Template does not exist"]]);
+                    $response->write($xmlResponse);
+                    return $response->withHeader('Content-Type', 'application/xml');
+                }
+
+                //TODO revoir le merge avec les data
+//                $mergedDocument = MergeController::mergeDocument([
+//                    'path'  => $pathToDocument,
+//                    'data'  => ['resId' => $aArgs['resId'], 'contactAddressId' => $contactToProcess, 'userId' => $currentUser['id']]
+//                ]);
+
+                $explodeFile = explode('.', $template['template_file_name']);
+                $ext = $explodeFile[count($explodeFile) - 1];
+                $newFileOnTmp = "tmp_file_{$GLOBALS['id']}_{$args['jnlpUniqueId']}.{$ext}";
 
                 $pathToCopy = $docserver['path_template'] . str_replace('#', DIRECTORY_SEPARATOR, $template['template_path']) . $template['template_file_name'];
             } else {
@@ -240,10 +260,10 @@ class JnlpController
 
             $result = [
                 'STATUS'            => 'ok',
-                'OBJECT_TYPE'       => $data['objectType'],
-                'OBJECT_TABLE'      => $data['objectTable'],
-                'OBJECT_ID'         => $data['objectId'],
-                'UNIQUE_ID'         => $data['uniqueId'],
+                'OBJECT_TYPE'       => $body['objectType'],
+                'OBJECT_TABLE'      => $body['objectTable'],
+                'OBJECT_ID'         => $body['objectId'],
+                'UNIQUE_ID'         => $body['uniqueId'],
                 'APP_PATH'          => 'start',
                 'FILE_CONTENT'      => base64_encode($fileContent),
                 'FILE_EXTENSION'    => $ext,
@@ -252,42 +272,42 @@ class JnlpController
             ];
             $xmlResponse = JnlpController::generateResponse(['type' => 'SUCCESS', 'data' => $result]);
 
-        } elseif ($data['action'] == 'saveObject') {
-            if (empty($data['fileContent']) || empty($data['fileExtension'])) {
+        } elseif ($body['action'] == 'saveObject') {
+            if (empty($body['fileContent']) || empty($body['fileExtension'])) {
                 $xmlResponse = JnlpController::generateResponse(['type' => 'ERROR', 'data' => ['ERROR' => 'File content or file extension empty']]);
                 $response->write($xmlResponse);
                 return $response->withHeader('Content-Type', 'application/xml');
             }
 
-            $encodedFileContent = str_replace(' ', '+', $data['fileContent']);
-            $ext = str_replace(["\\", "/", '..'], '', $data['fileExtension']);
+            $encodedFileContent = str_replace(' ', '+', $body['fileContent']);
+            $ext = str_replace(["\\", "/", '..'], '', $body['fileExtension']);
             $fileContent = base64_decode($encodedFileContent);
-            $fileOnTmp = "tmp_file_{$GLOBALS['userId']}_{$aArgs['jnlpUniqueId']}.{$ext}";
+            $fileOnTmp = "tmp_file_{$GLOBALS['id']}_{$args['jnlpUniqueId']}.{$ext}";
 
             $file = fopen($tmpPath . $fileOnTmp, 'w');
             fwrite($file, $fileContent);
             fclose($file);
 
             if (!empty($data['step']) && $data['step'] == 'end') {
-                if (file_exists("{$tmpPath}{$GLOBALS['userId']}_maarchCM_{$aArgs['jnlpUniqueId']}.lck")) {
-                    unlink("{$tmpPath}{$GLOBALS['userId']}_maarchCM_{$aArgs['jnlpUniqueId']}.lck");
+                if (file_exists("{$tmpPath}{$GLOBALS['id']}_maarchCM_{$args['jnlpUniqueId']}.lck")) {
+                    unlink("{$tmpPath}{$GLOBALS['id']}_maarchCM_{$args['jnlpUniqueId']}.lck");
                 }
             }
 
             $xmlResponse = JnlpController::generateResponse(['type' => 'SUCCESS', 'data' => ['END_MESSAGE' => 'Update ok']]);
-        } elseif ($data['action'] == 'terminate') {
-            if (file_exists("{$tmpPath}{$GLOBALS['userId']}_maarchCM_{$aArgs['jnlpUniqueId']}.lck")) {
-                unlink("{$tmpPath}{$GLOBALS['userId']}_maarchCM_{$aArgs['jnlpUniqueId']}.lck");
+        } elseif ($body['action'] == 'terminate') {
+            if (file_exists("{$tmpPath}{$GLOBALS['id']}_maarchCM_{$args['jnlpUniqueId']}.lck")) {
+                unlink("{$tmpPath}{$GLOBALS['id']}_maarchCM_{$args['jnlpUniqueId']}.lck");
             }
 
             $xmlResponse = JnlpController::generateResponse(['type' => 'SUCCESS', 'data' => ['END_MESSAGE' => 'Terminate ok']]);
         } else {
             $result = [
                 'STATUS' => 'ko',
-                'OBJECT_TYPE'       => $data['objectType'],
-                'OBJECT_TABLE'      => $data['objectTable'],
-                'OBJECT_ID'         => $data['objectId'],
-                'UNIQUE_ID'         => $data['uniqueId'],
+                'OBJECT_TYPE'       => $body['objectType'],
+                'OBJECT_TABLE'      => $body['objectTable'],
+                'OBJECT_ID'         => $body['objectId'],
+                'UNIQUE_ID'         => $body['uniqueId'],
                 'APP_PATH'          => 'start',
                 'FILE_CONTENT'      => '',
                 'FILE_EXTENSION'    => '',
@@ -305,7 +325,7 @@ class JnlpController
     public function isLockFileExisting(Request $request, Response $response, array $aArgs)
     {
         $tmpPath = CoreConfigModel::getTmpPath();
-        $lockFileName = "{$GLOBALS['userId']}_maarchCM_{$aArgs['jnlpUniqueId']}.lck";
+        $lockFileName = "{$GLOBALS['id']}_maarchCM_{$aArgs['jnlpUniqueId']}.lck";
 
         $fileFound = false;
         if (file_exists($tmpPath . $lockFileName)) {
diff --git a/src/app/template/controllers/TemplateController.php b/src/app/template/controllers/TemplateController.php
index 1e4e6be3f9421f6e5e505334a9946caf40c671f7..419b57c67a9a002d38ffd9e2db2e2006c5fba56b 100755
--- a/src/app/template/controllers/TemplateController.php
+++ b/src/app/template/controllers/TemplateController.php
@@ -129,7 +129,7 @@ class TemplateController
                     return $response->withStatus(400)->withJson(['errors' => 'Template style is missing']);
                 }
                 $explodeStyle = explode(':', $data['template_style']);
-                $fileOnTmp = "tmp_file_{$GLOBALS['userId']}_{$data['jnlpUniqueId']}." . strtolower($explodeStyle[0]);
+                $fileOnTmp = "tmp_file_{$GLOBALS['id']}_{$data['jnlpUniqueId']}." . strtolower($explodeStyle[0]);
             } else {
                 if (empty($data['uploadedFile']['base64']) || empty($data['uploadedFile']['name'])) {
                     return $response->withStatus(400)->withJson(['errors' => 'Uploaded file is missing']);
@@ -407,6 +407,7 @@ class TemplateController
 
         return $check;
     }
+
     public static function mergeDatasource(array $aArgs)
     {
         include_once 'apps/maarch_entreprise/tools/tbs/tbs_class_php5.php';
diff --git a/src/core/controllers/CoreController.php b/src/core/controllers/CoreController.php
index f27ed86d1eb6ed97be882e622df949c8c4a265be..f5f09ec8681aeda256e9241c48a4471572f9aa8e 100755
--- a/src/core/controllers/CoreController.php
+++ b/src/core/controllers/CoreController.php
@@ -22,14 +22,12 @@ use SrcCore\models\CoreConfigModel;
 use SrcCore\models\ValidatorModel;
 use User\models\UserModel;
 
-require_once 'core/class/Url.php';
-
 class CoreController
 {
     public function initialize(Request $request, Response $response)
     {
         $aInit = [];
-        $aInit['coreUrl']            = str_replace('rest/', '', \Url::coreurl());
+        $aInit['coreUrl']            = str_replace('rest/', '', UrlController::getCoreUrl());
         $aInit['applicationName']    = CoreConfigModel::getApplicationName();
         $aInit['applicationVersion'] = CoreConfigModel::getApplicationVersion();
         $aInit['lang']               = CoreConfigModel::getLanguage();
diff --git a/src/core/controllers/UrlController.php b/src/core/controllers/UrlController.php
new file mode 100644
index 0000000000000000000000000000000000000000..a2c21b2d5eb6e65e167d520e6b068de5d030ecfb
--- /dev/null
+++ b/src/core/controllers/UrlController.php
@@ -0,0 +1,81 @@
+<?php
+
+/**
+ * Copyright Maarch since 2008 under licence GPLv3.
+ * See LICENCE.txt file at the root folder for more details.
+ * This file is part of Maarch software.
+ */
+
+/**
+ * @brief Url Controller
+ * @author dev@maarch.org
+ */
+
+namespace SrcCore\controllers;
+
+class UrlController
+{
+    private static function getPath()
+    {
+
+        if (!empty($_SERVER['HTTP_X_FORWARDED_SCRIPT_NAME'])) {
+            $baseUri = $_SERVER['HTTP_X_FORWARDED_SCRIPT_NAME'];
+        } else {
+            $baseUri = $_SERVER['SCRIPT_NAME'];
+        }
+        $baseUri = trim(dirname($baseUri), '/');
+        $baseUri = str_replace('rest', '', $baseUri);
+
+        return '/'.$baseUri;
+    }
+
+    private static function getHost()
+    {
+        if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
+            return $_SERVER['HTTP_X_FORWARDED_HOST'];
+        }
+
+        $rawHost = explode(':',$_SERVER['HTTP_HOST']);
+
+        return $rawHost[0];
+    }
+
+    private static function getPort()
+    {
+        if (!empty($_SERVER['HTTP_X_FORWARDED_PORT'])) {
+            return $_SERVER['HTTP_X_FORWARDED_PORT'];
+        }
+
+        return $_SERVER['SERVER_PORT'];
+    }
+
+    private static function getProto()
+    {
+        if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
+            return $_SERVER['HTTP_X_FORWARDED_PROTO'];
+        }
+
+        if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
+            return 'https';
+        }
+
+        return 'http';
+    }
+
+    public static function getCoreUrl()
+    {
+        $url = UrlController::getProto();
+        $url .= '://';
+        $url .= UrlController::getHost();
+
+        $port = UrlController::getPort();
+        if ($port != 80 && $port != 443) {
+            $url .= ':';
+            $url .= $port;
+        }
+
+        $url .= UrlController::getPath();
+
+        return $url;
+    }
+}