MethodParameters mp = new MethodParameters(MethodType.valueOf(method.getAttributeValue("name"))); paramList.add(mp); for (Element param : method.getChildren("param")) { type = param.getAttributeValue("type"); mp.add(name, type);
if (methodParams != null) { for (MethodParameters params : methodParams) { String method = params.getMethod().toString().toLowerCase(); extraParams.add("method", method); String prefix = method+":"; for (Map.Entry<String,List<String>> entry: params.entrySet()) { extraParams.put(prefix+entry.getKey(), entry.getValue());
@Override public void writeServices( String resourceName, TextWriteHandle sourceHandle, ExtensionMetadata metadata, MethodParameters... methodParams ) { if (resourceName == null) throw new IllegalArgumentException("Writing resource services with null name"); if (logger.isInfoEnabled()) logger.info("Writing resource services source for {}", resourceName); HandleImplementation sourceBase = HandleAccessor.checkHandle(sourceHandle, "resource"); RequestParameters extraParams = (metadata != null) ? metadata.asParameters() : new RequestParameters(); if (methodParams != null) { for (MethodParameters params : methodParams) { String method = params.getMethod().toString().toLowerCase(); extraParams.add("method", method); String prefix = method+":"; for (Map.Entry<String,List<String>> entry: params.entrySet()) { extraParams.put(prefix+entry.getKey(), entry.getValue()); } } } services.putValue(requestLogger, "config/resources", resourceName, extraParams, "application/xquery", sourceBase); }
@Before public void setUp() throws KeyManagementException, NoSuchAlgorithmException, Exception { int restPort = getRestServerPort(); String appServerHostname = getRestAppServerHostName(); client = getDatabaseClientOnDatabase(appServerHostname, restPort, dbName, "eval-user", "x", getConnType()); resourceMgr = client.newServerConfigManager().newResourceExtensionsManager(); ExtensionMetadata resextMetadata = new ExtensionMetadata(); resextMetadata.setTitle("BasicJSTest"); resextMetadata.setDescription("Testing resource extension for java script"); System.out.println(resextMetadata.getScriptLanguage()); resextMetadata.setScriptLanguage(ScriptLanguage.JAVASCRIPT); System.out.println(resextMetadata.getScriptLanguage()); resextMetadata.setVersion("1.0"); MethodParameters getParams = new MethodParameters(MethodType.GET); getParams.add("my-uri", "xs:string?"); FileInputStream myStream = new FileInputStream("src/test/java/com/marklogic/client/functionaltest/data/JSResource.js"); InputStreamHandle handle = new InputStreamHandle(myStream); handle.set(myStream); resourceMgr.writeServices("simpleJSResourceModule", handle, resextMetadata, getParams); }
/** * Returns whether the method declaration is the same. */ @Override public boolean equals(Object other) { if (other == null) return false; if (!(other instanceof MethodParameters)) return false; MethodParameters otherParam = (MethodParameters) other; if (!getMethod().equals(otherParam.getMethod())) return false; return super.equals(otherParam); } }
/** * Returns whether the method declaration is the same. */ @Override public boolean equals(Object other) { if (other == null) return false; if (!(other instanceof MethodParameters)) return false; MethodParameters otherParam = (MethodParameters) other; if (!getMethod().equals(otherParam.getMethod())) return false; return super.equals(otherParam); } }
/** * Returns the hash code for the method. */ @Override public int hashCode() { return getMethod().hashCode(); } /**
static MethodParameters[] makeParameters() { MethodType[] methods = MethodType.values(); MethodParameters[] params = new MethodParameters[methods.length]; for (int i=0; i < methods.length; i++) { params[i] = new MethodParameters(methods[i]); params[i].put("value", "xs:boolean"); } return params; }
/** * Returns the hash code for the method. */ @Override public int hashCode() { return getMethod().hashCode(); } /**