/** * Convert an Aattributes object into a Map * @param att * @return */ public final static Map<String,String> normalize(Attributes att) { Set<Map.Entry<Object,Object>> entries = att.entrySet(); Map<String,String> pristine = new HashMap<String,String>(entries.size()); for(Map.Entry<Object,Object> entry : entries) { String key = entry.getKey().toString(); String value = decode(entry.getValue().toString()); pristine.put(key, value); } return pristine; }
/** * Convert a Manifest into an easier data structure. It returns a Map of Maps. * The main attributes become the map where the key is MAIN_ATTS. * Entries become named maps as in the Manifest * @param m * @return */ public final static Map<String, Map<String,String>> normalize(Manifest m) { // first add the "main attributes Map<String, Map<String,String>> all = new HashMap<String, Map<String,String>>(); Attributes mainAtt = m.getMainAttributes(); all.put(MAIN_ATTS, normalize(mainAtt)); // now add all the "sub-attributes" Map<String,Attributes> unwashed = m.getEntries(); Set<String> entryNames = unwashed.keySet(); for(String entryName : entryNames) { all.put(entryName, normalize(unwashed.get(entryName))); } return all; }
public void execute(AdminCommandContext context) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); modulesRegistry.dumpState(new PrintStream(baos)); ActionReport report = context.getActionReport(); report.setActionExitCode(ExitCode.SUCCESS); String msg = baos.toString(); // the proper way to do this is to check the user-agent of the caller, // but I can't access that -- so I'll just check the type of the // ActionReport. If we are sending back to CLI then linefeeds will // cause problems. Manifest.write() is OK but Manifest.read() explodes! if(report instanceof PropsFileActionReporter) { msg = ManifestUtils.encode(msg); } report.setMessage(msg); } }
/** * Convert a Manifest into an easier data structure. It returns a Map of Maps. * The main attributes become the map where the key is MAIN_ATTS. * Entries become named maps as in the Manifest * @param m * @return */ public final static Map<String, Map<String,String>> normalize(Manifest m) { // first add the "main attributes Map<String, Map<String,String>> all = new HashMap<String, Map<String,String>>(); Attributes mainAtt = m.getMainAttributes(); all.put(MAIN_ATTS, normalize(mainAtt)); // now add all the "sub-attributes" Map<String,Attributes> unwashed = m.getEntries(); Set<Map.Entry<String,Attributes>> entries = unwashed.entrySet(); for(Map.Entry<String,Attributes> entry : entries) { String name = entry.getKey(); Attributes value = entry.getValue(); if(name == null || value == null) continue; all.put(name, normalize(value)); } return all; }
@Override public void execute(AdminCommandContext context) { StringBuilder sb = new StringBuilder(); if (contract == null) { dumpContracts(sb); dumpModules(sb); dumpTypes(sb); } else { dumpInhabitantsImplementingContractPattern(contract, sb); } String msg = sb.toString(); ActionReport report = context.getActionReport(); report.setActionExitCode(ExitCode.SUCCESS); if (report instanceof PropsFileActionReporter) { msg = ManifestUtils.encode(msg); } report.setMessage(msg); }
/** * Convert an Aattributes object into a Map * @param att * @return */ public final static Map<String,String> normalize(Attributes att) { Set<Map.Entry<Object,Object>> entries = att.entrySet(); Map<String,String> pristine = new HashMap<String,String>(entries.size()); for(Map.Entry<Object,Object> entry : entries) { String key = entry.getKey().toString(); String value = decode(entry.getValue().toString()); pristine.put(key, value); } return pristine; }
/** * Convert a Manifest into an easier data structure. It returns a Map of Maps. * The main attributes become the map where the key is MAIN_ATTS. * Entries become named maps as in the Manifest * @param m * @return */ public final static Map<String, Map<String,String>> normalize(Manifest m) { // first add the "main attributes Map<String, Map<String,String>> all = new HashMap<String, Map<String,String>>(); Attributes mainAtt = m.getMainAttributes(); all.put(MAIN_ATTS, normalize(mainAtt)); // now add all the "sub-attributes" Map<String,Attributes> unwashed = m.getEntries(); Set<Map.Entry<String,Attributes>> entries = unwashed.entrySet(); for(Map.Entry<String,Attributes> entry : entries) { String name = entry.getKey(); Attributes value = entry.getValue(); if(name == null || value == null) continue; all.put(name, normalize(value)); } return all; }
/** * Convert an Aattributes object into a Map * @param att * @return */ public final static Map<String,String> normalize(Attributes att) { Set<Map.Entry<Object,Object>> entries = att.entrySet(); Map<String,String> pristine = new HashMap<String,String>(entries.size()); for(Map.Entry<Object,Object> entry : entries) { String key = entry.getKey().toString(); String value = decode(entry.getValue().toString()); if(key == null) // impossible! continue; pristine.put(key, value); } return pristine; }
public void process() throws RemoteException { // format: // "PlainTextActionReporterSUCCESS..." // or // "PlainTextActionReporterFAILURE..." String good = MAGIC + SUCCESS; String bad = MAGIC + FAILURE; response = ManifestUtils.decode(response); if (response.startsWith(good)) { throw new RemoteSuccessException(response.substring(good.length())); } else if (response.startsWith(bad)) { throw new RemoteSuccessException(response.substring(bad.length())); } else { throw new RemoteFailureException( strings.get("unknownFormat", good, bad, response)); } }
public void process() throws RemoteException { // format: // "PlainTextActionReporterSUCCESS..." // or // "PlainTextActionReporterFAILURE..." String good = MAGIC + SUCCESS; String bad = MAGIC + FAILURE; response = ManifestUtils.decode(response); if (response.startsWith(good)) { throw new RemoteSuccessException(response.substring(good.length())); } else if (response.startsWith(bad)) { throw new RemoteSuccessException(response.substring(bad.length())); } else { throw new RemoteFailureException( strings.get("unknownFormat", response)); } }