<commit_before><?php
/*
 * Copyright 2018 <NAME>
 *
 * 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.
 */

/**
 *  resto
 *
 *  This class should be instantiate with
 *
 *      $resto = new Resto();
 *
 * Access to resource
 * ==================
 *
 * General url template
 * --------------------
 *
 *      http(s)://host/resto/collections/{collection}.json?key1=value1&key2=value2&...
 *      \__________________/\_______________________/\____/\___________________________/
 *            baseUrl                   path         format          query
 *
 *      Where :
 *
 *          {collection} is the name of the collection (e.g. 'Charter', 'SPIRIT', etc.)
 *
 * Query
 * -----
 *
 *   Query parameters are described within OpenSearch Description file
 *
 *   Special query parameters can be used to modify the query. These parameters are not specified
 *   within the OpenSearch Description file. Below is the list of Special query parameters
 *
 *
 *    | Query parameter    |      Type      | Description
 *    |______________________________________________________________________________________________
 *    | _pretty            |     boolean    | (For JSON output only) true to return pretty print JSON
 *    
 *
 * Returned error
 * --------------
 *
 *   - HTTP 400 'Bad Request' for invalid request
 *   - HTTP 403 'Forbiden' when accessing protected resource/service with invalid credentials
 *   - HTTP 404 'Not Found' when accessing non existing resource/service
 *   - HTTP 405 'Method Not Allowed' when accessing existing resource/service with unallowed HTTP method
 *   - HTTP 412 'Precondition failed' when existing but non activated user try to connect
 *   - HTTP 500 'Internal Server Error' for technical errors (i.e. database connection error, etc.)
 *
 * Open API
 * ========
 *
 * @OA\OpenApi(
 *   @OA\Info(
 *       title=API_INFO_TITLE,
 *       description=API_INFO_DESCRIPTION,
 *       version="6.0.0",
 *       @OA\Contact(
 *           email=API_INFO_CONTACT_EMAIL
 *       )
 *   ),
 *   @OA\Server(
 *       description=API_HOST_DESCRIPTION,
 *       url=PUBLIC_ENDPOINT
 *   )
 *  )
 */

class Resto
{

    /*
     * Default routes
     */
    private $defaultRoutes = array(

        // Landing page and conformance (see WFS 3.0)
        array('GET',    '/', false, 'ServicesAPI::hello'),                                                                                  // Landing page
        array('GET',    '/api', false, 'ServicesAPI::api'),                                                                                 // API page
        array('GET',    '/conformance', false, 'ServicesAPI::conformance'),                                                                 // Conformance page

        // API for users
        array('GET',    '/users', true, 'UsersAPI::getUsersProfiles'),                                                                      // List users profiles
        array('POST',   '/users', false, 'UsersAPI::createUser'),                                                                           // Create user
        array('GET',    '/users/{userid}', true, 'UsersAPI::getUserProfile'),                                                               // Show user profile
        array('PUT',    '/users/{userid}', true, 'UsersAPI::updateUserProfile'),                                                            // Update :userid profile
        array('GET',    '/users/{userid}/logs', true, 'UsersAPI::getUserLogs'),                                                             // Show user logs
        array('GET',    '/users/{userid}/rights', true, 'UsersAPI::getUserRights'),                                                         // Show user rights
        array('GET',    '/users/{userid}/rights/{collectionId}', true, 'UsersAPI::getUserRights'),                                          // Show user rights for :collectionId
        array('GET',    '/users/{userid}/rights/{collectionId}/{featureId}', true, 'UsersAPI::getUserRights'),                              // Show user rights for :featureId
        
        // API for collections
        array('GET',    '/collections', false, 'CollectionsAPI::getCollections'),                                                           // List all collections
        array('POST',   '/collections', true, 'CollectionsAPI::createCollection'),                                                          // Create collection
        array('GET',    '/collections/{collectionId}', false, 'CollectionsAPI::getCollection'),                                             // Get :collectionId description
        array('PUT',    '/collections/{collectionId}', true, 'CollectionsAPI::updateCollection'),                                           // Update :collectionId
        array('DELETE', '/collections/{collectionId}', true, 'CollectionsAPI::deleteCollection'),                                           // Delete :collectionId

        // API for features
        array('GET',    '/collections/{collectionId}/items', false, 'FeaturesAPI::getFeaturesInCollection'),                                // Search features in :collectionId
        array('POST',   '/collections/{collectionId}/items', array('auth' => true, 'upload' => 'files'), 'CollectionsAPI::insertFeatures'), // Insert feature(s)
        array('GET',    '/collections/{collectionId}/items/{featureId}', false, 'FeaturesAPI::getFeature'),                                 // Get feature :featureId
        array('PUT',    '/collections/{collectionId}/items/{featureId}', true, 'FeaturesAPI::updateFeature'),                               // Update feature :featureId
        array('DELETE', '/collections/{collectionId}/items/{featureId}', true, 'FeaturesAPI::deleteFeature'),                               // Delete :featureId
        array('PUT',    '/collections/{collectionId}/items/{featureId}/properties/{property}', true, 'FeaturesAPI::updateFeatureProperty'), // Update feature :featureId single property 
        
        // API for authentication (token based)
        array('GET',    '/auth', true, 'AuthAPI::getToken'),                                                                                // Return a valid auth token
        array('GET',    '/auth/check/{token}', false, 'AuthAPI::checkToken'),                                                               // Check auth token validity
        array('DELETE', '/auth/revoke/{token}', true, 'AuthAPI::revokeToken'),                                                              // Revoke auth token
        array('PUT',    '/auth/activate/{token}', false, 'AuthAPI::activateUser'),                                                          // Activate owner of the token

        // API for services
        array('GET',    '/services/osdd', false, 'ServicesAPI::getOSDD'),                                                                   // Opensearch service description at collections level
        array('GET',    '/services/osdd/{collectionId}', false, 'ServicesAPI::getOSDDForCollection'),                                       // Opensearch service description for products on {collection}
        array('POST',   '/services/activation/send', false, 'ServicesAPI::sendActivationLink'),                                             // Send activation link
        array('POST',   '/services/password/forgot', false, 'ServicesAPI::forgotPassword'),                                                 // Send reset password link
        array('POST',   '/services/password/reset', false, 'ServicesAPI::resetPassword'),                                                   // Reset password

        // STAC
        array('GET',    '/search', false, 'STAC::search'),                                                                                  // STAC API   
        array('GET',    '/assets/{urlInBase64}', false, 'STAC::getAsset')                                                                   // Get an asset using HTTP 301 permanent redirect
    );

