com.sun.activation.registries.MailcapFile Java Examples

The following examples show how to use com.sun.activation.registries.MailcapFile. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MailcapCommandMap.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load from the named resource.
 */
private MailcapFile loadResource(String name) {
    InputStream clis = null;
    try {
        clis = SecuritySupport.getResourceAsStream(this.getClass(), name);
        if (clis != null) {
            MailcapFile mf = new MailcapFile(clis);
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: successfully loaded " +
                    "mailcap file: " + name);
            return mf;
        } else {
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: not loading " +
                    "mailcap file: " + name);
        }
    } catch (IOException e) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, e);
    } catch (SecurityException sex) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, sex);
    } finally {
        try {
            if (clis != null)
                clis.close();
        } catch (IOException ex) { }        // ignore it
    }
    return null;
}
 
Example #2
Source File: MailcapCommandMap.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load from the named resource.
 */
private MailcapFile loadResource(String name) {
    InputStream clis = null;
    try {
        clis = SecuritySupport.getResourceAsStream(this.getClass(), name);
        if (clis != null) {
            MailcapFile mf = new MailcapFile(clis);
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: successfully loaded " +
                    "mailcap file: " + name);
            return mf;
        } else {
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: not loading " +
                    "mailcap file: " + name);
        }
    } catch (IOException e) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, e);
    } catch (SecurityException sex) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, sex);
    } finally {
        try {
            if (clis != null)
                clis.close();
        } catch (IOException ex) { }        // ignore it
    }
    return null;
}
 
Example #3
Source File: MailcapCommandMap.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor that allows the caller to specify an <i>InputStream</i>
 * containing a mailcap file.
 *
 * @param is        InputStream of the <i>mailcap</i> file to open
 */
public MailcapCommandMap(InputStream is) {
    this();

    LogSupport.log("MailcapCommandMap: load PROG");
    if (DB[PROG] == null) {
        try {
            DB[PROG] = new MailcapFile(is);
        } catch (IOException ex) {
            // XXX - should throw it
        }
    }
}
 
Example #4
Source File: MailcapCommandMap.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor that allows the caller to specify the path
 * of a <i>mailcap</i> file.
 *
 * @param fileName The name of the <i>mailcap</i> file to open
 * @exception       IOException     if the file can't be accessed
 */
public MailcapCommandMap(String fileName) throws IOException {
    this();

    if (LogSupport.isLoggable())
        LogSupport.log("MailcapCommandMap: load PROG from " + fileName);
    if (DB[PROG] == null) {
        DB[PROG] = new MailcapFile(fileName);
    }
}
 
Example #5
Source File: MailcapCommandMap.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor that allows the caller to specify the path
 * of a <i>mailcap</i> file.
 *
 * @param fileName The name of the <i>mailcap</i> file to open
 * @exception       IOException     if the file can't be accessed
 */
public MailcapCommandMap(String fileName) throws IOException {
    this();

    if (LogSupport.isLoggable())
        LogSupport.log("MailcapCommandMap: load PROG from " + fileName);
    if (DB[PROG] == null) {
        DB[PROG] = new MailcapFile(fileName);
    }
}
 
Example #6
Source File: MailcapCommandMap.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load from the named resource.
 */
private MailcapFile loadResource(String name) {
    InputStream clis = null;
    try {
        clis = SecuritySupport.getResourceAsStream(this.getClass(), name);
        if (clis != null) {
            MailcapFile mf = new MailcapFile(clis);
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: successfully loaded " +
                    "mailcap file: " + name);
            return mf;
        } else {
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: not loading " +
                    "mailcap file: " + name);
        }
    } catch (IOException e) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, e);
    } catch (SecurityException sex) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, sex);
    } finally {
        try {
            if (clis != null)
                clis.close();
        } catch (IOException ex) { }        // ignore it
    }
    return null;
}
 
Example #7
Source File: MailcapCommandMap.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor that allows the caller to specify an <i>InputStream</i>
 * containing a mailcap file.
 *
 * @param is        InputStream of the <i>mailcap</i> file to open
 */
public MailcapCommandMap(InputStream is) {
    this();

    LogSupport.log("MailcapCommandMap: load PROG");
    if (DB[PROG] == null) {
        try {
            DB[PROG] = new MailcapFile(is);
        } catch (IOException ex) {
            // XXX - should throw it
        }
    }
}
 
Example #8
Source File: MailcapCommandMap.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor that allows the caller to specify an <i>InputStream</i>
 * containing a mailcap file.
 *
 * @param is        InputStream of the <i>mailcap</i> file to open
 */
