Skip to content

Commit ae68194

Browse files
committed
Merge branch 'dev' of github.com:marklogic/java-client-api into dev
2 parents 6ea8d78 + 4f3e3c7 commit ae68194

File tree

8 files changed

+729
-295
lines changed

8 files changed

+729
-295
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.marklogic.javaclient;
2+
3+
import com.marklogic.client.pojo.annotation.PathIndexProperty;
4+
import com.marklogic.client.pojo.annotation.PathIndexProperty.ScalarType;
5+
6+
/* This class is used to test range path index creation, when the Annotation is
7+
* in the super class and sub class adds an additional annotation entry.
8+
*
9+
* Used to test annotation in a hierarchy.
10+
*/
11+
public class ArtifactIndexedOnStringSub extends ArtifactIndexedOnString {
12+
@PathIndexProperty(scalarType = ScalarType.DOUBLE)
13+
public double artifactWeight;
14+
15+
public double getArtifactWeight() {
16+
return artifactWeight;
17+
}
18+
19+
public ArtifactIndexedOnStringSub setArtifactWeight(double artifactWeight) {
20+
this.artifactWeight = artifactWeight; return this;
21+
}
22+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.marklogic.javaclient;
2+
3+
import com.marklogic.client.pojo.annotation.Id;
4+
import com.marklogic.client.pojo.annotation.PathIndexProperty;
5+
import com.marklogic.client.pojo.annotation.PathIndexProperty.ScalarType;
6+
7+
public class ArtifactIndexedUnSupportedDataType {
8+
@Id
9+
public long id;
10+
private String name;
11+
12+
//Note: Any Type other than supported ones in ScalarType class will have compile issues.
13+
@PathIndexProperty(scalarType = ScalarType.STRING)
14+
public Company manufacturer;
15+
private int inventory;
16+
17+
public long getId() {
18+
return id;
19+
}
20+
public ArtifactIndexedUnSupportedDataType setId(long id) {
21+
this.id= id; return this;
22+
}
23+
public String getName() {
24+
return name;
25+
}
26+
public ArtifactIndexedUnSupportedDataType setName(String name) {
27+
this.name = name; return this;
28+
}
29+
public Company getManufacturer() {
30+
return manufacturer;
31+
}
32+
public ArtifactIndexedUnSupportedDataType setManufacturer(Company manufacturer) {
33+
this.manufacturer= manufacturer; return this;
34+
}
35+
public int getInventory() {
36+
return inventory;
37+
}
38+
public ArtifactIndexedUnSupportedDataType setInventory(int inventory) {
39+
this.inventory= inventory; return this;
40+
}
41+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.marklogic.javaclient;
2+
3+
import com.marklogic.client.pojo.annotation.PathIndexProperty;
4+
import com.marklogic.client.pojo.annotation.PathIndexProperty.ScalarType;
5+
/* This class is used to test range path index creation, when the Annotation is
6+
* in the super class and also in sub class on the same class property with same data type.
7+
*
8+
* Used to test annotation with collisions in a hierarchy.
9+
*/
10+
11+
public class ArtifactMultipleIndexedOnInt extends ArtifactIndexedOnInt {
12+
@PathIndexProperty(scalarType = ScalarType.INT)
13+
private int inventory;
14+
15+
public int getInventory() {
16+
return inventory;
17+
}
18+
19+
public ArtifactMultipleIndexedOnInt setInventory(int inventory) {
20+
this.inventory = inventory; return this;
21+
}
22+
}

test-complete/src/test/java/com/marklogic/javaclient/ConnectedRESTQA.java

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ public static String getBootStrapHostFromML() {
9191
if(!jnode.isNull()){
9292

9393
if(jnode.has(propName)){
94-
// System.out.println(jnode.withArray(propName).get(0).asText());
95-
return jnode.withArray(propName).get(0).asText();
94+
System.out.println("Bootstrap Host: " + jnode.withArray(propName).get(0).get("bootstrap-host-name").asText());
95+
return jnode.withArray(propName).get(0).get("bootstrap-host-name").asText();
9696
}
9797
else{
9898
System.out.println("Missing "+propName+" field from properties end point so sending java conanical host name\n"+jnode.toString());
@@ -245,6 +245,29 @@ public static void associateRESTServerWithDB(String restServerName,String dbName
245245
System.out.println(content);
246246
}
247247
}
248+
/*
249+
* Associate REST server with default user
250+
* this is created for the sake of runtime DB selection
251+
*/
252+
public static void associateRESTServerWithDefaultUser(String restServerName,String userName,String authType)throws Exception{
253+
DefaultHttpClient client = new DefaultHttpClient();
254+
255+
client.getCredentialsProvider().setCredentials(
256+
new AuthScope("localhost", 8002),
257+
new UsernamePasswordCredentials("admin", "admin"));
258+
String body = "{ \"default-user\":\""+userName+"\",\"authentication\": \""+authType+"\",\"group-name\": \"Default\"}";
259+
260+
HttpPut put = new HttpPut("http://localhost:8002/manage/v2/servers/"+restServerName+"/properties?server-type=http");
261+
put.addHeader("Content-type", "application/json");
262+
put.setEntity(new StringEntity(body));
263+
264+
HttpResponse response2 = client.execute(put);
265+
HttpEntity respEntity = response2.getEntity();
266+
if(respEntity != null){
267+
String content = EntityUtils.toString(respEntity);
268+
System.out.println(content);
269+
}
270+
}
248271
/*
249272
* Creating RESTServer With default content and module database
250273
*/
@@ -1580,6 +1603,56 @@ else if (respEntity != null) {
15801603

15811604
}
15821605

1606+
/*
1607+
* Create a temporal collection
1608+
* @dbName Database Name
1609+
* @collectionName Collection Name (name of temporal collection that needs to be created)
1610+
* @systemAxisName Name of System axis
1611+
* @validAxisName Name of Valid axis
1612+
*/
1613+
public static void updateTemporalCollectionForLSQT(String dbName, String collectionName, boolean enable)
1614+
throws Exception
1615+
{
1616+
ObjectMapper mapper = new ObjectMapper();
1617+
ObjectNode rootNode = mapper.createObjectNode();
1618+
rootNode.put( "lsqt-enabled", enable);
1619+
1620+
System.out.println(rootNode.toString());
1621+
1622+
1623+
DefaultHttpClient client = new DefaultHttpClient();
1624+
client.getCredentialsProvider().setCredentials(
1625+
new AuthScope("localhost", 8002),
1626+
new UsernamePasswordCredentials("admin", "admin"));
1627+
1628+
HttpPut put = new HttpPut("http://localhost:8002/manage/v2/databases/"+ dbName + "/temporal/collections/lsqt/properties?collection=" + collectionName);
1629+
1630+
put.addHeader("Content-type", "application/json");
1631+
put.addHeader("accept", "application/json");
1632+
put.setEntity(new StringEntity(rootNode.toString()));
1633+
1634+
HttpResponse response = client.execute(put);
1635+
HttpEntity respEntity = response.getEntity();
1636+
if( response.getStatusLine().getStatusCode() == 400)
1637+
{
1638+
HttpEntity entity = response.getEntity();
1639+
String responseString = EntityUtils.toString(entity, "UTF-8");
1640+
System.out.println(responseString);
1641+
}
1642+
else if (respEntity != null) {
1643+
// EntityUtils to get the response content
1644+
String content = EntityUtils.toString(respEntity);
1645+
System.out.println(content);
1646+
1647+
System.out.println("Temporal collection: " + collectionName + " created");
1648+
System.out.println("==============================================================");
1649+
}
1650+
else {
1651+
System.out.println("No Proper Response");
1652+
}
1653+
1654+
}
1655+
15831656
/*
15841657
* Delete a temporal collection
15851658
* @dbName Database Name

0 commit comments

Comments
 (0)