    // resto version
    const VERSION = '6.1.8';

    /* ============================================================
     *              NEVER EVER TOUCH THESE VALUES
     * ============================================================*/

    // PostgreSQL max value for integer
    const INT_MAX_VALUE = 2147483647;

    // Group identifier for administrator group
    const GROUP_ADMIN_ID = 0;

    // Group identifier for default group (every user is in default group)
    const GROUP_DEFAULT_ID = 100;

    // Separator for hashtags identifiers - should be the same as iTag
    const TAG_SEPARATOR = ':';

    /* ============================================================ */

    /*
     * RestoContext
     */
    public $context;

    /*
     * RestoUser
     */<commit_msg>Set version to resto 7.0.0-rc.1<commit_after><?php
/*
 * Copyright 2018 <NAME>
 *
 * 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.
 */

/**
 *  resto
 *
 *  This class should be instantiate with
 *
 *      $resto = new Resto();
 *
 * Access to resource
 * ==================
 *
 * General url template
 * --------------------
 *
 *      http(s)://host/resto/collections/{collection}.json?key1=value1&key2=value2&...
 *      \__________________/\_______________________/\____/\___________________________/
 *            baseUrl                   path         format          query
 *
 *      Where :
 *
 *          {collection} is the name of the collection (e.g. 'Charter', 'SPIRIT', etc.)
 *
 * Query
 * -----
 *
 *   Query parameters are described within OpenSearch Description file
 *
 *   Special query parameters can be used to modify the query. These parameters are not specified
 *   within the OpenSearch Description file. Below is the list of Special query parameters
 *
 *
 *    | Query parameter    |      Type      | Description
 *    |______________________________________________________________________________________________
 *    | _pretty            |     boolean    | (For JSON output only) true to return pretty print JSON
 *    
 *
 * Returned error
 * --------------
 *
 *   - HTTP 400 'Bad Request' for invalid request
 *   - HTTP 403 'Forbiden' when accessing protected resource/service with invalid credentials
 *   - HTTP 404 'Not Found' when accessing non existing resource/service
 *   - HTTP 405 'Method Not Allowed' when accessing existing resource/service with unallowed HTTP method
 *   - HTTP 412 'Precondition failed' when existing but non activated user try to connect
 *   - HTTP 500 'Internal Server Error' for technical errors (i.e. database connection error, etc.)
 *
 * Open API
 * ========
 *
 * @OA\OpenApi(
 *   @OA\Info(
 *       title=API_INFO_TITLE,
 *       description=API_INFO_DESCRIPTION,
 *       version="6.0.0",
 *       @OA\Contact(
 *           email=API_INFO_CONTACT_EMAIL
 *       )
 *   ),
 *   @OA\Server(
 *       description=API_HOST_DESCRIPTION,
 *       url=PUBLIC_ENDPOINT
 *   )
 *  )
 */

class Resto
{