public MailcapCommandMap(InputStream is) {
    this();

    LogSupport.log("MailcapCommandMap: load PROG");
    if (DB[PROG] == null) {
        try {
            DB[PROG] = new MailcapFile(is);
        } catch (IOException ex) {
            // XXX - should throw it
        }
    }
}
 
Example #9
Source File: MailcapCommandMap.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor that allows the caller to specify the path
 * of a <i>mailcap</i> file.
 *
 * @param fileName The name of the <i>mailcap</i> file to open
 * @exception       IOException     if the file can't be accessed
 */
public MailcapCommandMap(String fileName) throws IOException {
    this();

    if (LogSupport.isLoggable())
        LogSupport.log("MailcapCommandMap: load PROG from " + fileName);
    if (DB[PROG] == null) {
        DB[PROG] = new MailcapFile(fileName);
    }
}
 
Example #10
Source File: MailcapCommandMap.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load from the named resource.
 */
private MailcapFile loadResource(String name) {
    InputStream clis = null;
    try {
        clis = SecuritySupport.getResourceAsStream(this.getClass(), name);
        if (clis != null) {
            MailcapFile mf = new MailcapFile(clis);
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: successfully loaded " +
                    "mailcap file: " + name);
            return mf;
        } else {
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: not loading " +
                    "mailcap file: " + name);
        }
    } catch (IOException e) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, e);
    } catch (SecurityException sex) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, sex);
    } finally {
        try {
            if (clis != null)
                clis.close();
        } catch (IOException ex) { }        // ignore it
    }
    return null;
}
 
Example #11
Source File: MailcapCommandMap.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load from the named resource.
 */
private MailcapFile loadResource(String name) {
    InputStream clis = null;
    try {
        clis = SecuritySupport.getResourceAsStream(this.getClass(), name);
        if (clis != null) {
            MailcapFile mf = new MailcapFile(clis);
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: successfully loaded " +
                    "mailcap file: " + name);
            return mf;
        } else {
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: not loading " +
                    "mailcap file: " + name);
        }
    } catch (IOException e) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, e);
    } catch (SecurityException sex) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, sex);
    } finally {
        try {
            if (clis != null)
                clis.close();
        } catch (IOException ex) { }        // ignore it
    }
    return null;
}
 
Example #12
Source File: MailcapCommandMap.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor that allows the caller to specify an <i>InputStream</i>
 * containing a mailcap file.
 *
 * @param is        InputStream of the <i>mailcap</i> file to open
 */
public MailcapCommandMap(InputStream is) {
    this();

    LogSupport.log("MailcapCommandMap: load PROG");
    if (DB[PROG] == null) {
        try {
            DB[PROG] = new MailcapFile(is);
        } catch (IOException ex) {
            // XXX - should throw it
        }
    }
}
 
Example #13
Source File: MailcapCommandMap.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor that allows the caller to specify the path
 * of a <i>mailcap</i> file.
 *
 * @param fileName The name of the <i>mailcap</i> file to open
 * @exception       IOException     if the file can't be accessed
 */
public MailcapCommandMap(String fileName) throws IOException {
    this();

    if (LogSupport.isLoggable())
        LogSupport.log("MailcapCommandMap: load PROG from " + fileName);
    if (DB[PROG] == null) {
        DB[PROG] = new MailcapFile(fileName);
    }
}
 
Example #14
Source File: MailcapCommandMap.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor that allows the caller to specify the path
 * of a <i>mailcap</i> file.
 *
 * @param fileName The name of the <i>mailcap</i> file to open
 * @exception       IOException     if the file can't be accessed
 */
public MailcapCommandMap(String fileName) throws IOException {
    this();

    if (LogSupport.isLoggable())
        LogSupport.log("MailcapCommandMap: load PROG from " + fileName);
    if (DB[PROG] == null) {
        DB[PROG] = new MailcapFile(fileName);
    }
}
 
Example #15
Source File: MailcapCommandMap.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
/**
    * Constructor that allows the caller to specify an <i>InputStream</i>
    * containing a mailcap file.
    *
    * @param is	InputStream of the <i>mailcap</i> file to open
    */
   public MailcapCommandMap(InputStream is) {
this();

LogSupport.log("MailcapCommandMap: load PROG");
if (DB[PROG] == null) {
    try {
	DB[PROG] = new MailcapFile(is);
    } catch (IOException ex) {
	// XXX - should throw it
    }
}
   }
 
Example #16
Source File: MailcapCommandMap.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load from the named resource.
 */
