Merged in darojas/processmaker (pull request #274)
Se aumenta end point para borrar folders en FILESMANAGER (incluido BEHAT). Se agrega listado de InputDocuments con WS (no es la version final)
This commit is contained in:
@@ -69,11 +69,21 @@ Feature: Files Manager Resources
|
||||
| put into public subfolder | put test | 200 | object | 2 |
|
||||
| put into mailtemplates subfolder | put test | 200 | object | 3 |
|
||||
|
||||
#Para que funcione este test, debe existir el archivo que se quiere subir
|
||||
Scenario Outline: Upload files to same folders
|
||||
Given POST I want to upload the file "<file>" to path "<path>". Url "project/1265557095225ff5c688f46031700471/file-manager"
|
||||
And store "prf_uid" in session array as variable "prf_uid<i>"
|
||||
|
||||
Examples:
|
||||
| file | path | i |
|
||||
|/home/daniel/test1.html | templates | 4 |
|
||||
|
||||
|
||||
Scenario Outline: Delete file
|
||||
Given that I want to delete a resource with the key "prf_uid" stored in session array as variable "prf_uid<i>"
|
||||
And I request "project/1265557095225ff5c688f46031700471/file-manager"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
Given that I want to delete a resource with the key "prf_uid" stored in session array as variable "prf_uid<i>"
|
||||
And I request "project/1265557095225ff5c688f46031700471/file-manager"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
|
||||
Examples:
|
||||
| test_description | i |
|
||||
@@ -81,13 +91,14 @@ Feature: Files Manager Resources
|
||||
| delete mailtemplates folder | 1 |
|
||||
| delete public subfolder | 2 |
|
||||
| delete mailtemplates subfolder | 3 |
|
||||
| delete upload | 4 |
|
||||
|
||||
#Para que funcione este test, debe existir el archivo que se quiere subir
|
||||
Scenario: Post files
|
||||
Given POST I want to upload the file "/home/daniel/test.txt" to path "templates". Url "project/1265557095225ff5c688f46031700471/file-manager"
|
||||
Scenario: Delete folder public
|
||||
Given that I want to delete the folder
|
||||
And I request "project/1265557095225ff5c688f46031700471/file-manager/folder?path=public/test_folder"
|
||||
Then the response status code should be 200
|
||||
|
||||
Scenario: Delete file
|
||||
Given that I want to delete a resource with the key "prf_uid" stored in session array as variable "prf_uid"
|
||||
And I request "project/1265557095225ff5c688f46031700471/file-manager"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
Scenario: Delete folder templates
|
||||
Given that I want to delete the folder
|
||||
And I request "project/1265557095225ff5c688f46031700471/file-manager/folder?path=templates/test_folder"
|
||||
Then the response status code should be 200
|
||||
|
||||
@@ -1423,4 +1423,12 @@ print_r($sessionData);
|
||||
$this->postIWantToUploadTheImageToUser($imageFile, $usrUid, $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^that I want to delete the folder$/
|
||||
*/
|
||||
public function thatIWantToDeleteTheFolder()
|
||||
{
|
||||
$this->_restObjectMethod = 'delete';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class FilesManager
|
||||
$sDirectory = PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP . $sSubDirectory;
|
||||
break;
|
||||
default:
|
||||
die();
|
||||
throw (new \Exception( 'Invalid value specified for `path`. Expecting `templates` or `public`'));
|
||||
break;
|
||||
}
|
||||
\G::verifyPath($sDirectory, true);
|
||||
@@ -314,7 +314,7 @@ class FilesManager
|
||||
}
|
||||
$sFile = end(explode("/",$path));
|
||||
$sPath = str_replace($sFile,'',$path);
|
||||
$sSubDirectory = str_replace('/','',str_replace($sProcessUID,'',substr($sPath,(strpos($sPath, $sProcessUID)))));
|
||||
$sSubDirectory = substr(str_replace($sProcessUID,'',substr($sPath,(strpos($sPath, $sProcessUID)))),0,-1);
|
||||
$sMainDirectory = str_replace(substr($sPath, strpos($sPath, $sProcessUID)),'', $sPath);
|
||||
if ($sMainDirectory == PATH_DATA_MAILTEMPLATES) {
|
||||
$sMainDirectory = 'mailTemplates';
|
||||
@@ -383,7 +383,7 @@ class FilesManager
|
||||
}
|
||||
$sFile = end(explode("/",$path));
|
||||
$sPath = str_replace($sFile,'',$path);
|
||||
$sSubDirectory = str_replace('/','',str_replace($sProcessUID,'',substr($sPath,(strpos($sPath, $sProcessUID)))));
|
||||
$sSubDirectory = substr(str_replace($sProcessUID,'',substr($sPath,(strpos($sPath, $sProcessUID)))),0,-1);
|
||||
$sMainDirectory = str_replace(substr($sPath, strpos($sPath, $sProcessUID)),'', $sPath);
|
||||
if ($sMainDirectory == PATH_DATA_MAILTEMPLATES) {
|
||||
$sMainDirectory = 'mailTemplates';
|
||||
@@ -392,9 +392,7 @@ class FilesManager
|
||||
}
|
||||
$oProcessMap = new \processMap(new \DBConnection());
|
||||
$oProcessMap->deleteFile($sProcessUID, $sMainDirectory, $sSubDirectory, $sFile);
|
||||
$c = new \Criteria("workflow");
|
||||
$c->add(\ProcessFilesPeer::PRF_UID, $prfUid, \Criteria::EQUAL);
|
||||
$rs = \ProcessFilesPeer::doDelete($c);
|
||||
$rs = \ProcessFilesPeer::doDelete($criteria);
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
@@ -427,7 +425,7 @@ class FilesManager
|
||||
}
|
||||
$sFile = end(explode("/",$path));
|
||||
$sPath = str_replace($sFile,'',$path);
|
||||
$sSubDirectory = str_replace('/','',str_replace($sProcessUID,'',substr($sPath,(strpos($sPath, $sProcessUID)))));
|
||||
$sSubDirectory = substr(str_replace($sProcessUID,'',substr($sPath,(strpos($sPath, $sProcessUID)))),0,-1);
|
||||
$sMainDirectory = str_replace(substr($sPath, strpos($sPath, $sProcessUID)),'', $sPath);
|
||||
if ($sMainDirectory == PATH_DATA_MAILTEMPLATES) {
|
||||
$sMainDirectory = 'mailTemplates';
|
||||
@@ -445,5 +443,43 @@ class FilesManager
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $sProcessUID {@min 32} {@max 32}
|
||||
* @param array $path
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function deleteFolderProcessFilesManager($sProcessUID, $path)
|
||||
{
|
||||
try {
|
||||
$sDirToDelete = end(explode("/",$path));
|
||||
$sPath = str_replace($sDirToDelete,'',$path);
|
||||
$sSubDirectory = substr(str_replace($sProcessUID,'',substr($sPath,(strpos($sPath, $sProcessUID)))),0,-1);
|
||||
$sMainDirectory = current(explode("/", $path));
|
||||
$sSubDirectory = substr(str_replace($sMainDirectory,'',$sSubDirectory),1);
|
||||
switch ($sMainDirectory) {
|
||||
case 'templates':
|
||||
$sMainDirectory = 'mailTemplates';
|
||||
$sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP . ($sSubDirectory != '' ? $sSubDirectory . PATH_SEP : '');
|
||||
break;
|
||||
case 'public':
|
||||
$sMainDirectory = 'public';
|
||||
$sDirectory = PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP . ($sSubDirectory != '' ? $sSubDirectory . PATH_SEP : '');
|
||||
break;
|
||||
default:
|
||||
die();
|
||||
break;
|
||||
}
|
||||
if (file_exists($sDirectory . $sDirToDelete)) {
|
||||
\G::rm_dir($sDirectory . $sDirToDelete);
|
||||
} else {
|
||||
throw (new \Exception( 'Invalid value specified for `path`.'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -462,5 +462,192 @@ class InputDocument
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data of Cases InputDocument
|
||||
*
|
||||
* @param string $caseUid
|
||||
* @param string $userUid
|
||||
*
|
||||
* return array Return an array with data of an InputDocument
|
||||
*/
|
||||
public function getCasesInputDocument($caseUid, $userUid)
|
||||
{
|
||||
try {
|
||||
|
||||
///
|
||||
global $G_PUBLISH;
|
||||
$defaultEndpoint = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/classic/services/wsdl2';
|
||||
|
||||
$endpoint = isset( $_SESSION['END_POINT'] ) ? $_SESSION['END_POINT'] : $defaultEndpoint;
|
||||
|
||||
$sessionId = isset( $_SESSION['SESSION_ID'] ) ? $_SESSION['SESSION_ID'] : '';
|
||||
|
||||
//Apply proxy settings
|
||||
$proxy = array ();
|
||||
$sysConf = \System::getSystemConfiguration();
|
||||
if ($sysConf['proxy_host'] != '') {
|
||||
$proxy['proxy_host'] = $sysConf['proxy_host'];
|
||||
if ($sysConf['proxy_port'] != '') {
|
||||
$proxy['proxy_port'] = $sysConf['proxy_port'];
|
||||
}
|
||||
if ($sysConf['proxy_user'] != '') {
|
||||
$proxy['proxy_login'] = $sysConf['proxy_user'];
|
||||
}
|
||||
if ($sysConf['proxy_pass'] != '') {
|
||||
$proxy['proxy_password'] = $sysConf['proxy_pass'];
|
||||
}
|
||||
}
|
||||
|
||||
@$client = new \SoapClient( $endpoint, $proxy );
|
||||
///
|
||||
|
||||
|
||||
$caseId = $caseUid;
|
||||
$sessionId = $userUid;
|
||||
$params = array ('sessionId' => $sessionId,'caseId' => $caseId);
|
||||
|
||||
$wsResponse = $client->__SoapCall( 'InputDocumentList', array ($params));
|
||||
|
||||
//g::pr($wsResponse);
|
||||
$result = \G::PMWSCompositeResponse( $wsResponse, 'documents' );
|
||||
|
||||
$G_PUBLISH = new \Publisher();
|
||||
$rows[] = array ('guid' => 'char','name' => 'char','processId' => 'char');
|
||||
|
||||
if (is_array( $result )) {
|
||||
foreach ($result as $key => $item) {
|
||||
if (isset( $item->item )) {
|
||||
foreach ($item->item as $index => $val) {
|
||||
if ($val->key == 'guid') {
|
||||
$guid = $val->value;
|
||||
}
|
||||
if ($val->key == 'filename') {
|
||||
$filename = $val->value;
|
||||
}
|
||||
if ($val->key == 'docId') {
|
||||
$docId = $val->value;
|
||||
}
|
||||
if ($val->key == 'version') {
|
||||
$version = $val->value;
|
||||
}
|
||||
if ($val->key == 'createDate') {
|
||||
$createDate = $val->value;
|
||||
}
|
||||
if ($val->key == 'createBy') {
|
||||
$createBy = $val->value;
|
||||
}
|
||||
if ($val->key == 'type') {
|
||||
$type = $val->value;
|
||||
}
|
||||
if ($val->key == 'link') {
|
||||
$link = $val->value;
|
||||
}
|
||||
}
|
||||
} elseif (is_array( $item )) {
|
||||
foreach ($item as $index => $val) {
|
||||
if ($val->key == 'guid') {
|
||||
$guid = $val->value;
|
||||
}
|
||||
if ($val->key == 'filename') {
|
||||
$filename = $val->value;
|
||||
}
|
||||
if ($val->key == 'docId') {
|
||||
$docId = $val->value;
|
||||
}
|
||||
if ($val->key == 'version') {
|
||||
$version = $val->value;
|
||||
}
|
||||
if ($val->key == 'createDate') {
|
||||
$createDate = $val->value;
|
||||
}
|
||||
if ($val->key == 'createBy') {
|
||||
$createBy = $val->value;
|
||||
}
|
||||
if ($val->key == 'type') {
|
||||
$type = $val->value;
|
||||
}
|
||||
if ($val->key == 'link') {
|
||||
$link = $val->value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset( $item->guid )) {
|
||||
$guid = $item->guid;
|
||||
}
|
||||
if (isset( $item->filename )) {
|
||||
$filename = $item->filename;
|
||||
}
|
||||
if (isset( $item->docId )) {
|
||||
$docId = $item->docId;
|
||||
}
|
||||
if (isset( $item->version )) {
|
||||
$version = $item->version;
|
||||
}
|
||||
if (isset( $item->createDate )) {
|
||||
$createDate = $item->createDate;
|
||||
}
|
||||
if (isset( $item->createBy )) {
|
||||
$createBy = $item->createBy;
|
||||
}
|
||||
if (isset( $item->type )) {
|
||||
$type = $item->type;
|
||||
}
|
||||
if (isset( $item->link )) {
|
||||
$link = $item->link;
|
||||
}
|
||||
}
|
||||
$rows[] = array ('guid' => $guid,'filename' => $filename,'docId' => $docId,'version' => $version,'createDate' => $createDate,'createBy' => $createBy,'type' => $type,'link' => $link);
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
/* testing//
|
||||
global $_DBArray;
|
||||
$_DBArray = (isset( $_SESSION['_DBArray'] ) ? $_SESSION['_DBArray'] : '');
|
||||
$_DBArray['inputDocument'] = $rows;
|
||||
$documentArray = array ();
|
||||
$documentArray[] = array ('guid' => 'char','filename' => 'char'
|
||||
);
|
||||
if (isset( $_DBArray['inputDocument'] )) {
|
||||
foreach ($_DBArray['inputDocument'] as $key => $val) {
|
||||
if ($key != 0 && isset( $val['filename'] )) {
|
||||
$documentArray[] = array ('guid' => $val['guid'],'filename' => $val['filename']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset( $_DBArray['outputDocument'] )) {
|
||||
foreach ($_DBArray['outputDocument'] as $key => $val) {
|
||||
if ($key != 0 && isset( $val['filename'] )) {
|
||||
$documentArray[] = array ('guid' => $val['guid'],'filename' => $val['filename']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$_DBArray['documents'] = $documentArray;
|
||||
$_DBArray['WS_TMP_CASE_UID'] = $frm["CASE_ID"];
|
||||
$_SESSION['_DBArray'] = $_DBArray;
|
||||
|
||||
G::LoadClass( 'ArrayPeer' );
|
||||
$c = new Criteria( 'dbarray' );
|
||||
$c->setDBArrayTable( 'inputDocument' );
|
||||
$c->addAscendingOrderByColumn( 'name' );
|
||||
$G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'setup/wsrInputDocumentList', $c );
|
||||
|
||||
} elseif (is_object( $result )) {
|
||||
$_SESSION['WS_SESSION_ID'] = '';
|
||||
$fields['status_code'] = $result->status_code;
|
||||
$fields['message'] = $result->message;
|
||||
$fields['time_stamp'] = date( "Y-m-d H:i:s" );
|
||||
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields );
|
||||
}
|
||||
G::RenderPage( 'publish', 'raw' );
|
||||
break;*/
|
||||
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -132,6 +132,23 @@ class FilesManager extends Api
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $prjUid {@min 32} {@max 32}
|
||||
* @param string $path
|
||||
*
|
||||
* @url DELETE /:prjUid/file-manager/folder
|
||||
*/
|
||||
public function doDeleteFolderProcessFilesManager($prjUid, $path)
|
||||
{
|
||||
try {
|
||||
$filesManager = new \BusinessModel\FilesManager();
|
||||
$filesManager->deleteFolderProcessFilesManager($prjUid, $path);
|
||||
} catch (\Exception $e) {
|
||||
//response
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ProcessFilesManagerStructure
|
||||
|
||||
@@ -59,3 +59,9 @@ debug = 1
|
||||
[alias: calendars]
|
||||
calendar = "Services\Api\ProcessMaker\Calendar"
|
||||
|
||||
[alias: case]
|
||||
case = "Services\Api\ProcessMaker\Case"
|
||||
|
||||
[alias: cases]
|
||||
case = "Services\Api\ProcessMaker\Case"
|
||||
input-document = "Services\Api\ProcessMaker\Cases\InputDocument"
|
||||
Reference in New Issue
Block a user