Search in sources :

Example 1 with CommandMap

use of javax.activation.CommandMap in project sling by apache.

the class OsgiMailcapCommandMap method getPreferredCommands.

private void getPreferredCommands(String mimeType, List<CommandInfo> accumulator, boolean fallback) {
    for (Map.Entry<Bundle, MailcapFile> entry : db.entrySet()) {
        Map<?, ?> commandMap = fallback ? entry.getValue().getMailcapFallbackList(mimeType) : entry.getValue().getMailcapList(mimeType);
        if (commandMap == null) {
            continue;
        }
        for (Object verbObject : commandMap.keySet()) {
            String verb = (String) verbObject;
            if (!commandsHaveVerb(accumulator, verb)) {
                List<?> commands = (List<?>) commandMap.get(verb);
                String className = (String) commands.get(0);
                accumulator.add(new CommandInfo(verb, className));
            }
        }
    }
}
Also used : CommandInfo(javax.activation.CommandInfo) Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) CommandMap(javax.activation.CommandMap) Map(java.util.Map) MailcapFile(com.sun.activation.registries.MailcapFile)

Example 2 with CommandMap

use of javax.activation.CommandMap in project sling by apache.

the class OsgiMailcapCommandMap method getAllCommands.

private void getAllCommands(String mimeType, List<CommandInfo> accumulator, boolean fallback) {
    for (Map.Entry<Bundle, MailcapFile> entry : db.entrySet()) {
        Map<?, ?> commandMap = fallback ? entry.getValue().getMailcapFallbackList(mimeType) : entry.getValue().getMailcapList(mimeType);
        if (commandMap == null) {
            continue;
        }
        for (Object verbAsObject : commandMap.keySet()) {
            String verb = (String) verbAsObject;
            List<?> commands = (List<?>) commandMap.get(verb);
            for (Object command : commands) {
                accumulator.add(new CommandInfo(verb, (String) command));
            }
        }
    }
}
Also used : CommandInfo(javax.activation.CommandInfo) Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) CommandMap(javax.activation.CommandMap) Map(java.util.Map) MailcapFile(com.sun.activation.registries.MailcapFile)

Example 3 with CommandMap

use of javax.activation.CommandMap in project sling by apache.

the class OsgiMailcapCommandMap method findDataContentHandler.

private DataContentHandler findDataContentHandler(String mimeType, boolean fallback) {
    for (Map.Entry<Bundle, MailcapFile> entry : db.entrySet()) {
        Map<?, ?> commandMap = fallback ? entry.getValue().getMailcapFallbackList(mimeType) : entry.getValue().getMailcapList(mimeType);
        if (commandMap != null) {
            List<?> v = (List<?>) commandMap.get("content-handler");
            if (v == null) {
                continue;
            }
            String name = (String) v.get(0);
            DataContentHandler dch = getDataContentHandler(name, entry.getKey());
            if (dch != null) {
                return dch;
            }
        }
    }
    return null;
}
Also used : DataContentHandler(javax.activation.DataContentHandler) Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) CommandMap(javax.activation.CommandMap) Map(java.util.Map) MailcapFile(com.sun.activation.registries.MailcapFile)

Aggregations

MailcapFile (com.sun.activation.registries.MailcapFile)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 CommandMap (javax.activation.CommandMap)3 Bundle (org.osgi.framework.Bundle)3 CommandInfo (javax.activation.CommandInfo)2 DataContentHandler (javax.activation.DataContentHandler)1