001/** 002 * Copyright 2014 Tampere University of Technology, Pori Department 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 service.tut.pori.fileservice; 017 018import java.util.Properties; 019 020import org.apache.commons.lang3.StringUtils; 021 022import core.tut.pori.properties.SystemProperty; 023 024/** 025 * System properties for File Service. 026 */ 027public class FileProperties extends SystemProperty { 028 private static final String PROPERTY_SERVICE_PORI_FILE_SERVICE = PROPERTY_SERVICE_PORI+".fileservice"; 029 private static final String PROPERTY_SERVICE_PORI_FILE_SERVICE_FILE_PATH = PROPERTY_SERVICE_PORI_FILE_SERVICE+".file_path"; 030 private static final String PROPERTY_SERVICE_PORI_FILE_SERVICE_URI_PATH = PROPERTY_SERVICE_PORI_FILE_SERVICE+".uri_path"; 031 private String _filePath = null; 032 private String _uriPath = null; 033 034 @Override 035 public void initialize(Properties properties) throws IllegalArgumentException { 036 _filePath = properties.getProperty(PROPERTY_SERVICE_PORI_FILE_SERVICE_FILE_PATH); 037 _uriPath = properties.getProperty(PROPERTY_SERVICE_PORI_FILE_SERVICE_URI_PATH); 038 if(StringUtils.isBlank(_filePath) || StringUtils.isBlank(_uriPath)){ 039 throw new IllegalArgumentException("Bad "+PROPERTY_SERVICE_PORI_FILE_SERVICE_FILE_PATH+" or "+PROPERTY_SERVICE_PORI_FILE_SERVICE_URI_PATH); 040 } 041 } 042 043 /** 044 * @return the file system path where the actual files are located 045 */ 046 public String getFilePath() { 047 return _filePath; 048 } 049 050 /** 051 * @return the uriPath 052 */ 053 public String getUriPath() { 054 return _uriPath; 055 } 056 057 @Override 058 public String getPropertyFilePath() { 059 return CONFIGURATION_FILE_PATH+Definitions.PROPERTY_FILE; 060 } 061}