16 private static $entityList = [
17 self::REST_APPLICATION => 100,
20 private static $accessManifest = [
27 return static::$entityList;
51 !static::$entityList[$code]
58 if (static::checkRequiredParams($code))
64 case 'REST_APPLICATION':
65 $result = static::exportApp($step, $setting);
76 if (!static::checkAccessImport($event))
82 if (static::checkRequiredParams($code))
87 case 'REST_APPLICATION':
88 $result = static::clearApp($option);
99 if (!static::checkAccessImport($event))
105 if (static::checkRequiredParams($code))
110 case 'REST_APPLICATION':
111 $result = static::importApp($data);
119 private static function checkAccessImport(
Event $event)
123 !isset(static::$entityList[$code])
124 || !static::$entityList[$code]
139 private static function checkRequiredParams($type)
145 private static function importApp($item)
148 if (!empty($item[
'CONTENT'][
'DATA'][
'code']))
150 $code = preg_replace(
'/[^a-zA-Z0-9._\-]/',
'', $item[
'CONTENT'][
'DATA'][
'code']);
151 if ($code !== $item[
'CONTENT'][
'DATA'][
'code'])
154 'ERROR_EXCEPTION' => [
156 'REST_CONFIGURATION_ERROR_UNKNOWN_APP'
162 Application::setContextUserId((
int)$item[
'USER_ID']);
163 $result = Application::install($code);
164 if ($result[
'success'])
166 $res = AppTable::getList(
172 '!=URL_INSTALL' =>
false,
177 if ($app = $res->fetch())
179 $res = EventTable::getList(
182 "APP_ID" => $app[
'ID'],
183 "EVENT_NAME" =>
"ONAPPINSTALL",
184 "EVENT_HANDLER" => $app[
"URL_INSTALL"],
189 if (!$event = $res->fetch())
191 $res = EventTable::add(
193 "APP_ID" => $app[
'ID'],
194 "EVENT_NAME" =>
"ONAPPINSTALL",
195 "EVENT_HANDLER" => $app[
"URL_INSTALL"],
198 if ($res->isSuccess())
218 elseif (is_array($result) && $result[
'errorDescription'])
221 'REST_CONFIGURATION_ERROR_INSTALL_APP_CONTENT_DATA',
223 '#ERROR_CODE#' => $result[
'error'],
224 '#ERROR_MESSAGE#' => $result[
'errorDescription'],
231 'REST_CONFIGURATION_ERROR_INSTALL_APP_CONTENT'
238 'ERROR_EXCEPTION' => [
240 'REST_CONFIGURATION_ERROR_UNKNOWN_APP'
249 private static function clearApp($option)
254 if ($option[
'CLEAR_FULL'])
256 $dbRes = AppTable::getList(
264 '>ID' => $option[
'NEXT']
270 while ($appInfo = $dbRes->Fetch())
272 $result[
'NEXT'] = $appInfo[
'ID'];
275 if (!empty($option[
'CONTEXT']) && $option[
'CONTEXT'] === $currentApp)
280 $checkResult = AppTable::checkUninstallAvailability($appInfo[
'ID']);
281 if ($checkResult->isEmpty())
288 AppTable::update($appInfo[
'ID'], $appFields);
310 if (is_array($setting))
312 if (!empty($setting[
'APP_REQUIRED']) && is_array($setting[
'APP_REQUIRED']))
319 '=ID' => $setting[
'APP_REQUIRED'],
324 elseif (array_key_exists(
'APP_USES_REQUIRED', $setting))
327 if (!empty($setting[
'APP_USES_REQUIRED']))
330 '=ID' => $setting[
'APP_USES_REQUIRED'],
338 $res = AppTable::getList(
353 if ($app = $res->Fetch())
355 $return[
'FILE_NAME'] = $step;
356 $return[
'NEXT'] = $step;
357 $return[
'CONTENT'] = [
358 'code' => $app[
'CODE'],
static getMessage($code, $replace=null, $language=null)