Changeset 18193 for greenstone3


Ignore:
Timestamp:
2008-12-12T14:45:53+13:00 (15 years ago)
Author:
cc108
Message:

add a new method to uninstall greenstone3 extension

File:
1 edited

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/src/java/org/greenstone/admin/gui/Mat.java

    r18172 r18193  
    443443            String action = actionElement.getAttribute("action");
    444444           
    445             if(!action.equalsIgnoreCase(command) && !action.equalsIgnoreCase("uninstall")){
     445            if(!action.equalsIgnoreCase(command)){
    446446               
    447447            String status = actionElement.getAttribute("status");
    448             if(status=="true"){
    449                 actionElement.setAttribute("status", "false");
    450             }
    451             else{
    452                 actionElement.setAttribute("status", "true");
    453             }
     448             actionElement.setAttribute("status", "true");
    454449            }
    455450            }
    456451        }
    457452    }
     453       
     454        else if(command.equalsIgnoreCase("uninstall")){
     455            Node x  = actionList.item(0);
     456            NodeList stepList = x.getChildNodes();
     457           
     458            for(int i = 0; i<stepList.getLength(); i++){
     459            Node n = stepList.item(i);
     460            if(n instanceof Element){
     461                Element actionElement = (Element) n;
     462               
     463                String action = actionElement.getAttribute("action");
     464               
     465                if(!action.equalsIgnoreCase("download")){
     466                   
     467                String status = actionElement.getAttribute("status");
     468                    actionElement.setAttribute("status", "false");
     469                }
     470            }
     471            }
     472        }
    458473       
    459474    try{
     
    577592        String msg = createInfoMsg(button.getName());
    578593        String timestamp = getTimestamp();
    579         updateLOG("Unistall", msg , timestamp);
     594       uninstallExtension();
     595       adaptee.setCommandStatus("Uninstall");
     596       updateLOG("Unistall", msg , timestamp);
    580597    }
    581598    else if(button.getName().equalsIgnoreCase("disable")){
     
    591608    }
    592609   
     610    public void uninstallExtension(){
     611        File temp = new File(adaptee.extension_path);
     612        deleteDir(temp);
     613    }
     614   
     615    private static boolean deleteDir(File dir) {
     616       
     617        if (dir.isDirectory()) {
     618                String[] children = dir.list();
     619                for (int i=0; i<children.length; i++) {
     620                    boolean success = deleteDir(new File(dir, children[i]));
     621                    if (!success) {
     622                        return false;
     623                    }
     624                }
     625            }
     626        return dir.delete();
     627        }
     628
     629
    593630    public void downloadExtension(){
    594631        System.out.println("start downloading");
Note: See TracChangeset for help on using the changeset viewer.