001/* 002 * Copyright 2021 Anyware Services 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 */ 016package org.ametys.plugins.joboffer.transformation; 017 018import org.apache.avalon.framework.activity.Initializable; 019import org.apache.commons.lang.StringUtils; 020 021import org.ametys.cms.transformation.URIResolver; 022import org.ametys.plugins.repository.data.ametysobject.ModelAwareDataAwareAmetysObject; 023import org.ametys.runtime.config.Config; 024 025/** 026 * {@link URIResolver} for type "joboffer-attribute".<br> 027 */ 028public class AttributeURIResolver extends org.ametys.cms.transformation.AttributeURIResolver implements Initializable 029{ 030 private String _baseURL; 031 032 public void initialize() throws Exception 033 { 034 _baseURL = StringUtils.stripEnd(StringUtils.removeEndIgnoreCase(Config.getInstance().getValue("cms.url"), "index.html"), "/"); 035 } 036 037 @Override 038 public String getType() 039 { 040 return "joboffer-attribute"; 041 } 042 043 @Override 044 protected String getUri(String path, ModelAwareDataAwareAmetysObject object, boolean download, boolean absolute, boolean internal) 045 { 046 // Override getUri method to have BO URI for job offer attribute (because application contents are never published in live) 047 return internal 048 ? super.getUri(path, object, download, absolute, internal) 049 : _baseURL + path; 050 } 051}