<?php
import("com.laurus.core.actions.CoreActionHttp");
import("com.laurus.core.services.ServiceManager");
import("com.laurus.kayo.services.api.IFileSystemService");
import("com.laurus.main.auth.services.api.IKayoAuthConstant");


/**
 * Description of ActMakePackageFilePath
 *
 * @author Amruta Vichare
 */
class ActMakeTempFilePath extends CoreActionHttp{
     protected $logger;
      
    public function  __construct() {
        $this->logger = Logger::getLogger(__CLASS__);
    }
    public function executeInvoke(\HttpRequest $wr) {
        /* @var $image Image*/
        $image=$wr->getCommandAttribute("aimage",true);
        $this->logger->debug($image);
         /* @var $mFileServiceobj IFileSystemService */
        $mFileServiceobj=ServiceManager::getInstance()->getService(IFileSystemService::NAME);
        $path='tmp'.DIRECTORY_SEPARATOR.'files'.DIRECTORY_SEPARATOR ;
        $newPath=$path.$image->getId().$mFileServiceobj->getFileExtension($image->getImageName());
        $image->setImagePath(base64_encode($newPath));
         if (!$mFileServiceobj->fileExsistOrNot($path)) {
            $mFileServiceobj->createDirectory($path);
        } else {
            
        }
        $fullpath = $mFileServiceobj->createFile($newPath);
        $header=new Map();
        $this->logger->debug(base64_encode($newPath));
        $header->put("path", base64_encode($image->getId()));
        $header->put("filetype", base64_encode("image"));
        $_REQUEST["HEADER_CONTAINER"]=$header;
        $wr->setJSONResponseBean($image);
        $fileList=new SimpleList();
        $fileList->add($image);
        return $fileList;
        //nothing to return from here
    }
   
}

?>
