Search in sources :

Example 1 with CommandInfo

use of javax.activation.CommandInfo 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 CommandInfo

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

the class OsgiMailcapCommandMap method getCommand.

@Override
public CommandInfo getCommand(String mimeType, String cmdName) {
    if (mimeType != null) {
        mimeType = mimeType.toLowerCase(Locale.ENGLISH);
    }
    CommandInfo command = null;
    synchronized (sync) {
        command = getCommand(mimeType, cmdName, false);
        if (command != null) {
            return command;
        }
        command = getCommand(mimeType, cmdName, true);
    }
    return command;
}
Also used : CommandInfo(javax.activation.CommandInfo)

Example 3 with CommandInfo

use of javax.activation.CommandInfo 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)

Aggregations

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