public function application_webapp_remove($application_id) { $this->check_authorized('manageApplications'); $applicationDB = ApplicationDB::getInstance(); if (!$applicationDB->isWriteable()) { Logger::error('api', 'ApplicationDB is not writable'); return false; } $webapp_application_DB = WebAppConfDB::getInstance(); if (!$webapp_application_DB->isWriteable()) { Logger::info('api', 'WebAppConfDB is not writable'); return null; } $app = $applicationDB->import($application_id); if (!is_object($app)) { Logger::error('api', 'Unknown web application "' . $application_id . '"'); return false; } $webapp_configuration_object = $webapp_application_DB->search($application_id); if ($webapp_configuration_object != NULL) { $webapp_application_DB->remove($webapp_configuration_object); } $ret = $applicationDB->remove($app); if (!$ret) { Logger::error('api', sprintf("Failed to delete web application '%s'", $app->getAttribute('name'))); return false; } $servers = Abstract_Server::load_available_by_role('webapps', true); foreach ($servers as $server) { $server->syncWebApplications(); } $this->log_action('application_webapp_clone', array('id' => $app->getAttribute('id'), 'name' => $app->getAttribute('name'))); return true; }
require_once dirname(__FILE__) . '/../includes/core-minimal.inc.php'; require_once dirname(__FILE__) . '/../includes/webservices.inc.php'; $server = webservices_load_server($_SERVER['REMOTE_ADDR']); if (!$server) { Logger::error('main', '(webservices/applications/webapps) Server does not exist (error_code: 0)'); webservices_return_error(1, 'Server does not exist'); } if (!$server->isAuthorized()) { Logger::error('main', '(webservices/applications/webapps) Server is not authorized (error_code: 2)'); webservices_return_error(2, 'Server is not authorized'); } header('Content-Type: text/xml; charset=utf-8'); $dom = new DomDocument('1.0', 'utf-8'); $node = $dom->createElement('webapps'); $applicationDB = ApplicationDB::getInstance(); $webapp_application_DB = WebAppConfDB::getInstance(); $applications = $applicationDB->getList('webapp'); if (is_array($applications)) { foreach ($applications as $app) { $app_node = $dom->createElement('webapp'); $app_node->setAttribute('id', $app->getAttribute('id')); $app_node->setAttribute('name', $app->getAttribute('name')); $app_node->setAttribute('description', $app->getAttribute('description')); $app_node->setAttribute('revision', $app->getAttribute('revision')); $webapp_configuration_object = $webapp_application_DB->search($app->getAttribute('id')); if ($webapp_configuration_object != NULL) { $configuration = $webapp_configuration_object->getUpdatedConfguration(); $config_node = $dom->createElement('configuration'); $config_node->appendChild($dom->createCDATASection($configuration)); $app_node->appendChild($config_node); }