Refine search
MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html"); mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml"); mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain"); mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822"); CommandMap.setDefaultCommandMap(mc); BodyPart messageBodyPart = new MimeBodyPart(); DataSource source = new FileDataSource(filename); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(filename);
return dataContentHandler; String simpleMT = getBaseType(); dataContentHandler = getCommandMap(). createDataContentHandler(simpleMT, dataSource); else dataContentHandler = getCommandMap(). createDataContentHandler(simpleMT);
/** * Return all the commands for this type of data. * This method returns an array containing all commands * for the type of data represented by this DataHandler. The * MIME type for the underlying data represented by this DataHandler * is used to call through to the <code>getAllCommands</code> method * of the CommandMap associated with this DataHandler. * * @return the CommandInfo objects representing all the commands * * @see javax.activation.CommandMap#getAllCommands */ public CommandInfo[] getAllCommands() { if (dataSource != null) return getCommandMap().getAllCommands(getBaseType(), dataSource); else return getCommandMap().getAllCommands(getBaseType()); }
/** * Adds a group of content handlers to the Mailcap <code>CommandMap</code>. These handlers are * used by the JavaMail API to encode and decode information of specific mime types. * * @throws OpenAS2Exception If an error occurs while initializing mime types */ private void initJavaMail() throws OpenAS2Exception { MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); mc.addMailcap( AS2Standards.DISPOSITION_TYPE + ";; x-java-content-handler=org.openas2.lib.util.javamail.DispositionDataContentHandler"); CommandMap.setDefaultCommandMap(mc); }
/** * Return the CommandMap for this instance of DataHandler. */ private synchronized CommandMap getCommandMap() { if (currentCommandMap != null) return currentCommandMap; else return CommandMap.getDefaultCommandMap(); }
/** * Rebuild a new default command map after a change in * the status of bundles providing command maps. */ private void rebuildCommandMap() { MailcapCommandMap commandMap = new MailcapCommandMap(); for (URL url : mailCaps.values()) { try { InputStream is = url.openStream(); try { BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line; while ((line = br.readLine()) != null) { commandMap.addMailcap(line); } } finally { is.close(); } } catch (Exception e) { // Ignore } } // this is our new default command map CommandMap.setDefaultCommandMap(commandMap); } }
/** * Get the command <i>cmdName</i>. Use the search semantics as * defined by the CommandMap installed in this DataHandler. The * MIME type for the underlying data represented by this DataHandler * is used to call through to the <code>getCommand</code> method * of the CommandMap associated with this DataHandler. * * @param cmdName the command name * @return the CommandInfo corresponding to the command * * @see javax.activation.CommandMap#getCommand */ public CommandInfo getCommand(String cmdName) { if (dataSource != null) return getCommandMap().getCommand(getBaseType(), cmdName, dataSource); else return getCommandMap().getCommand(getBaseType(), cmdName); }
/** * Determine if the dummy mime type is present, indicating this thread, * classloader has been setup as needed. (bz-1104273 workaround) * * @return */ public static boolean isRegistered() { MailcapCommandMap mailcap = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); return (mailcap.getAllCommands(DummyDataContentHandler.DUMMY_DATA_FLAVOR).length > 0); } }
/** * Return the <i>preferred</i> commands for this type of data. * This method calls the <code>getPreferredCommands</code> method * in the CommandMap associated with this instance of DataHandler. * This method returns an array that represents a subset of * available commands. In cases where multiple commands for the * MIME type represented by this DataHandler are present, the * installed CommandMap chooses the appropriate commands. * * @return the CommandInfo objects representing the preferred commands * * @see javax.activation.CommandMap#getPreferredCommands */ public CommandInfo[] getPreferredCommands() { if (dataSource != null) return getCommandMap().getPreferredCommands(getBaseType(), dataSource); else return getCommandMap().getPreferredCommands(getBaseType()); }
public CommandInfo getCommand(String cmdName) { return getCommandMap().getCommand(ds.getContentType(), cmdName); }
public CommandInfo[] getAllCommands() { return getCommandMap().getAllCommands(ds.getContentType()); }
@Override public synchronized DataContentHandler createDataContentHandler( String mimeType) { DataContentHandler dch = super.createDataContentHandler(mimeType); if (dch == null) { dch = DEFAULT_COMMAND_MAP.createDataContentHandler(mimeType); } return dch; }
public CommandInfo[] getPreferredCommands() { return getCommandMap().getPreferredCommands(ds.getContentType()); }
/** * Locate a DataContentHandler that corresponds to the MIME type. * The mechanism and semantics for determining this are determined * by the implementation of the particular CommandMap. <p> * * The <code>DataSource</code> provides extra information, such as * the file name, that a CommandMap implementation may use to further * refine the choice of DataContentHandler. The implementation * in this class simply calls the <code>createDataContentHandler</code> * method that ignores this argument. * * @param mimeType the MIME type * @param ds a DataSource for the data * @return the DataContentHandler for the MIME type * @since JAF 1.1 */ public DataContentHandler createDataContentHandler(String mimeType, DataSource ds) { return createDataContentHandler(mimeType); }
@Override public synchronized CommandInfo getCommand(String mimeType, String cmdName) { CommandInfo cmdInfo = super.getCommand(mimeType, cmdName); if (cmdInfo == null) { cmdInfo = DEFAULT_COMMAND_MAP.getCommand(mimeType, cmdName); } return cmdInfo; }
/** * Get all the available commands for this type. This method * should return all the possible commands for this MIME type. <p> * * The <code>DataSource</code> provides extra information, such as * the file name, that a CommandMap implementation may use to further * refine the list of commands that are returned. The implementation * in this class simply calls the <code>getAllCommands</code> * method that ignores this argument. * * @param mimeType the MIME type * @param ds a DataSource for the data * @return the CommandInfo objects representing all the commands. * @since JAF 1.1 */ public CommandInfo[] getAllCommands(String mimeType, DataSource ds) { return getAllCommands(mimeType); }
/** * Get the preferred command list from a MIME Type. The actual semantics * are determined by the implementation of the CommandMap. <p> * * The <code>DataSource</code> provides extra information, such as * the file name, that a CommandMap implementation may use to further * refine the list of commands that are returned. The implementation * in this class simply calls the <code>getPreferredCommands</code> * method that ignores this argument. * * @param mimeType the MIME type * @param ds a DataSource for the data * @return the CommandInfo classes that represent the command Beans. * @since JAF 1.1 */ public CommandInfo[] getPreferredCommands(String mimeType, DataSource ds) { return getPreferredCommands(mimeType); }
/** * Get the default command corresponding to the MIME type. <p> * * The <code>DataSource</code> provides extra information, such as * the file name, that a CommandMap implementation may use to further * refine the command that is chosen. The implementation * in this class simply calls the <code>getCommand</code> * method that ignores this argument. * * @param mimeType the MIME type * @param cmdName the command name * @param ds a DataSource for the data * @return the CommandInfo corresponding to the command. * @since JAF 1.1 */ public CommandInfo getCommand(String mimeType, String cmdName, DataSource ds) { return getCommand(mimeType, cmdName); }
@Override public void stop(BundleContext bundleContext) throws Exception { super.stop(bundleContext); CommandMap.setDefaultCommandMap(null); }
public void initialize() { Security.addProvider(new BouncyCastleProvider()); MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); mc.addMailcap("application/pkcs7-signature;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.pkcs7_signature"); mc.addMailcap("application/pkcs7-mime;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.pkcs7_mime"); mc.addMailcap("application/x-pkcs7-signature;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.x_pkcs7_signature"); mc.addMailcap("application/x-pkcs7-mime;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.x_pkcs7_mime"); mc.addMailcap("multipart/signed;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.multipart_signed"); CommandMap.setDefaultCommandMap(mc); }