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; 017 018import java.io.File; 019import java.util.ArrayList; 020 021import org.codehaus.plexus.util.StringUtils; 022import org.kuali.common.util.scm.ScmRequest; 023import org.springframework.util.Assert; 024 025/** 026 * @deprecated 027 */ 028@Deprecated 029public class ScmUtils { 030 031 /** 032 * Use <code>ScmConfig</code> instead 033 */ 034 @Deprecated 035 public static org.kuali.common.util.service.ScmService getScmService(String url) { 036 Assert.hasText(url, "URL has no text"); 037 // scm:svn:https://svn.kuali.org/repos/student/trunk 038 String[] tokens = StringUtils.split(url, ":"); 039 String scmType = tokens[1].toUpperCase(); 040 org.kuali.common.util.service.ScmType type = org.kuali.common.util.service.ScmType.valueOf(scmType); 041 switch (type) { 042 case SVN: 043 return new org.kuali.common.util.service.SvnService(); 044 case GIT: 045 throw new IllegalArgumentException("GIT support is coming soon!"); 046 default: 047 throw new IllegalArgumentException("SCM type [" + scmType + "] is unknown"); 048 } 049 } 050 051 public static ScmRequest cloneOrNew(ScmRequest request) { 052 if (request == null) { 053 return new ScmRequest(); 054 } else { 055 return clone(request); 056 } 057 } 058 059 public static ScmRequest clone(ScmRequest request) { 060 ScmRequest clone = new ScmRequest(); 061 clone.setCommitMessage(request.getCommitMessage()); 062 063 if (!CollectionUtils.isEmpty(request.getAdds())) { 064 clone.setAdds(new ArrayList<File>(request.getAdds())); 065 } 066 067 if (!CollectionUtils.isEmpty(request.getDeletes())) { 068 clone.setDeletes(new ArrayList<File>(request.getDeletes())); 069 } 070 071 if (!CollectionUtils.isEmpty(request.getCommits())) { 072 clone.setCommits(new ArrayList<File>(request.getCommits())); 073 } 074 return clone; 075 } 076 077}