001/** 002 * Copyright 2010-2014 The Kuali Foundation 003 * 004 * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php 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.kuali.common.util.spring; 017 018import java.io.File; 019 020import org.kuali.common.util.Assert; 021import org.kuali.common.util.LocationUtils; 022import org.springframework.beans.factory.FactoryBean; 023 024/** 025 * @deprecated 026 */ 027@Deprecated 028public class ArtifactPathFactoryBean extends org.kuali.common.util.Artifact implements FactoryBean<String> { 029 030 File localRepositoryDir = org.kuali.common.util.RepositoryUtils.getDefaultLocalRepositoryDir(); 031 boolean mustExist; 032 033 @Override 034 public String getObject() { 035 036 Assert.notNull(localRepositoryDir); 037 Assert.hasText(getGroupId()); 038 Assert.hasText(getArtifactId()); 039 Assert.hasText(getVersion()); 040 Assert.hasText(getType()); 041 042 File file = org.kuali.common.util.RepositoryUtils.getFile(localRepositoryDir, this); 043 validate(file); 044 return LocationUtils.getCanonicalPath(file); 045 } 046 047 protected void validate(File file) { 048 if (!file.exists() && mustExist) { 049 throw new IllegalStateException(file + " does not exist"); 050 } 051 } 052 053 @Override 054 public Class<String> getObjectType() { 055 return String.class; 056 } 057 058 @Override 059 public boolean isSingleton() { 060 return false; 061 } 062 063 public File getLocalRepositoryDir() { 064 return localRepositoryDir; 065 } 066 067 public void setLocalRepositoryDir(File localRepositoryDir) { 068 this.localRepositoryDir = localRepositoryDir; 069 } 070 071 public boolean isMustExist() { 072 return mustExist; 073 } 074 075 public void setMustExist(boolean mustExist) { 076 this.mustExist = mustExist; 077 } 078 079}