{"action":"created","issue":{"url":"https://api.github.com/repos/marklogic/java-client-api/issues/384","repository_url":"https://api.github.com/repos/marklogic/java-client-api","labels_url":"https://api.github.com/repos/marklogic/java-client-api/issues/384/labels{/name}","comments_url":"https://api.github.com/repos/marklogic/java-client-api/issues/384/comments","events_url":"https://api.github.com/repos/marklogic/java-client-api/issues/384/events","html_url":"https://github.com/marklogic/java-client-api/issues/384","id":134695892,"number":384,"title":"TransformExtensionsManager readAs method throws FailedRequestException","user":{"login":"georgeajit","id":8634482,"avatar_url":"https://avatars.githubusercontent.com/u/8634482?v=3","gravatar_id":"","url":"https://api.github.com/users/georgeajit","html_url":"https://github.com/georgeajit","followers_url":"https://api.github.com/users/georgeajit/followers","following_url":"https://api.github.com/users/georgeajit/following{/other_user}","gists_url":"https://api.github.com/users/georgeajit/gists{/gist_id}","starred_url":"https://api.github.com/users/georgeajit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/georgeajit/subscriptions","organizations_url":"https://api.github.com/users/georgeajit/orgs","repos_url":"https://api.github.com/users/georgeajit/repos","events_url":"https://api.github.com/users/georgeajit/events{/privacy}","received_events_url":"https://api.github.com/users/georgeajit/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/marklogic/java-client-api/labels/Bug","name":"Bug","color":"e11d21"},{"url":"https://api.github.com/repos/marklogic/java-client-api/labels/major","name":"major","color":"fbca04"},{"url":"https://api.github.com/repos/marklogic/java-client-api/labels/verify","name":"verify","color":"eb6420"}],"state":"open","locked":false,"assignee":{"login":"sammefford","id":298950,"avatar_url":"https://avatars.githubusercontent.com/u/298950?v=3","gravatar_id":"","url":"https://api.github.com/users/sammefford","html_url":"https://github.com/sammefford","followers_url":"https://api.github.com/users/sammefford/followers","following_url":"https://api.github.com/users/sammefford/following{/other_user}","gists_url":"https://api.github.com/users/sammefford/gists{/gist_id}","starred_url":"https://api.github.com/users/sammefford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sammefford/subscriptions","organizations_url":"https://api.github.com/users/sammefford/orgs","repos_url":"https://api.github.com/users/sammefford/repos","events_url":"https://api.github.com/users/sammefford/events{/privacy}","received_events_url":"https://api.github.com/users/sammefford/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/marklogic/java-client-api/milestones/18","html_url":"https://github.com/marklogic/java-client-api/milestones/java-client-api-4.0-ea2","labels_url":"https://api.github.com/repos/marklogic/java-client-api/milestones/18/labels","id":1452909,"number":18,"title":"java-client-api-4.0-ea2","description":"Coincides with MarkLogic Server 9.0 Early Access 2","creator":{"login":"sammefford","id":298950,"avatar_url":"https://avatars.githubusercontent.com/u/298950?v=3","gravatar_id":"","url":"https://api.github.com/users/sammefford","html_url":"https://github.com/sammefford","followers_url":"https://api.github.com/users/sammefford/followers","following_url":"https://api.github.com/users/sammefford/following{/other_user}","gists_url":"https://api.github.com/users/sammefford/gists{/gist_id}","starred_url":"https://api.github.com/users/sammefford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sammefford/subscriptions","organizations_url":"https://api.github.com/users/sammefford/orgs","repos_url":"https://api.github.com/users/sammefford/repos","events_url":"https://api.github.com/users/sammefford/events{/privacy}","received_events_url":"https://api.github.com/users/sammefford/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":1,"state":"open","created_at":"2015-12-09T23:00:38Z","updated_at":"2016-02-25T00:44:55Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2016-02-18T21:03:04Z","updated_at":"2016-02-25T01:15:19Z","closed_at":null,"body":"Using one of the Java IO classes to read a XSL transform code, causes a FailedRequestException.\r\nThe motive of this test was to validate Git Issue 332.\r\n\r\nSince only users with the http://marklogic.com/xdmp/privileges/xdmp-eval-in (xdmp:eval-in) or equivalent privilege can send request parameter that enables the request to be evaluated against a content database other than the default  database associated with the REST API instance,the test creates a user called \"eval-user\" who has the following role \"test-eval\".\r\n\r\nRole \"test-eval\" has the following previlages : \r\n```\r\n\"xdbc:eval\", \"xdbc:eval-in\",\"xdmp:eval-in\",\"any-uri\",\"xdbc:invoke\"\r\n```\r\nBut \r\n```\r\nTransformExtensionsManager readXSLTransformAs(transformName, FileReader.class)\r\n```\r\nthrows an exception. Using a BufferedReader also threw same exception. Maybe the API usage in the test is missing something or incorrectly used.\r\n\r\nHere is the sample test code:\r\n```\r\n\t@Test\t\r\n\tpublic void testXsltTransformReadAs() throws IOException, ParserConfigurationException, SAXException, XpathException, TransformerException\r\n\t{\t\r\n\t\tSystem.out.println(\"Running testXsltTransformReadAs\");\r\n\r\n\t\tString[] filenames = {\"constraint1.xml\", \"constraint2.xml\", \"constraint3.xml\", \"constraint4.xml\", \"constraint5.xml\"};\r\n\t\tString transformName = \"search2html\";\r\n\r\n\t\tDatabaseClient client = DatabaseClientFactory.newClient(\"localhost\", Uberport, UberdbName, \"eval-user\", \"x\", Authentication.DIGEST);\r\n\r\n\t\t// set query option validation to true\r\n\t\tServerConfigurationManager srvMgr = client.newServerConfigManager();\r\n\t\tsrvMgr.readConfiguration();\r\n\t\tsrvMgr.setQueryOptionValidation(true);\r\n\t\tsrvMgr.writeConfiguration();\r\n\r\n\t\t// write docs\r\n\t\tfor(String filename : filenames)\r\n\t\t{\r\n\t\t\twriteDocumentUsingInputStreamHandle(client, filename, \"/response-transform/\", \"XML\");\r\n\t\t}\r\n\r\n\t\t// set the transform\t\t\r\n\t\t// create a manager for transform extensions\r\n\t\tTransformExtensionsManager transMgr = client.newServerConfigManager().newTransformExtensionsManager();\r\n\r\n\t\t// specify metadata about the transform extension\r\n\t\tExtensionMetadata metadata = new ExtensionMetadata();\r\n\t\tmetadata.setTitle(\"Search-Response-TO-HTML XSLT Transform\");\r\n\t\tmetadata.setDescription(\"This plugin transforms a Search Response document to HTML\");\r\n\t\tmetadata.setProvider(\"MarkLogic\");\r\n\t\tmetadata.setVersion(\"0.1\");\r\n\r\n\t\t// get the transform file\r\n\t\tFile transformFile = new File(\"src/test/java/com/marklogic/client/functionaltest/transforms/search2html.xsl\");\r\n\r\n\t\tFileHandle transformHandle = new FileHandle(transformFile);\r\n\r\n\t\t// write the transform\r\n\t\ttransMgr.writeXSLTransform(transformName, transformHandle, metadata);\r\n\r\n\t\t// get the combined query\r\n\t\tFile file = new File(\"src/test/java/com/marklogic/client/functionaltest/combined/combinedQueryOption.xml\");\r\n\r\n\t\tString combinedQuery = convertFileToString(file);\r\n\r\n\t\t// create a handle for the search criteria\r\n\t\tStringHandle rawHandle = new StringHandle(combinedQuery);\r\n\r\n\t\tQueryManager queryMgr = client.newQueryManager();\r\n\r\n\t\t// create a search definition based on the handle\r\n\t\tRawCombinedQueryDefinition querydef = queryMgr.newRawCombinedQueryDefinition(rawHandle);\r\n\t\tquerydef.setResponseTransform(new ServerTransform(\"search2html\"));\r\n\r\n\t\t// create result handle\r\n\t\tStringHandle resultsHandle = new StringHandle();\r\n\t\tqueryMgr.search(querydef, resultsHandle);\r\n\r\n\t\t// get the result\r\n\t\tString resultDoc = resultsHandle.get();\r\n\r\n\t\tSystem.out.println(resultDoc);\r\n\r\n\t\tassertTrue(\"transform on title is not found\", resultDoc.contains(\"<title>Custom Search Results</title>\"));\r\n\t\tassertTrue(\"transform on header is not found\", resultDoc.contains(\"MyURI\"));\r\n\t\tassertTrue(\"transform on doc return is not found\", resultDoc.contains(\"<td align=\\\"left\\\">/response-transform/constraint5.xml</td>\"));\r\n\r\n\t\t\r\n\t\tFileReader srtReadXSLTCodeHandle1 = transMgr.readXSLTransformAs(transformName, FileReader.class);\r\n\r\n\t\ttransMgr.deleteTransform(\"search2html\");\r\n\r\n\t\t// release client\r\n\t\tclient.release();\t\t\r\n\t}\r\n\r\n```\r\n\r\nHere is the stack trace:\r\n```\r\ncom.marklogic.client.FailedRequestException: Local message: config/transforms read failed: Bad Request. Server Message: REST-UNSUPPORTEDPARAM: (rest:UNSUPPORTEDPARAM) Endpoint does not support query parameter: database\r\n\tat com.marklogic.client.impl.JerseyServices.getValue(JerseyServices.java:2733)\r\n\tat com.marklogic.client.impl.TransformExtensionsImpl.readTransform(TransformExtensionsImpl.java:197)\r\n\tat com.marklogic.client.impl.TransformExtensionsImpl.readXSLTransform(TransformExtensionsImpl.java:182)\r\n\tat com.marklogic.client.impl.TransformExtensionsImpl.readXSLTransformAs(TransformExtensionsImpl.java:147)\r\n\tat com.marklogic.client.functionaltest.TestDatabaseClientConnection.testXsltTransformReadAs(TestDatabaseClientConnection.java:535)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)\r\n\tat java.lang.reflect.Method.invoke(Unknown Source)\r\n\tat org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)\r\n\tat org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)\r\n\tat org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)\r\n\tat org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)\r\n\tat org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)\r\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)\r\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)\r\n\tat org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)\r\n\tat org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)\r\n\tat org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)\r\n\tat org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)\r\n\tat org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)\r\n\tat org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)\r\n\tat org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)\r\n\tat org.junit.runners.ParentRunner.run(ParentRunner.java:309)\r\n\tat org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)\r\n\tat org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:19\r\n```"},"comment":{"url":"https://api.github.com/repos/marklogic/java-client-api/issues/comments/188545137","html_url":"https://github.com/marklogic/java-client-api/issues/384#issuecomment-188545137","issue_url":"https://api.github.com/repos/marklogic/java-client-api/issues/384","id":188545137,"user":{"login":"kcoleman-marklogic","id":1951367,"avatar_url":"https://avatars.githubusercontent.com/u/1951367?v=3","gravatar_id":"","url":"https://api.github.com/users/kcoleman-marklogic","html_url":"https://github.com/kcoleman-marklogic","followers_url":"https://api.github.com/users/kcoleman-marklogic/followers","following_url":"https://api.github.com/users/kcoleman-marklogic/following{/other_user}","gists_url":"https://api.github.com/users/kcoleman-marklogic/gists{/gist_id}","starred_url":"https://api.github.com/users/kcoleman-marklogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kcoleman-marklogic/subscriptions","organizations_url":"https://api.github.com/users/kcoleman-marklogic/orgs","repos_url":"https://api.github.com/users/kcoleman-marklogic/repos","events_url":"https://api.github.com/users/kcoleman-marklogic/events{/privacy}","received_events_url":"https://api.github.com/users/kcoleman-marklogic/received_events","type":"User","site_admin":false},"created_at":"2016-02-25T01:15:19Z","updated_at":"2016-02-25T01:15:19Z","body":"I don't understand the concern about being consistent with the REST behavior. The REST API is throwing an error because the API is using it wrong, not because there's something special about passing it the database parameter. If the Java API passed it a parameter named \"sausage\", you'd get the same behavior. The user isn't doing anything wrong. We are.\r\n\r\nI think as long as we talk about the parameter in terms of the content database, there's no need to fear the database entanglement, either. The REST dev guide, REST apidoc, and the Java dev guide all talk about this knob as changing the CONTENT database. The javadoc doesn't, which may be where your concern arises. It just says the following, which is misleading:\r\n\r\n\"database - the database to access (default: configured database for the REST server)\"\r\n\r\nAnyway, I'll take pity on the poor horse and stop beating it now. :)"}}