    /*
     * Default routes
     */
    private $defaultRoutes = array(

        // Landing page and conformance (see WFS 3.0)
        array('GET',    '/', false, 'ServicesAPI::hello'),                                                                                  // Landing page
        array('GET',    '/api', false, 'ServicesAPI::api'),                                                                                 // API page
        array('GET',    '/conformance', false, 'ServicesAPI::conformance'),                                                                 // Conformance page

        // API for users
        array('GET',    '/users', true, 'UsersAPI::getUsersProfiles'),                                                                      // List users profiles
        array('POST',   '/users', false, 'UsersAPI::createUser'),                                                                           // Create user
        array('GET',    '/users/{userid}', true, 'UsersAPI::getUserProfile'),                                                               // Show user profile
        array('PUT',    '/users/{userid}', true, 'UsersAPI::updateUserProfile'),                                                            // Update :userid profile
        array('GET',    '/users/{userid}/logs', true, 'UsersAPI::getUserLogs'),                                                             // Show user logs
        array('GET',    '/users/{userid}/rights', true, 'UsersAPI::getUserRights'),                                                         // Show user rights
        array('GET',    '/users/{userid}/rights/{collectionId}', true, 'UsersAPI::getUserRights'),                                          // Show user rights for :collectionId
        array('GET',    '/users/{userid}/rights/{collectionId}/{featureId}', true, 'UsersAPI::getUserRights'),                              // Show user rights for :featureId
        
        // API for collections
        array('GET',    '/collections', false, 'CollectionsAPI::getCollections'),                                                           // List all collections
        array('POST',   '/collections', true, 'CollectionsAPI::createCollection'),                                                          // Create collection
        array('GET',    '/collections/{collectionId}', false, 'CollectionsAPI::getCollection'),                                             // Get :collectionId description
        array('PUT',    '/collections/{collectionId}', true, 'CollectionsAPI::updateCollection'),                                           // Update :collectionId
        array('DELETE', '/collections/{collectionId}', true, 'CollectionsAPI::deleteCollection'),                                           // Delete :collectionId

        // API for features
        array('GET',    '/collections/{collectionId}/items', false, 'FeaturesAPI::getFeaturesInCollection'),                                // Search features in :collectionId
        array('POST',   '/collections/{collectionId}/items', array('auth' => true, 'upload' => 'files'), 'CollectionsAPI::insertFeatures'), // Insert feature(s)
        array('GET',    '/collections/{collectionId}/items/{featureId}', false, 'FeaturesAPI::getFeature'),                                 // Get feature :featureId
        array('PUT',    '/collections/{collectionId}/items/{featureId}', true, 'FeaturesAPI::updateFeature'),                               // Update feature :featureId
        array('DELETE', '/collections/{collectionId}/items/{featureId}', true, 'FeaturesAPI::deleteFeature'),                               // Delete :featureId
        array('PUT',    '/collections/{collectionId}/items/{featureId}/properties/{property}', true, 'FeaturesAPI::updateFeatureProperty'), // Update feature :featureId single property 
        
        // API for authentication (token based)
        array('GET',    '/auth', true, 'AuthAPI::getToken'),                                                                                // Return a valid auth token
        array('GET',    '/auth/check/{token}', false, 'AuthAPI::checkToken'),                                                               // Check auth token validity
        array('DELETE', '/auth/revoke/{token}', true, 'AuthAPI::revokeToken'),                                                              // Revoke auth token
        array('PUT',    '/auth/activate/{token}', false, 'AuthAPI::activateUser'),                                                          // Activate owner of the token

        // API for services
        array('GET',    '/services/osdd', false, 'ServicesAPI::getOSDD'),                                                                   // Opensearch service description at collections level
        array('GET',    '/services/osdd/{collectionId}', false, 'ServicesAPI::getOSDDForCollection'),                                       // Opensearch service description for products on {collection}
        array('POST',   '/services/activation/send', false, 'ServicesAPI::sendActivationLink'),                                             // Send activation link
        array('POST',   '/services/password/forgot', false, 'ServicesAPI::forgotPassword'),                                                 // Send reset password link
        array('POST',   '/services/password/reset', false, 'ServicesAPI::resetPassword'),                                                   // Reset password

        // STAC
        array('GET',    '/search', false, 'STAC::search'),                                                                                  // STAC API   
        array('GET',    '/assets/{urlInBase64}', false, 'STAC::getAsset')                                                                   // Get an asset using HTTP 301 permanent redirect
    );

    // resto version
    const VERSION = '7.0.0-rc.1';

    /* ============================================================
     *              NEVER EVER TOUCH THESE VALUES
     * ============================================================*/

    // PostgreSQL max value for integer
    const INT_MAX_VALUE = 2147483647;

    // Group identifier for administrator group
    const GROUP_ADMIN_ID = 0;

    // Group identifier for default group (every user is in default group)
    const GROUP_DEFAULT_ID = 100;

    // Separator for hashtags identifiers - should be the same as iTag
    const TAG_SEPARATOR = ':';

    /* ============================================================ */

    /*
     * RestoContext
     */
    public $context;

    /*
     * RestoUser
     */
{'fraction_non_alphanumeric': 0.1347300564061241, 'fraction_numerical': 0.006392694063926941, 'mean_word_length': 1.596011713847441, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 134, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5361224', 'n_tokens_mistral': 4091, 'n_tokens_neox': 3935, 'n_words': 1168}