1 19 20 package com.sslexplorer.networkplaces; 21 22 import java.io.File ; 23 import java.util.List ; 24 25 import org.apache.commons.logging.Log; 26 import org.apache.commons.logging.LogFactory; 27 28 import com.sslexplorer.boot.ContextHolder; 29 import com.sslexplorer.extensions.ExtensionInstaller; 30 import com.sslexplorer.extensions.ExtensionInstaller.ExtensionInstallOp; 31 32 33 38 public class NetworkPlaceInstall implements ExtensionInstallOp { 39 40 final static Log log = LogFactory.getLog(NetworkPlaceInstall.class); 41 final static String VARIABLE_PATTERN = "\\$\\{[^}]*\\}"; 42 final static String PROTOTYPE_PATTERN = "_prototype_[^_]*_[^_]*_"; 43 44 47 public void doOp(ExtensionInstaller install) throws Exception { 48 NetworkPlaceDatabase npd = NetworkPlaceDatabaseFactory.getInstance(); 49 List <NetworkPlace> networkPlaces = npd.getNetworkPlaces(); 50 int errs = 0; 51 File oldTagLib = new File ("webapp" + File.separator + "WEB-INF" + File.separator + "vfs.tld"); 52 if(oldTagLib.exists()) { 53 log.info("Deleting old tag lib " + oldTagLib.getAbsolutePath()); 54 oldTagLib.delete(); 55 } 56 57 for(NetworkPlace networkPlace : networkPlaces) { 58 try { 59 NetworkPlaceUtil.convertNetworkPlace(networkPlace); 60 npd.updateNetworkPlace(networkPlace.getResourceId(), networkPlace.getScheme(), networkPlace.getResourceName(), 61 networkPlace.getResourceDescription(), networkPlace.getHost(), networkPlace.getPath(), networkPlace.getPort(), networkPlace.getUsername(), networkPlace.getPassword(), networkPlace.isReadOnly(), networkPlace.isAllowRecursive(), networkPlace.isNoDelete(), networkPlace.isShowHidden()); 62 } 63 catch(Exception e) { 64 errs ++; 65 log.error("Failed to convert network place '" + networkPlace.getResourceName() + "'. Please manually check and amend."); 66 } 67 } 68 if(errs > 0) { 69 throw new Exception ("Failed to convert " + errs + " network places. Please check the log for the names of the " + 70 "failed network places that failed and then manually amend these resources."); 71 } 72 } 73 74 77 public String getPhase() { 78 return ExtensionInstaller.ON_ACTIVATE; 79 } 80 81 } 82
| Popular Tags
|