1 19 20 package com.sslexplorer.extensions; 21 22 import java.io.IOException ; 23 24 import javax.servlet.http.HttpServletRequest ; 25 import javax.servlet.http.HttpServletResponse ; 26 27 import org.apache.struts.Globals; 28 import org.apache.struts.action.ActionForward; 29 import org.apache.struts.action.ActionMessages; 30 import org.apache.struts.upload.FormFile; 31 32 import com.sslexplorer.core.BundleActionMessage; 33 import com.sslexplorer.core.CoreException; 34 import com.sslexplorer.core.CoreUtil; 35 import com.sslexplorer.core.GlobalWarning; 36 import com.sslexplorer.core.PopupException; 37 import com.sslexplorer.core.UploadHandler; 38 import com.sslexplorer.extensions.store.ExtensionStore; 39 import com.sslexplorer.vfs.UploadDetails; 40 41 public class ExtensionUploadHandler implements UploadHandler { 42 43 public static final String TYPE_EXTENSION = "EXTENSION"; 44 45 public ActionForward performUpload(HttpServletRequest request, HttpServletResponse response, UploadDetails fileUpload, 46 FormFile file) throws IOException , Exception { 47 String id = file.getFileName().replaceAll(".zip", ""); 48 ExtensionBundle bundle = null; 49 try { 50 bundle = ExtensionStore.getInstance().getExtensionBundle(id); 51 } catch (Exception e) { 52 } 54 if (bundle == null) { 55 bundle = ExtensionStore.getInstance().installExtension(id, file.getInputStream()); 56 ExtensionStore.getInstance().licenseCheck(bundle, request, fileUpload.getUploadedForward()); 57 ExtensionStore.getInstance().postInstallExtension(bundle, request); 58 } else { 59 bundle = ExtensionStore.getInstance().updateExtension(id, file.getInputStream(), request, file.getFileSize()); 60 if (bundle.isContainsPlugin()) 61 CoreUtil.addMultipleGlobalWarning(GlobalWarning.MANAGEMENT_USERS, new BundleActionMessage("extensions", 62 "extensionStore.message.extensionUpdatedRestartRequired")); 63 } 64 65 return fileUpload.getUploadedForward(); 66 67 } 68 69 public boolean checkFileToUpload(HttpServletRequest request, HttpServletResponse response, UploadDetails fileUpload, 70 FormFile file) throws IOException , Exception { 71 return false; 73 } 74 75 } 76 | Popular Tags |