Commit f20f72d2 by everdarkgreen

assignment bug

parent a5d60174
......@@ -9,6 +9,7 @@ import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -27,9 +28,10 @@ import javax.ejb.MessageDriven;
@ActivationConfigProperty(propertyName = "destination", propertyValue = "java:jboss/queues/Integration/CustomBP"),
@ActivationConfigProperty(propertyName = "reconnectAttempts", propertyValue = "32"),
@ActivationConfigProperty(propertyName = "reconnectInterval", propertyValue = "4000"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")})
public class Main implements MessageListener {
private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
@Override
......@@ -37,16 +39,15 @@ public class Main implements MessageListener {
LOGGER.error("CWM work starts");
String dataUUID = null;
String executionID = null;
String documentID = null;
String dataUUID = null; // идентификатор данных по форме записи реестра
String executionID = null; // идентификатор блокирующего процесса
String documentID = null; // идентификатор документа реестра
if (!(message instanceof TextMessage)) {
return;
}
try {
JsonFactory factory = new JsonFactory();
JsonParser parser = factory.createParser(((TextMessage) message).getText());
JsonToken token = null;
......@@ -72,55 +73,89 @@ public class Main implements MessageListener {
}
}
// Выполнение каких-либо действий
//
// Получение данных исходной формы
URL getFormDataURL = new URL("http://127.0.0.1:8080/Synergy/rest/api/asforms/data/" + dataUUID);
JsonParser sourceFormData = synergyApiGet(getFormDataURL);
// Получение значений текущих дат исходной формы
String b2b1, b4b1, b5b1;
String t4b1, t6b1, t2b1;
String t10b1, t12b1, t8b1;
String t18b1, t20b1, t16b1;
String t26b1, t24b1, t22b1;
String t32b1, t30b1, t28b1;
b2b1 = getDateKeyByFieldName(sourceFormData, "b2-b1");
b4b1 = getDateKeyByFieldName(sourceFormData, "b4-b1");
LOGGER.info(getDateKeyByFieldName(sourceFormData, "b2-b1"));
// Получение данных целевой карточки
// Разблокировка маршрута
String address = "http://127.0.0.1:8080/Synergy";
String login = "1";
String password = "1";
String signal = "got_agree";
boolean isSuccess = false;
URL url = new URL(address + "/rest/api/processes/signal?signal=" + signal + "&executionID=" + executionID + "&param1=resolution&value1=signal_is_" + signal);
synergyApiGet(url);
} catch (Exception exc) {
LOGGER.error(exc.getMessage(), exc);
}
}
private String getDateKeyByFieldName(final JsonParser formJson, final String fieldName) {
String value = new String();
try {
URL url = new URL(address + "/rest/api/processes/signal?signal=" + signal + "&executionID=" + executionID + "&param1=resolution&value1=signal_is_" + signal);
while (!formJson.isClosed()) {
if (JsonToken.FIELD_NAME.equals(formJson.nextToken())) {
if ("id".equals(formJson.getCurrentName()) && fieldName.equals(formJson.nextTextValue())) {
formJson.nextToken();
formJson.nextToken();
formJson.nextToken();
LOGGER.info(fieldName + ": " + formJson.nextTextValue());
value = formJson.nextTextValue();
break;
}
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
}
}
} catch (Exception exc) {
LOGGER.error(exc.getMessage(), exc);
}
return value;
}
private static JsonParser synergyApiGet(final URL requestURL) {
String login = "Ипатьев";
String password = "1";
try {
String output;
HttpURLConnection conn = (HttpURLConnection) requestURL.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/json; charset=utf-8");
String encoded = Base64.encode((login + ":" + password).getBytes());
conn.setRequestProperty("Authorization", "Basic " + encoded);
String output;
StringBuffer result = new StringBuffer();
BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
StringBuilder result = new StringBuilder();
while ((output = br.readLine()) != null) {
result.append(output);
}
conn.disconnect();
factory = new JsonFactory();
parser = factory.createParser(result.toString());
token = null;
while ((token = parser.nextToken()) != null) {
if (token == JsonToken.FIELD_NAME) {
String fieldName = parser.getText();
token = parser.nextToken();
if (fieldName.equals("errorCode") && parser.getText().equals("0")) {
isSuccess = true;
}
}
}
JsonFactory factory = new JsonFactory();
return factory.createParser(result.toString());
} catch (Exception exc) {
LOGGER.error(exc.getMessage(), exc);
}
} catch (Exception exc) {
LOGGER.error(exc.getMessage(), exc);
}
return null;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment