ManifestManager(InputStream inStream, Logger logger) throws RemoteException, IOException { this.logger = logger; response = new AdminCommandResponse(inStream); }
public Map<String,String> getMainAtts() { return response.getMainAtts(); }
private void setParamsAndOperands() { List<NameValue<String,String>> list = response.getMainKeys(); for(NameValue<String,String> nv : list) { String name = nv.getName(); if(name.equals(AdminCommandResponse.SYNOPSIS)) continue; if(name.endsWith("operand")) operands.add(nv); else params.add(nv); } }
private void processGeneric() throws RemoteSuccessException, RemoteFailureException { StringBuilder sb = new StringBuilder(); String msg = response.getMainMessage(); if(ok(msg)) { sb.append(msg); } boolean useMainChildrenAttr = Boolean.valueOf(response.getMainAtts().get("use-main-children-attribute")); if (useMainChildrenAttr) { sb = processMainChildrenAttribute(response.getMainAtts(), sb); } else { processOneLevel("", null, response.getMainAtts(), sb); } if (response.wasFailure()) { final String cause = response.getCause(); if(ok(cause)){ if (logger.isLoggable(Level.FINER)) { if (sb.length() > 0) sb.append(EOL); sb.append(cause); } throw new RemoteFailureException(sb.toString(), cause); } throw new RemoteFailureException(sb.toString()); } throw new RemoteSuccessException(sb.toString()); }
/** * Format: * (1) Main Attributes usually have the bulk of the data. Say you have 3 items * in there: a, b and c. The Manifest main attributes will end up with this: * keys=a;b;c * a_name=xxx * a_value=xxx * b_name=xxx * b_value=xxx * c_name=xxx * c_value=xxx */ private void makeMainKeys() { mainKeys = getKeys(mainRaw); for(NameValue<String,String> nv : mainKeys) { if(nv.getName().equals(GENERATED_HELP)) { isGeneratedHelp = Boolean.parseBoolean(nv.getValue()); mainKeys.remove(nv); break; } } }
public void process() throws RemoteException { String usageText = response.getValue(AdminCommandResponse.SYNOPSIS); if(usageText == null) { // this is one way to figure out there was an error! throw new RemoteFailureException("XXXXXXXXXXXXXXXXXXXX", response.getMainMessage()); } setName(); setSynopsis(); setParamsAndOperands(); StringBuilder sb = new StringBuilder(); sb.append(EOL); printName(sb); printSynopsis(sb); printParams(sb); printOperands(sb); throw new RemoteSuccessException(sb.toString()); }
private void setSynopsis() { synopsis = response.getValue(AdminCommandResponse.SYNOPSIS); if (synopsis.startsWith("Usage: ")) { synopsis = synopsis.substring(7); } // this looks too horrible - go with one long line... //synopsis = displayInProperLen(synopsis); } private void printSynopsis(StringBuilder sb) {
public AdminCommandResponse(InputStream inStream) throws IOException { Manifest m = new Manifest(inStream); m.read(inStream); allRaw = ManifestUtils.normalize(m); mainRaw = ManifestUtils.getMain(allRaw); makeMain(); }
private void processGeneratedManPage() throws RemoteException { if(!response.isGeneratedHelp()) return; GeneratedManPageManager mgr = new GeneratedManPageManager(response); mgr.process(); }
private void setName() { name = displayInProperLen(response.getMainMessage()); }
private void processChildren(String prefix, String parent, Map<String, String> atts, StringBuilder sb) { Map<String,Map<String,String>> kids = response.getChildren(atts); if(kids == null || kids.isEmpty()) return; String childrenType = atts.get(AdminCommandResponse.CHILDREN_TYPE); int index = (parent == null) ? 0 : parent.length() + 1; for(Map.Entry<String, Map<String,String>> entry : kids.entrySet()) { String container = entry.getKey(); if (sb.length() > 0) sb.append(EOL); if(ok(childrenType)) { sb.append(prefix).append(childrenType).append(" : "); } try { sb.append(java.net.URLDecoder.decode(container.substring(index), "UTF-8")); } catch (Exception e) { sb.append(container.substring(index)); } processOneLevel(prefix + TAB, container, entry.getValue(), sb); } }
private void processGeneric() throws RemoteSuccessException, RemoteFailureException { StringBuilder sb = new StringBuilder(); String msg = response.getMainMessage(); if(ok(msg)) { sb.append(msg); } boolean useMainChildrenAttr = Boolean.valueOf(response.getMainAtts().get("use-main-children-attribute")); if (useMainChildrenAttr) { sb = processMainChildrenAttribute(response.getMainAtts(), sb); } else { processOneLevel("", null, response.getMainAtts(), sb); } if (response.wasFailure()) { final String cause = response.getCause(); if(ok(cause)){ if (logger.isLoggable(Level.FINER)) { if (sb.length() > 0) sb.append(EOL); sb.append(cause); } throw new RemoteFailureException(sb.toString(), cause); } throw new RemoteFailureException(sb.toString()); } throw new RemoteSuccessException(sb.toString()); }
private void processProps(String prefix, Map<String, String> atts, StringBuilder sb) { // output "properties=(a=b,c=d)" List<NameValue<String,String>> props = response.getKeys(atts); for(Iterator<NameValue<String,String>> it = props.iterator(); it.hasNext(); ) { NameValue<String,String> nv = it.next(); if(nv.getName().startsWith("nb-")) it.remove(); } if(props == null || props.isEmpty()) return; if (sb.length() > 0) sb.append(EOL); sb.append(prefix).append("properties=("); boolean first = true; for(NameValue<String,String> nv : props) { String name = nv.getName(); String value = nv.getValue(); if(first) first = false; else sb.append(","); sb.append(name + "=" + value); } sb.append(")"); }
public void process() throws RemoteException { String usageText = response.getValue(AdminCommandResponse.SYNOPSIS); if(usageText == null) { // this is one way to figure out there was an error! throw new RemoteFailureException("XXXXXXXXXXXXXXXXXXXX", response.getMainMessage()); } setName(); setSynopsis(); setParamsAndOperands(); StringBuilder sb = new StringBuilder(); sb.append(EOL); printName(sb); printSynopsis(sb); printParams(sb); printOperands(sb); throw new RemoteSuccessException(sb.toString()); }
private void setSynopsis() { synopsis = response.getValue(AdminCommandResponse.SYNOPSIS); if (synopsis.startsWith("Usage: ")) { synopsis = synopsis.substring(7); } // this looks too horrible - go with one long line... //synopsis = displayInProperLen(synopsis); } private void printSynopsis(StringBuilder sb) {
public AdminCommandResponse(InputStream inStream) throws IOException { Manifest m = new Manifest(inStream); m.read(inStream); allRaw = ManifestUtils.normalize(m); mainRaw = ManifestUtils.getMain(allRaw); makeMain(); }
private void processGeneratedManPage() throws RemoteException { if(!response.isGeneratedHelp()) return; GeneratedManPageManager mgr = new GeneratedManPageManager(response); mgr.process(); }
private void setName() { name = displayInProperLen(response.getMainMessage()); }
private void processChildren(String prefix, String parent, Map<String, String> atts, StringBuilder sb) { Map<String,Map<String,String>> kids = response.getChildren(atts); if(kids == null || kids.isEmpty()) return; String childrenType = atts.get(AdminCommandResponse.CHILDREN_TYPE); int index = (parent == null) ? 0 : parent.length() + 1; for(Map.Entry<String, Map<String,String>> entry : kids.entrySet()) { String container = entry.getKey(); if (sb.length() > 0) sb.append(EOL); if(ok(childrenType)) { sb.append(prefix).append(childrenType).append(" : "); } try { sb.append(java.net.URLDecoder.decode(container.substring(index), "UTF-8")); } catch (Exception e) { sb.append(container.substring(index)); } processOneLevel(prefix + TAB, container, entry.getValue(), sb); } }
/** * Format: * (1) Main Attributes usually have the bulk of the data. Say you have 3 items * in there: a, b and c. The Manifest main attributes will end up with this: * keys=a;b;c * a_name=xxx * a_value=xxx * b_name=xxx * b_value=xxx * c_name=xxx * c_value=xxx */ private void makeMainKeys() { mainKeys = getKeys(mainRaw); for(NameValue<String,String> nv : mainKeys) { if(nv.getName().equals(GENERATED_HELP)) { isGeneratedHelp = Boolean.parseBoolean(nv.getValue()); mainKeys.remove(nv); break; } } }