Subversion Repositories XServices

Compare Revisions

Regard whitespace Rev 203 → Rev 201

/xservices/trunk/src/main/java/net/brutex/xservices/ws/impl/MiscServiceImpl.java
41,7 → 41,6
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.namespace.QName;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
import java.io.StringReader;
70,7 → 69,6
 
@Resource
private WebServiceContext context;
 
public MiscServiceImpl() throws SchedulerException {
}
 
176,6 → 174,7
public BigInteger lock(String id, String objectId) throws XServicesFault {
 
 
 
final String conString = "jdbc:h2:mem:lockdb;DB_CLOSE_DELAY=10;" +
"INIT=CREATE SCHEMA IF NOT EXISTS brutex\\;" +
// "SET SCHEMA brutex\\;" +
228,8 → 227,6
final Instant d = Instant.now();
final long ts = d.toEpochMilli();
 
MessageContext cont = context.getMessageContext();
 
//Get Parameters from the Servlet Context
final ServletContext servletContext =
(ServletContext) context.getMessageContext().get(MessageContext.SERVLET_CONTEXT);
254,33 → 251,29
log.debug("Event id '{}', type '{}' received for object '{}' with object_id '{}'.",
eventId, eventType, objectType, objectId);
 
final String mergeStatememt = "SELECT btx_id FROM OLD TABLE (MERGE INTO brutex.tbl_events " +
final String mergeStatememt = "MERGE INTO brutex.tbl_events " +
"KEY (btx_event_type, btx_obj_type, btx_obj_id) " +
"VALUES (?,?,?,?,?,?));";
"VALUES (?,?,?,?,?,?);";
 
final String insertAll = "INSERT INTO brutex.tbl_events_all VALUES (?,?,?,?,?,?,?)";
 
 
try (Connection con = pool.getConnection()) {
try {
Marshaller m = JAXBContext.newInstance(ALFEventType.class).createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
JAXBElement<ALFEventType> e = of.createALFEventNoticeDoc(event);
JAXBElement<ALFEventType> e = of.createEventNotice(event);
StringWriter sw = new StringWriter();
m.marshal(e, sw);
StringBuilder sb = new StringBuilder();
 
sb.append(" <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
"xmlns:ns=\"http://www.eclipse.org/alf/schema/EventBase/1\">\n");
sb.append("<soapenv:Body>\n");
 
sb.append("<ns:EventNotice>\n");
sb.append(sw);
 
sb.append("</ns:EventNotice>\n");
sb.append("</soapenv:Body>");
sb.append("</soapenv:Envelope>");
 
 
Connection con = pool.getConnection();
PreparedStatement prep = con.prepareStatement(mergeStatememt);
prep.setString(1, eventType);
prep.setString(2, eventId);
288,35 → 281,12
prep.setString(4, objectId);
prep.setLong(5, ts);
prep.setClob(6, new StringReader(sb.toString()));
ResultSet r = prep.executeQuery();
con.commit();
String supersed_id = null;
if (r.next()) {
supersed_id = r.getString(1);
log.trace("Event '{}' superseded event '{}'", eventId, supersed_id);
} else {
log.trace("Event '{}' inserted into outgoing queue.", eventId);
}
 
 
/* Write all into permanent storage */
//Connection fcon = fpool.getConnection();
prep = con.prepareStatement(insertAll);
prep.setString(1, eventType);
prep.setString(2, eventId);
prep.setString(3, objectType);
prep.setString(4, objectId);
prep.setLong(5, ts);
prep.setString(6, supersed_id);
prep.setClob(7, new StringReader(sb.toString()));
prep.execute();
 
con.commit();
con.close();
 
ingres_counter.incrementAndGet();
 
if (conf.isEmitterActive()) {
synchronized (scheduler) {
if (!scheduler.checkExists(JobKey.jobKey("ALFEmitter"))) {
JobDetail job2 = JobBuilder.newJob(EventEmitter.class)
337,7 → 307,6
scheduler.scheduleJob(job2, t);
}
}
}
} catch (JAXBException | SQLException | SchedulerException e) {
log.error(e.getMessage());
throw new XServicesFault(e);
/xservices/trunk/src/main/java/net/brutex/xservices/ws/MiscService.java
74,7 → 74,6
public abstract BigInteger lock(@WebParam(name="id") @XmlElement(nillable = false) String id,
@WebParam(name="objectId") @XmlElement(nillable = false) String objectId) throws XServicesFault;
 
@WebMethod(operationName="", action = "EventNotice")
@SOAPBinding(use = SOAPBinding.Use.LITERAL, style = SOAPBinding.Style.DOCUMENT, parameterStyle = SOAPBinding.ParameterStyle.BARE)
public abstract ALFEventResponseType mergeALFEvent(@WebParam(name="ALFEventNoticeDoc", targetNamespace = "http://www.eclipse.org/alf/schema/EventBase/1") ALFEventType event) throws XServicesFault;
@WebMethod(operationName="EventNotice")
public abstract ALFEventResponseType mergeALFEvent(@WebParam(name="EventNotice", targetNamespace = "http://www.eclipse.org/alf/schema/EventBase/1") ALFEventType event) throws XServicesFault;
}