<commit_before>/*
 * Copyright  1999-2004 The Apache Software Foundation
 *
 *  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$  */

package org.apache.lenya.cms.publication;

/**
 * This class resolves all Lenya-specific information from a webapp URL.
 */
public class URLInformation {

    private String publicationId = null;
    private String area = null;
    private String completeArea = null;
    private String documentUrl = null;

    /**
     * Returns the area (without the "info-" prefix).
     * @return A string.
     */
    public String getArea() {
        return this.area;
    }

    /**
     * Returns the complete area (including the "info-" prefix).
     * @return A string.
     */
    public String getCompleteArea() {
        return this.completeArea;
    }

    /**
     * Returns the document URL.
     * @return A string.
     */
    public String getDocumentUrl() {
        return this.documentUrl;
    }

    /**
     * Returns the publication ID.
     * @return A string.
     */
    public String getPublicationId() {
        return this.publicationId;
    }

    /**
     * Ctor.
     * @param webappUrl A webapp URL (without context prefix).
     */
    public URLInformation(String webappUrl) {
        assert webappUrl.startsWith("/");

        String url = webappUrl.substring(1);

        String[] fragments = url.split("/");
        if (fragments.length > 0) {
            this.publicationId = fragments[0];

            if (fragments.length > 1) {
                this.completeArea = fragments[1];
<commit_msg>Replaced assertion with Exception in URLInformation<commit_after>/*
 * Copyright  1999-2004 The Apache Software Foundation
 *
 *  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$  */

package org.apache.lenya.cms.publication;

/**
 * This class resolves all Lenya-specific information from a webapp URL.
 */
public class URLInformation {

    private String publicationId = null;
    private String area = null;
    private String completeArea = null;
    private String documentUrl = null;

    /**
     * Returns the area (without the "info-" prefix).
     * @return A string.
     */
    public String getArea() {
        return this.area;
    }

    /**
     * Returns the complete area (including the "info-" prefix).
     * @return A string.
     */
    public String getCompleteArea() {
        return this.completeArea;
    }

    /**
     * Returns the document URL.
     * @return A string.
     */
    public String getDocumentUrl() {
        return this.documentUrl;
    }

    /**
     * Returns the publication ID.
     * @return A string.
     */
    public String getPublicationId() {
        return this.publicationId;
    }

    /**
     * Ctor.
     * @param webappUrl A webapp URL (without context prefix).
     */
    public URLInformation(String webappUrl) {
        
        if (!webappUrl.startsWith("/")) {
            throw new RuntimeException("The URL [" + webappUrl + "] doesn't start with a slash!");
        }

        String url = webappUrl.substring(1);

        String[] fragments = url.split("/");
        if (fragments.length > 0) {
            this.publicationId = fragments[0];

            if (fragments.length > 1) {
                this.completeArea = fragments[1];

{'fraction_non_alphanumeric': 0.09902597402597403, 'fraction_numerical': 0.007884972170686457, 'mean_word_length': 2.3460046547711406, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4822369', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1156, 'n_words': 419}