private MailcapFile loadResource(String name) {
    InputStream clis = null;
    try {
        clis = SecuritySupport.getResourceAsStream(this.getClass(), name);
        if (clis != null) {
            MailcapFile mf = new MailcapFile(clis);
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: successfully loaded " +
                    "mailcap file: " + name);
            return mf;
        } else {
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: not loading " +
                    "mailcap file: " + name);
        }
    } catch (IOException e) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, e);
    } catch (SecurityException sex) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, sex);
    } finally {
        try {
            if (clis != null)
                clis.close();
        } catch (IOException ex) { }        // ignore it
    }
    return null;
}
 
Example #17
Source File: MailcapCommandMap.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor that allows the caller to specify the path
 * of a <i>mailcap</i> file.
 *
 * @param fileName The name of the <i>mailcap</i> file to open
 * @exception       IOException     if the file can't be accessed
 */
public MailcapCommandMap(String fileName) throws IOException {
    this();

    if (LogSupport.isLoggable())
        LogSupport.log("MailcapCommandMap: load PROG from " + fileName);
    if (DB[PROG] == null) {
        DB[PROG] = new MailcapFile(fileName);
    }
}
 
Example #18
Source File: MailcapCommandMap.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor that allows the caller to specify an <i>InputStream</i>
 * containing a mailcap file.
 *
 * @param is        InputStream of the <i>mailcap</i> file to open
 */
public MailcapCommandMap(InputStream is) {
    this();

    LogSupport.log("MailcapCommandMap: load PROG");
    if (DB[PROG] == null) {
        try {
            DB[PROG] = new MailcapFile(is);
        } catch (IOException ex) {
            // XXX - should throw it
        }
    }
}
 
Example #19
Source File: MailcapCommandMap.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor that allows the caller to specify an <i>InputStream</i>
 * containing a mailcap file.
 *
 * @param is        InputStream of the <i>mailcap</i> file to open
 */
public MailcapCommandMap(InputStream is) {
    this();

    LogSupport.log("MailcapCommandMap: load PROG");
    if (DB[PROG] == null) {
        try {
            DB[PROG] = new MailcapFile(is);
        } catch (IOException ex) {
            // XXX - should throw it
        }
    }
}
 
Example #20
Source File: MailcapCommandMap.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
/**
    * Load from the named resource.
    */
   private MailcapFile loadResource(String name) {
InputStream clis = null;
try {
    clis = SecuritySupport.getResourceAsStream(this.getClass(), name);
    if (clis != null) {
	MailcapFile mf = new MailcapFile(clis);
	if (LogSupport.isLoggable())
	    LogSupport.log("MailcapCommandMap: successfully loaded " +
		"mailcap file: " + name);
	return mf;
    } else {
	if (LogSupport.isLoggable())
	    LogSupport.log("MailcapCommandMap: not loading " +
		"mailcap file: " + name);
    }
} catch (IOException e) {
    if (LogSupport.isLoggable())
	LogSupport.log("MailcapCommandMap: can't load " + name, e);
} catch (SecurityException sex) {
    if (LogSupport.isLoggable())
	LogSupport.log("MailcapCommandMap: can't load " + name, sex);
} finally {
    try {
	if (clis != null)
	    clis.close();
    } catch (IOException ex) { }	// ignore it
}
return null;
   }
 
Example #21
Source File: MailcapCommandMap.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor that allows the caller to specify the path
 * of a <i>mailcap</i> file.
 *
 * @param fileName The name of the <i>mailcap</i> file to open
 * @exception       IOException     if the file can't be accessed
 */
public MailcapCommandMap(String fileName) throws IOException {
    this();

    if (LogSupport.isLoggable())
        LogSupport.log("MailcapCommandMap: load PROG from " + fileName);
    if (DB[PROG] == null) {
        DB[PROG] = new MailcapFile(fileName);
    }
}
 
Example #22
Source File: MailcapCommandMap.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
/**
    * Constructor that allows the caller to specify the path
    * of a <i>mailcap</i> file.
    *
    * @param fileName The name of the <i>mailcap</i> file to open
    * @exception	IOException	if the file can't be accessed
    */
   public MailcapCommandMap(String fileName) throws IOException {
this();

if (LogSupport.isLoggable())
    LogSupport.log("MailcapCommandMap: load PROG from " + fileName);
if (DB[PROG] == null) {
    DB[PROG] = new MailcapFile(fileName);
}
   }
 
Example #23
Source File: MailcapCommandMap.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor that allows the caller to specify an <i>InputStream</i>
 * containing a mailcap file.
 *
 * @param is        InputStream of the <i>mailcap</i> file to open
 */
