001/*
002 * (C) Copyright 2006-2009 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 * $Id$
018 */
019
020package org.nuxeo.ecm.platform.web.common.ajax.service;
021
022import java.util.regex.Pattern;
023
024import org.nuxeo.common.xmap.annotation.XNode;
025import org.nuxeo.common.xmap.annotation.XObject;
026
027/**
028 * Simple Descriptor for a proxyable URL config.
029 *
030 * @author tiry
031 */
032@XObject("proxyableURL")
033public class ProxyableURLDescriptor {
034
035    @XNode("@name")
036    protected String name;
037
038    @XNode("@enabled")
039    protected boolean enabled = true;
040
041    @XNode("@userCache")
042    protected boolean useCache;
043
044    @XNode("@cachePerSession")
045    protected boolean cachePerSession;
046
047    @XNode("pattern")
048    protected String pattern;
049
050    protected Pattern compiledPattern;
051
052    public String getName() {
053        if (name == null) {
054            return pattern;
055        }
056        return name;
057    }
058
059    public Pattern getCompiledPattern() {
060        if (compiledPattern == null) {
061            compiledPattern = Pattern.compile(pattern);
062        }
063        return compiledPattern;
064    }
065
066    public void merge(ProxyableURLDescriptor other) {
067        // TODO
068    }
069
070    public boolean isEnabled() {
071        return enabled;
072    }
073
074}