From cdb55499f64d3764ef15b5203e9e5bdba52fe008 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sat, 27 Jan 2024 12:39:06 +0900 Subject: [PATCH] Replace CRLF by LF ... because LF is now commonly used as newline code. Also some files in the samples directory has 755 permission but x bit is not needed. This removes the unnecessary bit as well. Change-Id: I6119e508481c9c0f8a5c1c2c40bb2e3a788abd3c --- .../receive_message/JsonDecoder.java | 84 ++++++------- .../receive_message/SampleZaqarEndpoint.java | 114 +++++++++--------- .../send_message/SampleZaqarEndpoint.java | 90 +++++++------- .../receive_message/zaqar_sample.js | 64 +++++----- .../javascript/send_message/zaqar_sample.js | 50 ++++---- .../receive_message/SampleZaqarServlet.java | 110 ++++++++--------- .../send_message/SampleZaqarServlet.java | 104 ++++++++-------- .../nodejs/receive_message/zaqar_sample.js | 68 +++++------ samples/nodejs/send_message/zaqar_sample.js | 54 ++++----- .../receive_message/zaqar_sample.py | 0 .../send_message/zaqar_sample.py | 0 11 files changed, 369 insertions(+), 369 deletions(-) mode change 100755 => 100644 samples/java-api-for-websocket/receive_message/JsonDecoder.java mode change 100755 => 100644 samples/java-api-for-websocket/receive_message/SampleZaqarEndpoint.java mode change 100755 => 100644 samples/java-api-for-websocket/send_message/SampleZaqarEndpoint.java mode change 100755 => 100644 samples/javascript/receive_message/zaqar_sample.js mode change 100755 => 100644 samples/javascript/send_message/zaqar_sample.js mode change 100755 => 100644 samples/jaxrs/receive_message/SampleZaqarServlet.java mode change 100755 => 100644 samples/jaxrs/send_message/SampleZaqarServlet.java mode change 100755 => 100644 samples/nodejs/receive_message/zaqar_sample.js mode change 100755 => 100644 samples/nodejs/send_message/zaqar_sample.js mode change 100755 => 100644 samples/python-zaqarclient/receive_message/zaqar_sample.py mode change 100755 => 100644 samples/python-zaqarclient/send_message/zaqar_sample.py diff --git a/samples/java-api-for-websocket/receive_message/JsonDecoder.java b/samples/java-api-for-websocket/receive_message/JsonDecoder.java old mode 100755 new mode 100644 index ced97f223..feaeef436 --- a/samples/java-api-for-websocket/receive_message/JsonDecoder.java +++ b/samples/java-api-for-websocket/receive_message/JsonDecoder.java @@ -1,43 +1,43 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package org.openstack.zaqar.sample; - -import java.io.StringReader; - -import javax.json.Json; -import javax.json.JsonObject; -import javax.websocket.Decoder; -import javax.websocket.EndpointConfig; - -public final class JsonDecoder implements Decoder.Text { - - @Override - public JsonObject decode(final String s) { - return Json.createReader(new StringReader(s)).readObject(); - } - - @Override - public void destroy() { - } - - @Override - public void init(final EndpointConfig config) { - } - - @Override - public boolean willDecode(final String s) { - return true; - } - +/* + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package org.openstack.zaqar.sample; + +import java.io.StringReader; + +import javax.json.Json; +import javax.json.JsonObject; +import javax.websocket.Decoder; +import javax.websocket.EndpointConfig; + +public final class JsonDecoder implements Decoder.Text { + + @Override + public JsonObject decode(final String s) { + return Json.createReader(new StringReader(s)).readObject(); + } + + @Override + public void destroy() { + } + + @Override + public void init(final EndpointConfig config) { + } + + @Override + public boolean willDecode(final String s) { + return true; + } + } \ No newline at end of file diff --git a/samples/java-api-for-websocket/receive_message/SampleZaqarEndpoint.java b/samples/java-api-for-websocket/receive_message/SampleZaqarEndpoint.java old mode 100755 new mode 100644 index 3d1787320..55d4ebbc2 --- a/samples/java-api-for-websocket/receive_message/SampleZaqarEndpoint.java +++ b/samples/java-api-for-websocket/receive_message/SampleZaqarEndpoint.java @@ -1,57 +1,57 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -import static java.lang.System.out; - -import java.io.IOException; - -import javax.json.JsonObject; -import javax.websocket.ClientEndpoint; -import javax.websocket.OnMessage; -import javax.websocket.OnOpen; -import javax.websocket.RemoteEndpoint; -import javax.websocket.Session; - -@ClientEndpoint(decoders = JsonDecoder.class) -public final class SampleZaqarEndpoint { - - @OnMessage - public void onMessage(final JsonObject msg) { - - if (msg.getJsonObject("body").getJsonArray("messages") != null) - out.println(msg.getJsonObject("body").getJsonArray("messages") - .getJsonObject(0).getString("body")); - - } - - @OnOpen - public void onOpen(final Session sess) throws IOException { - final RemoteEndpoint.Basic remote = sess.getBasicRemote(); - - final String authenticateMsg = "{\"action\":\"authenticate\"," - + "\"headers\":{\"X-Auth-Token\":" - + "\"8444886dd9b04a1b87ddb502b508261c\",\"X-Project-ID\":" - + "\"7530fad032ca431e9dc8ed4a5de5d99c\"}}"; // refer to bug - // #1553398 - - remote.sendText(authenticateMsg); - - final String claimCreateMsg = "{\"action\":\"claim_create\",\"body\":" - + "{\"queue_name\":\"SampleQueue\"},\"headers\":{\"Client-ID\":" - + "\"355186cd-d1e8-4108-a3ac-a2183697232a\",\"X-Project-ID\":" - + "\"7530fad032ca431e9dc8ed4a5de5d99c\"}}"; - - remote.sendText(claimCreateMsg); - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +import static java.lang.System.out; + +import java.io.IOException; + +import javax.json.JsonObject; +import javax.websocket.ClientEndpoint; +import javax.websocket.OnMessage; +import javax.websocket.OnOpen; +import javax.websocket.RemoteEndpoint; +import javax.websocket.Session; + +@ClientEndpoint(decoders = JsonDecoder.class) +public final class SampleZaqarEndpoint { + + @OnMessage + public void onMessage(final JsonObject msg) { + + if (msg.getJsonObject("body").getJsonArray("messages") != null) + out.println(msg.getJsonObject("body").getJsonArray("messages") + .getJsonObject(0).getString("body")); + + } + + @OnOpen + public void onOpen(final Session sess) throws IOException { + final RemoteEndpoint.Basic remote = sess.getBasicRemote(); + + final String authenticateMsg = "{\"action\":\"authenticate\"," + + "\"headers\":{\"X-Auth-Token\":" + + "\"8444886dd9b04a1b87ddb502b508261c\",\"X-Project-ID\":" + + "\"7530fad032ca431e9dc8ed4a5de5d99c\"}}"; // refer to bug + // #1553398 + + remote.sendText(authenticateMsg); + + final String claimCreateMsg = "{\"action\":\"claim_create\",\"body\":" + + "{\"queue_name\":\"SampleQueue\"},\"headers\":{\"Client-ID\":" + + "\"355186cd-d1e8-4108-a3ac-a2183697232a\",\"X-Project-ID\":" + + "\"7530fad032ca431e9dc8ed4a5de5d99c\"}}"; + + remote.sendText(claimCreateMsg); + } + +} diff --git a/samples/java-api-for-websocket/send_message/SampleZaqarEndpoint.java b/samples/java-api-for-websocket/send_message/SampleZaqarEndpoint.java old mode 100755 new mode 100644 index d9d608a85..9bfe06d17 --- a/samples/java-api-for-websocket/send_message/SampleZaqarEndpoint.java +++ b/samples/java-api-for-websocket/send_message/SampleZaqarEndpoint.java @@ -1,45 +1,45 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -import java.io.IOException; - -import javax.websocket.ClientEndpoint; -import javax.websocket.OnOpen; -import javax.websocket.RemoteEndpoint; -import javax.websocket.Session; - -@ClientEndpoint -public final class SampleZaqarEndpoint { - - @OnOpen - public void onOpen(final Session sess) throws IOException { - final RemoteEndpoint.Basic remote = sess.getBasicRemote(); - - final String authenticateMsg = "{\"action\":\"authenticate\"," - + "\"headers\":{\"X-Auth-Token\":" - + "\"8444886dd9b04a1b87ddb502b508261c\",\"X-Project-ID\":" - + "\"7530fad032ca431e9dc8ed4a5de5d99c\"}}"; // refer to bug - // #1553398 - - remote.sendText(authenticateMsg); - - final String messagePostMsg = "{\"action\":\"message_post\",\"body\":" - + "{\"messages\":[{\"body\":\"Zaqar Sample\"}],\"queue_name\":" - + "\"SampleQueue\"},\"headers\":{\"Client-ID\":" - + "\"355186cd-d1e8-4108-a3ac-a2183697232a\",\"X-Project-ID\":" - + "\"7530fad032ca431e9dc8ed4a5de5d99c\"}}"; - - remote.sendText(messagePostMsg); - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +import java.io.IOException; + +import javax.websocket.ClientEndpoint; +import javax.websocket.OnOpen; +import javax.websocket.RemoteEndpoint; +import javax.websocket.Session; + +@ClientEndpoint +public final class SampleZaqarEndpoint { + + @OnOpen + public void onOpen(final Session sess) throws IOException { + final RemoteEndpoint.Basic remote = sess.getBasicRemote(); + + final String authenticateMsg = "{\"action\":\"authenticate\"," + + "\"headers\":{\"X-Auth-Token\":" + + "\"8444886dd9b04a1b87ddb502b508261c\",\"X-Project-ID\":" + + "\"7530fad032ca431e9dc8ed4a5de5d99c\"}}"; // refer to bug + // #1553398 + + remote.sendText(authenticateMsg); + + final String messagePostMsg = "{\"action\":\"message_post\",\"body\":" + + "{\"messages\":[{\"body\":\"Zaqar Sample\"}],\"queue_name\":" + + "\"SampleQueue\"},\"headers\":{\"Client-ID\":" + + "\"355186cd-d1e8-4108-a3ac-a2183697232a\",\"X-Project-ID\":" + + "\"7530fad032ca431e9dc8ed4a5de5d99c\"}}"; + + remote.sendText(messagePostMsg); + } + +} diff --git a/samples/javascript/receive_message/zaqar_sample.js b/samples/javascript/receive_message/zaqar_sample.js old mode 100755 new mode 100644 index 3c41e2056..4ea8a9098 --- a/samples/javascript/receive_message/zaqar_sample.js +++ b/samples/javascript/receive_message/zaqar_sample.js @@ -1,32 +1,32 @@ -/* - * Licensed under the Apache License, Version 2.0 (the 'License'); you may not - * use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -const ws = new WebSocket('ws://localhost:9000'); - -ws.onmessage = (e) => { - const msg = JSON.parse(e.data); - - if (msg.body.messages) - console.log(msg.body.messages[0].body); - -}; - -ws.onopen = () => { - ws.send('{"action": "authenticate", "headers": {"X-Auth-Token": \ - "8444886dd9b04a1b87ddb502b508261c", "X-Project-ID": \ - "7530fad032ca431e9dc8ed4a5de5d99c"}}'); // refer to bug #1553398 - - ws.send('{"action": "claim_create", "body": {"queue_name": "SampleQueue"}, \ - "headers": {"Client-ID": "355186cd-d1e8-4108-a3ac-a2183697232a", \ - "X-Project-ID": "7530fad032ca431e9dc8ed4a5de5d99c"}}'); -}; +/* + * Licensed under the Apache License, Version 2.0 (the 'License'); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +const ws = new WebSocket('ws://localhost:9000'); + +ws.onmessage = (e) => { + const msg = JSON.parse(e.data); + + if (msg.body.messages) + console.log(msg.body.messages[0].body); + +}; + +ws.onopen = () => { + ws.send('{"action": "authenticate", "headers": {"X-Auth-Token": \ + "8444886dd9b04a1b87ddb502b508261c", "X-Project-ID": \ + "7530fad032ca431e9dc8ed4a5de5d99c"}}'); // refer to bug #1553398 + + ws.send('{"action": "claim_create", "body": {"queue_name": "SampleQueue"}, \ + "headers": {"Client-ID": "355186cd-d1e8-4108-a3ac-a2183697232a", \ + "X-Project-ID": "7530fad032ca431e9dc8ed4a5de5d99c"}}'); +}; diff --git a/samples/javascript/send_message/zaqar_sample.js b/samples/javascript/send_message/zaqar_sample.js old mode 100755 new mode 100644 index eee7850f4..75141b3e7 --- a/samples/javascript/send_message/zaqar_sample.js +++ b/samples/javascript/send_message/zaqar_sample.js @@ -1,25 +1,25 @@ -/* - * Licensed under the Apache License, Version 2.0 (the 'License'); you may not - * use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -const ws = new WebSocket('ws://localhost:9000'); - -ws.onopen = () => { - ws.send('{"action": "authenticate", "headers": {"X-Auth-Token": \ - "8444886dd9b04a1b87ddb502b508261c", "X-Project-ID": \ - "7530fad032ca431e9dc8ed4a5de5d99c"}}'); // refer to bug #1553398 - - ws.send('{"action": "message_post", "body": {"messages": [{"body": \ - "Zaqar Sample"}], "queue_name": "SampleQueue"}, "headers": \ - {"Client-ID": "355186cd-d1e8-4108-a3ac-a2183697232a", "X-Project-ID": \ - "7530fad032ca431e9dc8ed4a5de5d99c"}}'); -}; +/* + * Licensed under the Apache License, Version 2.0 (the 'License'); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +const ws = new WebSocket('ws://localhost:9000'); + +ws.onopen = () => { + ws.send('{"action": "authenticate", "headers": {"X-Auth-Token": \ + "8444886dd9b04a1b87ddb502b508261c", "X-Project-ID": \ + "7530fad032ca431e9dc8ed4a5de5d99c"}}'); // refer to bug #1553398 + + ws.send('{"action": "message_post", "body": {"messages": [{"body": \ + "Zaqar Sample"}], "queue_name": "SampleQueue"}, "headers": \ + {"Client-ID": "355186cd-d1e8-4108-a3ac-a2183697232a", "X-Project-ID": \ + "7530fad032ca431e9dc8ed4a5de5d99c"}}'); +}; diff --git a/samples/jaxrs/receive_message/SampleZaqarServlet.java b/samples/jaxrs/receive_message/SampleZaqarServlet.java old mode 100755 new mode 100644 index 844e2acff..21c83fcef --- a/samples/jaxrs/receive_message/SampleZaqarServlet.java +++ b/samples/jaxrs/receive_message/SampleZaqarServlet.java @@ -1,55 +1,55 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -import java.io.IOException; - -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; - -@SuppressWarnings("serial") -@WebServlet(name = "SampleServlet", value = "/") -public final class SampleZaqarServlet extends HttpServlet { - - @Override - protected void doGet(final HttpServletRequest req, - final HttpServletResponse resp) throws IOException { - final Client client = ClientBuilder.newClient(); - - final MultivaluedMap headers = - new MultivaluedHashMap(); - - headers.putSingle("Client-ID", "355186cd-d1e8-4108-a3ac-a2183697232a"); - - headers.putSingle("X-Auth-Token", "8444886dd9b04a1b87ddb502b508261c"); - - headers.putSingle("X-Project-Id", "7530fad032ca431e9dc8ed4a5de5d99c"); - - final Response res = client - .target("http://localhost:8888/v2/queues/SampleQueue/claims") - .request().headers(headers).post(Entity.json("")); - - resp.getWriter().println(res.readEntity(String.class)); - - client.close(); - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +import java.io.IOException; + +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; + +@SuppressWarnings("serial") +@WebServlet(name = "SampleServlet", value = "/") +public final class SampleZaqarServlet extends HttpServlet { + + @Override + protected void doGet(final HttpServletRequest req, + final HttpServletResponse resp) throws IOException { + final Client client = ClientBuilder.newClient(); + + final MultivaluedMap headers = + new MultivaluedHashMap(); + + headers.putSingle("Client-ID", "355186cd-d1e8-4108-a3ac-a2183697232a"); + + headers.putSingle("X-Auth-Token", "8444886dd9b04a1b87ddb502b508261c"); + + headers.putSingle("X-Project-Id", "7530fad032ca431e9dc8ed4a5de5d99c"); + + final Response res = client + .target("http://localhost:8888/v2/queues/SampleQueue/claims") + .request().headers(headers).post(Entity.json("")); + + resp.getWriter().println(res.readEntity(String.class)); + + client.close(); + } + +} diff --git a/samples/jaxrs/send_message/SampleZaqarServlet.java b/samples/jaxrs/send_message/SampleZaqarServlet.java old mode 100755 new mode 100644 index 64690f474..cab535c2f --- a/samples/jaxrs/send_message/SampleZaqarServlet.java +++ b/samples/jaxrs/send_message/SampleZaqarServlet.java @@ -1,52 +1,52 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; - -@SuppressWarnings("serial") -@WebServlet(name = "SampleZaqarServlet", value = "/") -public final class SampleZaqarServlet extends HttpServlet { - - @Override - protected void doGet(final HttpServletRequest req, - final HttpServletResponse resp) { - final Client client = ClientBuilder.newClient(); - - final MultivaluedMap headers = - new MultivaluedHashMap(); - - headers.putSingle("Client-ID", "355186cd-d1e8-4108-a3ac-a2183697232a"); - - headers.putSingle("X-Auth-Token", "8444886dd9b04a1b87ddb502b508261c"); - - headers.putSingle("X-Project-Id", "7530fad032ca431e9dc8ed4a5de5d99c"); - - client.target("http://localhost:8888/v2/queues/SampleQueue/messages") - .request(MediaType.APPLICATION_JSON_TYPE).headers(headers) - .post(Entity - .json("{\"messages\":[{\"body\":\"Zaqar Sample\"}]}")); - - client.close(); - } - -} +/* + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.MultivaluedMap; + +@SuppressWarnings("serial") +@WebServlet(name = "SampleZaqarServlet", value = "/") +public final class SampleZaqarServlet extends HttpServlet { + + @Override + protected void doGet(final HttpServletRequest req, + final HttpServletResponse resp) { + final Client client = ClientBuilder.newClient(); + + final MultivaluedMap headers = + new MultivaluedHashMap(); + + headers.putSingle("Client-ID", "355186cd-d1e8-4108-a3ac-a2183697232a"); + + headers.putSingle("X-Auth-Token", "8444886dd9b04a1b87ddb502b508261c"); + + headers.putSingle("X-Project-Id", "7530fad032ca431e9dc8ed4a5de5d99c"); + + client.target("http://localhost:8888/v2/queues/SampleQueue/messages") + .request(MediaType.APPLICATION_JSON_TYPE).headers(headers) + .post(Entity + .json("{\"messages\":[{\"body\":\"Zaqar Sample\"}]}")); + + client.close(); + } + +} diff --git a/samples/nodejs/receive_message/zaqar_sample.js b/samples/nodejs/receive_message/zaqar_sample.js old mode 100755 new mode 100644 index 62526a235..0c8b87d9a --- a/samples/nodejs/receive_message/zaqar_sample.js +++ b/samples/nodejs/receive_message/zaqar_sample.js @@ -1,34 +1,34 @@ -/* - * Licensed under the Apache License, Version 2.0 (the 'License'); you may not - * use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -const WebSocket = require('ws'); - -const ws = new WebSocket('ws://localhost:9000'); - -ws.on('message', (data, flags) => { - const msg = JSON.parse(data); - - if (msg.body.messages) - console.log(msg.body.messages[0].body); - -}); - -ws.on('open', () => { - ws.send('{"action": "authenticate", "headers": {"X-Auth-Token": \ - "8444886dd9b04a1b87ddb502b508261c", "X-Project-ID": \ - "7530fad032ca431e9dc8ed4a5de5d99c"}}'); // refer to bug #1553398 - - ws.send('{"action": "claim_create", "body": {"queue_name": "SampleQueue"}, \ - "headers": {"Client-ID": "355186cd-d1e8-4108-a3ac-a2183697232a", \ - "X-Project-ID": "7530fad032ca431e9dc8ed4a5de5d99c"}}'); -}); +/* + * Licensed under the Apache License, Version 2.0 (the 'License'); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +const WebSocket = require('ws'); + +const ws = new WebSocket('ws://localhost:9000'); + +ws.on('message', (data, flags) => { + const msg = JSON.parse(data); + + if (msg.body.messages) + console.log(msg.body.messages[0].body); + +}); + +ws.on('open', () => { + ws.send('{"action": "authenticate", "headers": {"X-Auth-Token": \ + "8444886dd9b04a1b87ddb502b508261c", "X-Project-ID": \ + "7530fad032ca431e9dc8ed4a5de5d99c"}}'); // refer to bug #1553398 + + ws.send('{"action": "claim_create", "body": {"queue_name": "SampleQueue"}, \ + "headers": {"Client-ID": "355186cd-d1e8-4108-a3ac-a2183697232a", \ + "X-Project-ID": "7530fad032ca431e9dc8ed4a5de5d99c"}}'); +}); diff --git a/samples/nodejs/send_message/zaqar_sample.js b/samples/nodejs/send_message/zaqar_sample.js old mode 100755 new mode 100644 index 45df9dbc1..d5a645363 --- a/samples/nodejs/send_message/zaqar_sample.js +++ b/samples/nodejs/send_message/zaqar_sample.js @@ -1,27 +1,27 @@ -/* - * Licensed under the Apache License, Version 2.0 (the 'License'); you may not - * use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -const WebSocket = require('ws'); - -const ws = new WebSocket('ws://localhost:9000'); - -ws.on('open', () => { - ws.send('{"action": "authenticate", "headers": {"X-Auth-Token": \ - "8444886dd9b04a1b87ddb502b508261c", "X-Project-ID": \ - "7530fad032ca431e9dc8ed4a5de5d99c"}}'); // refer to bug #1553398 - - ws.send('{"action": "message_post", "body": {"messages": [{"body": \ - "Zaqar Sample"}], "queue_name": "SampleQueue"}, "headers": \ - {"Client-ID": "355186cd-d1e8-4108-a3ac-a2183697232a", "X-Project-ID": \ - "7530fad032ca431e9dc8ed4a5de5d99c"}}'); -}); +/* + * Licensed under the Apache License, Version 2.0 (the 'License'); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +const WebSocket = require('ws'); + +const ws = new WebSocket('ws://localhost:9000'); + +ws.on('open', () => { + ws.send('{"action": "authenticate", "headers": {"X-Auth-Token": \ + "8444886dd9b04a1b87ddb502b508261c", "X-Project-ID": \ + "7530fad032ca431e9dc8ed4a5de5d99c"}}'); // refer to bug #1553398 + + ws.send('{"action": "message_post", "body": {"messages": [{"body": \ + "Zaqar Sample"}], "queue_name": "SampleQueue"}, "headers": \ + {"Client-ID": "355186cd-d1e8-4108-a3ac-a2183697232a", "X-Project-ID": \ + "7530fad032ca431e9dc8ed4a5de5d99c"}}'); +}); diff --git a/samples/python-zaqarclient/receive_message/zaqar_sample.py b/samples/python-zaqarclient/receive_message/zaqar_sample.py old mode 100755 new mode 100644 diff --git a/samples/python-zaqarclient/send_message/zaqar_sample.py b/samples/python-zaqarclient/send_message/zaqar_sample.py old mode 100755 new mode 100644