001/*
002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     <a href="mailto:glefevre@nuxeo.com">Gildas</a>
018 */
019package org.nuxeo.ecm.user.center;
020
021import org.nuxeo.ecm.platform.url.api.DocumentView;
022
023/**
024 * Codec handling a groupname, an optional view and additional request parameters.
025 *
026 * @since 6.0
027 */
028public class GroupCodec extends AbstractUserGroupCodec {
029
030    public static final String PREFIX = "group";
031
032    public static final String DEFAULT_GROUPS_TAB = "USER_CENTER:UsersGroupsHome:GroupsHome";
033
034    @Override
035    public String getPrefix() {
036        if (prefix != null) {
037            return prefix;
038        }
039        return PREFIX;
040    }
041
042    @Override
043    public DocumentView getDocumentViewFromUrl(String url) {
044
045        return getDocumentViewFromUrl(url, DEFAULT_GROUPS_TAB, "groupname", "showGroup");
046    }
047
048    @Override
049    public String getUrlFromDocumentView(DocumentView docView) {
050        return getUrlFromDocumentViewAndID(docView, "groupname");
051    }
052
053}