1 7 package org.openharmonise.him.actions.system; 8 9 import java.awt.Dimension ; 10 import java.awt.event.ActionEvent ; 11 import java.net.MalformedURLException ; 12 import java.net.URI ; 13 import java.net.URL ; 14 import java.rmi.RemoteException ; 15 16 import javax.swing.Icon ; 17 import javax.swing.ImageIcon ; 18 import javax.swing.JFrame ; 19 import javax.xml.rpc.ServiceException ; 20 21 import org.openharmonise.him.actions.AbstractHIMAction; 22 import org.openharmonise.him.actions.HIMAction; 23 import org.openharmonise.him.configuration.EmailDialog; 24 import org.openharmonise.him.publish.PublishServiceClient; 25 import org.openharmonise.him.window.messages.MessageHandler; 26 import org.openharmonise.vfs.AbstractVirtualFileSystem; 27 import org.openharmonise.vfs.VirtualFile; 28 import org.openharmonise.vfs.context.ContextEvent; 29 import org.openharmonise.vfs.gui.IconManager; 30 import org.openharmonise.vfs.servers.ServerList; 31 import org.openharmonise.vfs.status.StatusData; 32 import org.openharmonise.vfs.status.VFSStatus; 33 34 42 public class ActionExportContent extends AbstractHIMAction implements HIMAction { 43 44 47 public ActionExportContent() { 48 super(); 49 } 51 52 55 public ActionExportContent(VirtualFile vfFile) { 56 super(vfFile); 57 } 59 60 65 public void actionPerformed(ActionEvent arg0) { 66 JFrame frame = new JFrame (); 67 frame.setIconImage( ((ImageIcon )IconManager.getInstance().getIcon("32-sim-logo.gif")).getImage() ); 68 EmailDialog emailDialog = new EmailDialog(frame); 69 70 frame.setVisible(true); 71 frame.setTitle("Export Content"); 72 Dimension dims = frame.getGraphicsConfiguration().getBounds().getSize(); 73 frame.setLocation(dims.width,dims.height); 74 75 emailDialog.show(); 76 77 String sEmail = emailDialog.getEmail(); 78 String sType = emailDialog.getType(); 79 80 frame.setVisible(false); 81 82 if(sEmail != null && sEmail.length()>0){ 83 boolean bShowContent = true; 84 boolean bShowMetadata = true; 85 if(sType.equals(emailDialog.TYPE_CONTENTS)){ 86 bShowMetadata = false; 87 } else if (sType.equals(emailDialog.TYPE_METADATA)){ 88 bShowContent = false; 89 } 90 StatusData statusOverall = new VFSStatus(); 91 try { 92 invokeExportService(sEmail,bShowContent,bShowMetadata); 93 } catch (Exception e) { 94 e.printStackTrace(); 95 String sMsg = "There was a problem exporting the content."; 96 MessageHandler.getInstance().fireMessageEvent(sMsg, MessageHandler.TYPE_ERROR); 97 } 98 } 99 } 100 101 public void invokeExportService(String sEmailAddress, boolean bShowContent, boolean bShowMetadata) throws MalformedURLException , RemoteException , ServiceException { 102 AbstractVirtualFileSystem vfs = ServerList.getInstance().getHarmoniseServer().getVFS(); 103 URI uri = vfs.getURI(); 104 String sURL = 105 uri.getScheme() 106 + "://" 107 + uri.getHost() 108 + ":" 109 + uri.getPort() 110 + "/webdav/services/PublishService"; 111 URL endPointURL = new URL (sURL); 112 PublishServiceClient.exportContent(endPointURL, sEmailAddress, bShowContent, bShowMetadata); 113 } 114 115 120 public String getText() { 121 return "Export Content"; 122 } 123 124 129 public String getToolTip() { 130 return this.getDescription(); 131 } 132 133 138 public Icon getIcon() { 139 return IconManager.getInstance().getIcon("16-blank.gif"); 140 } 141 142 147 public String getMnemonic() { 148 return "O"; 149 } 150 151 156 public String getDescription() { 157 return "Download all the Sections, Documents and Metadata"; 158 } 159 160 165 public boolean isEnabled(ContextEvent ce) { 166 if (!m_bUserChecked) { 167 checkUser(); 168 } 169 this.setEnabled(m_bShow); 170 return m_bShow; 171 } 172 173 178 public int getAcceleratorKeycode() { 179 return 0; 181 } 182 183 188 public int getAcceleratorMask() { 189 return 0; 191 } 192 public static void main(String [] args){ 193 ActionExportContent myAction = new ActionExportContent(); 194 myAction.actionPerformed(null); 195 System.out.println("Done"); 196 System.exit(0); 197 } 198 } | Popular Tags |