public MailcapCommandMap(InputStream is) {
    this();

    LogSupport.log("MailcapCommandMap: load PROG");
    if (DB[PROG] == null) {
        try {
            DB[PROG] = new MailcapFile(is);
        } catch (IOException ex) {
            // XXX - should throw it
        }
    }
}
 
Example #24
Source File: MailcapCommandMap.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load from the named resource.
 */
private MailcapFile loadResource(String name) {
    InputStream clis = null;
    try {
        clis = SecuritySupport.getResourceAsStream(this.getClass(), name);
        if (clis != null) {
            MailcapFile mf = new MailcapFile(clis);
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: successfully loaded " +
                    "mailcap file: " + name);
            return mf;
        } else {
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: not loading " +
                    "mailcap file: " + name);
        }
    } catch (IOException e) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, e);
    } catch (SecurityException sex) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, sex);
    } finally {
        try {
            if (clis != null)
                clis.close();
        } catch (IOException ex) { }        // ignore it
    }
    return null;
}
 
Example #25
Source File: MailcapCommandMap.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load from the named resource.
 */
private MailcapFile loadResource(String name) {
    InputStream clis = null;
    try {
        clis = SecuritySupport.getResourceAsStream(this.getClass(), name);
        if (clis != null) {
            MailcapFile mf = new MailcapFile(clis);
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: successfully loaded " +
                    "mailcap file: " + name);
            return mf;
        } else {
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: not loading " +
                    "mailcap file: " + name);
        }
    } catch (IOException e) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, e);
    } catch (SecurityException sex) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, sex);
    } finally {
        try {
            if (clis != null)
                clis.close();
        } catch (IOException ex) { }        // ignore it
    }
    return null;
}
 
Example #26
Source File: MailcapCommandMap.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor that allows the caller to specify the path
 * of a <i>mailcap</i> file.
 *
 * @param fileName The name of the <i>mailcap</i> file to open
 * @exception       IOException     if the file can't be accessed
 */
public MailcapCommandMap(String fileName) throws IOException {
    this();

    if (LogSupport.isLoggable())
        LogSupport.log("MailcapCommandMap: load PROG from " + fileName);
    if (DB[PROG] == null) {
        DB[PROG] = new MailcapFile(fileName);
    }
}
 
Example #27
Source File: MailcapCommandMap.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor that allows the caller to specify an <i>InputStream</i>
 * containing a mailcap file.
 *
 * @param is        InputStream of the <i>mailcap</i> file to open
 */
public MailcapCommandMap(InputStream is) {
    this();

    LogSupport.log("MailcapCommandMap: load PROG");
    if (DB[PROG] == null) {
        try {
            DB[PROG] = new MailcapFile(is);
        } catch (IOException ex) {
            // XXX - should throw it
        }
    }
}
 
Example #28
Source File: MailcapCommandMap.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Load all of the named resource.
 */
private void loadAllResources(List v, String name) {
    boolean anyLoaded = false;
    try {
        URL[] urls;
        ClassLoader cld = null;
        // First try the "application's" class loader.
        cld = SecuritySupport.getContextClassLoader();
        if (cld == null)
            cld = this.getClass().getClassLoader();
        if (cld != null)
            urls = SecuritySupport.getResources(cld, name);
        else
            urls = SecuritySupport.getSystemResources(name);
        if (urls != null) {
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: getResources");
            for (int i = 0; i < urls.length; i++) {
                URL url = urls[i];
                InputStream clis = null;
                if (LogSupport.isLoggable())
                    LogSupport.log("MailcapCommandMap: URL " + url);
                try {
                    clis = SecuritySupport.openStream(url);
                    if (clis != null) {
                        v.add(new MailcapFile(clis));
                        anyLoaded = true;
                        if (LogSupport.isLoggable())
                            LogSupport.log("MailcapCommandMap: " +
                                "successfully loaded " +
                                "mailcap file from URL: " +
                                url);
                    } else {
                        if (LogSupport.isLoggable())
                            LogSupport.log("MailcapCommandMap: " +
                                "not loading mailcap " +
                                "file from URL: " + url);
                    }
                } catch (IOException ioex) {
                    if (LogSupport.isLoggable())
                        LogSupport.log("MailcapCommandMap: can't load " +
                                            url, ioex);
                } catch (SecurityException sex) {
                    if (LogSupport.isLoggable())
                        LogSupport.log("MailcapCommandMap: can't load " +
                                            url, sex);
                } finally {
                    try {
                        if (clis != null)
                            clis.close();
                    } catch (IOException cex) { }
                }
            }
        }
    } catch (Exception ex) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, ex);
    }

    // if failed to load anything, fall back to old technique, just in case
    if (!anyLoaded) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: !anyLoaded");
        MailcapFile mf = loadResource("/" + name);
        if (mf != null)
            v.add(mf);
    }
}
 
