/**
  * Page のアクション.
  *
  * @return void
  */
 function action()
 {
     $arrParam = $_REQUEST;
     list($response_outer, $arrResponse) = SC_Api_Operation::doApiAction($arrParam);
     SC_Api_Operation_Ex::sendApiResponse('xml', $response_outer, $arrResponse);
     SC_Response_Ex::actionExit();
 }
 /**
  * Page のアクション.
  *
  * @return void
  */
 public function action()
 {
     $arrParam = $_REQUEST;
     list($response_outer, $arrResponse) = SC_Api_Operation_Ex::doApiAction($arrParam);
     if (isset($arrParam["callback"])) {
         $arrResponse["callback"] = $arrParam["callback"];
     }
     SC_Api_Operation_Ex::sendApiResponse('json', $response_outer, $arrResponse);
     SC_Response_Ex::actionExit();
 }
 /**
  * API実行
  *
  * @param array $arrPost リクエストパラメーター
  * @return array(string レスポンス名, array レスポンス配列)
  */
 public function doApiAction($arrPost)
 {
     // 実行時間計測用
     $start_time = microtime(true);
     $objFormParam = new SC_FormParam_Ex();
     SC_Api_Operation_Ex::setApiBaseParam($objFormParam);
     $objFormParam->setParam($arrPost);
     $objFormParam->convParam();
     $arrErr = SC_Api_Operation_Ex::checkParam($objFormParam);
     if (SC_Utils_Ex::isBlank($arrErr)) {
         $arrParam = $objFormParam->getHashArray();
         $operation_name = $arrParam['Operation'];
         $service_name = $arrParam['Service'];
         $style_name = $arrParam['Style'];
         $validate_flag = $arrParam['Validate'];
         $api_version = $arrParam['Version'];
         SC_Api_Utils_Ex::printApiLog('access', $start_time, $operation_name);
         // API設定のロード
         $arrApiConfig = SC_Api_Utils_Ex::getApiConfig($operation_name);
         if (SC_Api_Operation_Ex::checkOperationAuth($operation_name, $arrPost, $arrApiConfig)) {
             SC_Api_Utils_Ex::printApiLog('Authority PASS', $start_time, $operation_name);
             // オペレーション権限OK
             // API オブジェクトをロード
             $objApiOperation = SC_Api_Utils_Ex::loadApiOperation($operation_name, $arrParam);
             if (is_object($objApiOperation) && method_exists($objApiOperation, 'doAction')) {
                 // API オペレーション実行
                 $operation_result = $objApiOperation->doAction($arrPost);
                 // オペレーション結果処理
                 if ($operation_result) {
                     $arrOperationRequestValid = $objApiOperation->getRequestValidate();
                     $arrResponseBody = $objApiOperation->getResponseArray();
                     $response_group_name = $objApiOperation->getResponseGroupName();
                 } else {
                     $arrErr = $objApiOperation->getErrorArray();
                 }
             } else {
                 $arrErr['ECCUBE.Operation.NoLoad'] = 'オペレーションをロード出来ませんでした。';
             }
         } else {
             $arrErr['ECCUBE.Authority.NoAuthority'] = 'オペレーションの実行権限がありません。';
         }
     }
     if (count($arrErr) == 0) {
         // 実行成功
         $arrResponseValidSection = array('Request' => array('IsValid' => 'True', $operation_name . 'Request' => $arrOperationRequestValid));
         $response_outer = $operation_name . 'Response';
         SC_Api_Utils_Ex::printApiLog('Operation SUCCESS', $start_time, $response_outer);
     } else {
         // 実行失敗
         $arrResponseErrorSection = array();
         foreach ($arrErr as $error_code => $error_msg) {
             $arrResponseErrorSection[] = array('Code' => $error_code, 'Message' => $error_msg);
         }
         $arrResponseValidSection = array('Request' => array('IsValid' => 'False', 'Errors' => array('Error' => $arrResponseErrorSection)));
         if (is_object($objApiOperation)) {
             $response_outer = $operation_name . 'Response';
         } else {
             $response_outer = 'ECCUBEApiCommonResponse';
         }
         SC_Api_Utils_Ex::printApiLog('Operation FAILED', $start_time, $response_outer);
     }
     $arrResponse = array();
     $arrResponse['OperationRequest'] = SC_Api_Operation_Ex::getOperationRequestEcho($arrPost, $start_time);
     $arrResponse[$response_group_name] = array();
     // Items
     $arrResponse[$response_group_name] = $arrResponseValidSection;
     if (is_array($arrResponseBody)) {
         $arrResponse[$response_group_name] = array_merge((array) $arrResponse[$response_group_name], (array) $arrResponseBody);
     }
     return array($response_outer, $arrResponse);
 }