* File documentation.
 * @package Portal
 */
require_once 'include/global.php';
require_once 'portal_app.php';
require_once 'topos.php';
function myRemoveTempFiles()
{
    global $TEMPNAM;
    exec("rm -rf {$TEMPNAM}*");
}
REST::require_method('POST', 'GET', 'HEAD');
$path_info = Portal::path_info();
$appname = @$path_info[0];
$appversion = @$path_info[1];
$portlet = Portal_App::factory($appname, $appversion);
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $user_id = Portal_User::current()->user_id();
    $applicationURL = "http://{$_SERVER['SERVER_NAME']}/gridapps/{$appname}-{$appversion}.tgz";
    $TEMPNAM = tempnam('/tmp', 'portal_');
    register_shutdown_function('myRemoveTempFiles');
    $sandbox = "{$TEMPNAM}.d/";
    mkdir($sandbox);
    $bashcode = $database = '';
    $portlet->doPOST($sandbox, $bashcode, $database);
    if (substr($database, 0, 1) === '/') {
        $database = REST::urlbase() . $database;
    }
    $database = str_replace(REST::urlbase(), 'https://' . $_SERVER['SERVER_NAME'] . ':' . Portal::PORT_SSL_CSA, $database);
    if (!empty($database) && !REST::isValidURI($database)) {
        REST::fatal(REST::HTTP_BAD_REQUEST, "{$database} is not a valid URL.");
<?php

/*·*************************************************************************
 * Copyright ©2009 SARA Computing and Networking Services
 *                 Amsterdam, the Netherlands
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * $Id: applications_versions.php 2459 2009-08-10 21:20:41Z pieterb $
 **************************************************************************/
/**
 * File documentation.
 * @package Portal
 */
require_once 'include/global.php';
require_once 'portal_app.php';
REST::require_method('GET', 'HEAD');
$directory = RESTDir::factory();
list($appname, $dummy) = Portal::path_info();
foreach (Portal_App::versions($appname) as $version) {
    $directory->line($version, array('Description' => "{$appname} version {$version}"));
}
$directory->end();
<?php

/*·*************************************************************************
 * Copyright ©2009 SARA Computing and Networking Services
 *                 Amsterdam, the Netherlands
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * $Id: applications.php 2459 2009-08-10 21:20:41Z pieterb $
 **************************************************************************/
/**
 * File documentation.
 * @package Portal
 */
require_once 'include/global.php';
require_once 'portal_app.php';
REST::require_method('GET', 'HEAD');
$directory = RESTDir::factory();
foreach (Portal_App::apps() as $app) {
    $directory->line("{$app}/");
}
$directory->end();