Example #29
Source File: MailcapCommandMap.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Load all of the named resource.
 */
private void loadAllResources(List v, String name) {
    boolean anyLoaded = false;
    try {
        URL[] urls;
        ClassLoader cld = null;
        // First try the "application's" class loader.
        cld = SecuritySupport.getContextClassLoader();
        if (cld == null)
            cld = this.getClass().getClassLoader();
        if (cld != null)
            urls = SecuritySupport.getResources(cld, name);
        else
            urls = SecuritySupport.getSystemResources(name);
        if (urls != null) {
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: getResources");
            for (int i = 0; i < urls.length; i++) {
                URL url = urls[i];
                InputStream clis = null;
                if (LogSupport.isLoggable())
                    LogSupport.log("MailcapCommandMap: URL " + url);
                try {
                    clis = SecuritySupport.openStream(url);
                    if (clis != null) {
                        v.add(new MailcapFile(clis));
                        anyLoaded = true;
                        if (LogSupport.isLoggable())
                            LogSupport.log("MailcapCommandMap: " +
                                "successfully loaded " +
                                "mailcap file from URL: " +
                                url);
                    } else {
                        if (LogSupport.isLoggable())
                            LogSupport.log("MailcapCommandMap: " +
                                "not loading mailcap " +
                                "file from URL: " + url);
                    }
                } catch (IOException ioex) {
                    if (LogSupport.isLoggable())
                        LogSupport.log("MailcapCommandMap: can't load " +
                                            url, ioex);
                } catch (SecurityException sex) {
                    if (LogSupport.isLoggable())
                        LogSupport.log("MailcapCommandMap: can't load " +
                                            url, sex);
                } finally {
                    try {
                        if (clis != null)
                            clis.close();
                    } catch (IOException cex) { }
                }
            }
        }
    } catch (Exception ex) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, ex);
    }

    // if failed to load anything, fall back to old technique, just in case
    if (!anyLoaded) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: !anyLoaded");
        MailcapFile mf = loadResource("/" + name);
        if (mf != null)
            v.add(mf);
    }
}
 
Example #30
Source File: MailcapCommandMap.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Load all of the named resource.
 */
private void loadAllResources(List v, String name) {
    boolean anyLoaded = false;
    try {
        URL[] urls;
        ClassLoader cld = null;
        // First try the "application's" class loader.
        cld = SecuritySupport.getContextClassLoader();
        if (cld == null)
            cld = this.getClass().getClassLoader();
        if (cld != null)
            urls = SecuritySupport.getResources(cld, name);
        else
            urls = SecuritySupport.getSystemResources(name);
        if (urls != null) {
            if (LogSupport.isLoggable())
                LogSupport.log("MailcapCommandMap: getResources");
            for (int i = 0; i < urls.length; i++) {
                URL url = urls[i];
                InputStream clis = null;
                if (LogSupport.isLoggable())
                    LogSupport.log("MailcapCommandMap: URL " + url);
                try {
                    clis = SecuritySupport.openStream(url);
                    if (clis != null) {
                        v.add(new MailcapFile(clis));
                        anyLoaded = true;
                        if (LogSupport.isLoggable())
                            LogSupport.log("MailcapCommandMap: " +
                                "successfully loaded " +
                                "mailcap file from URL: " +
                                url);
                    } else {
                        if (LogSupport.isLoggable())
                            LogSupport.log("MailcapCommandMap: " +
                                "not loading mailcap " +
                                "file from URL: " + url);
                    }
                } catch (IOException ioex) {
                    if (LogSupport.isLoggable())
                        LogSupport.log("MailcapCommandMap: can't load " +
                                            url, ioex);
                } catch (SecurityException sex) {
                    if (LogSupport.isLoggable())
                        LogSupport.log("MailcapCommandMap: can't load " +
                                            url, sex);
                } finally {
                    try {
                        if (clis != null)
                            clis.close();
                    } catch (IOException cex) { }
                }
            }
        }
    } catch (Exception ex) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: can't load " + name, ex);
    }

    // if failed to load anything, fall back to old technique, just in case
    if (!anyLoaded) {
        if (LogSupport.isLoggable())
            LogSupport.log("MailcapCommandMap: !anyLoaded");
        MailcapFile mf = loadResource("/" + name);
        if (mf != null)
            v.add(mf);
    }
}