Subversion Repositories XServices

Compare Revisions

Ignore whitespace Rev 196 → Rev 170

/SVN-ALFEventEmitter/trunk/src/net/brutex/emitter/ALFEmitter.java
15,19 → 15,53
*/
package net.brutex.emitter;
 
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringWriter;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.xml.stream.XMLStreamException;
 
import net.brutex.emitter.util.EmitterUtil;
import net.brutex.emitter.util.PasswordEncrypter;
import net.brutex.sbm.sbmappservices72.AEWebservicesFaultFault;
import net.brutex.sbm.sbmappservices72.Sbmappservices72PortType;
import net.brutex.sbm.sbmappservices72.api.*;
import net.brutex.sbm.sbmappservices72.api.Auth;
import net.brutex.sbm.sbmappservices72.api.MultipleResponseItemOptions;
import net.brutex.sbm.sbmappservices72.api.ObjectFactory;
import net.brutex.sbm.sbmappservices72.api.SectionsOption;
import net.brutex.sbm.sbmappservices72.api.TTItemList;
import net.brutex.sbm.sbmappservices72.api.TableIdentifier;
import net.brutex.svn.SVNAdminCommand;
import net.brutex.svn.SVNAdminExecutor;
import net.brutex.svn.SVNCommitInfo;
import net.brutex.svn.SVNLookExecutor;
import org.apache.axiom.om.*;
 
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMComment;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMNode;
import org.apache.axiom.om.OMText;
import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.xpath.AXIOMXPath;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.*;
import org.apache.commons.cli.BasicParser;
import org.apache.commons.cli.ParseException;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
40,17 → 74,7
import org.apache.log4j.Logger;
import org.jaxen.JaxenException;
 
import javax.xml.stream.XMLStreamException;
import java.io.*;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
 
/**
* The Class ALFEmitter.
*
58,10 → 82,10
* @since 0.1
*/
public class ALFEmitter {
 
public static final String VERSION = "0.2";
public static final String VERSION = "0.1";
private static Logger logger = Logger.getRootLogger();
 
//
// Keys to read from the configuration file.
//
661,46 → 685,37
logger.debug("Total execution took '"+(endTime-startTime)+"' milliseconds.");
System.exit(errorCode);
}
 
 
@SuppressWarnings("static-access")
private static Options getOptions() {
Option repository = Option.builder(PARAM_REPOS)
.argName("repository")
Option repository = OptionBuilder.withArgName( "repository" )
.hasArg()
.withLongOpt("repository")
.withDescription( "Path or URL to the SVN repository." )
.create( PARAM_REPOS );
repository.setRequired(true);
Option txn = OptionBuilder.withArgName( "transactionid" )
.hasArg()
.withLongOpt("transaction")
.withDescription( "The SVN transaction id to examine (TXN). You cannot combine txn with -rev. "
+ "When a txn is given, the repository path must be a local path.")
.create( PARAM_TXN );
Option rev = OptionBuilder.withArgName( "revision" )
.hasArg()
.longOpt("repository")
.desc("Path or Url to the SVN repository")
.required()
.build();
 
Option txn = Option.builder(PARAM_TXN)
.argName("transactionid")
.withDescription( "A revision to examine. You cannot combine revision with -txn." )
.create( PARAM_REV );
Option config = OptionBuilder.withArgName( "config_file" )
.hasArg()
.longOpt("transaction")
.desc("The SVN transaction id to examine (TXN). You cannot combine txn with -rev. "
+ "When a txn is given, the repository path must be a local path.")
.build();
 
Option rev = Option.builder(PARAM_REV)
.argName("revision")
.hasArg()
.desc("A revision to examine. You cannot combine revision with -txn.")
.build();
 
OptionGroup group = new OptionGroup()
.addOption(txn)
.addOption(rev);
 
Option config = Option.builder(PARAM_CONFIG)
.argName("config_file")
.hasArg()
.longOpt("config")
.desc("The configuration file to use. Defaults to 'emitter.properties'.")
.build();
 
.withLongOpt("config")
.withDescription( "The configuration file to use. Defaults to 'emitter.properties'.")
.create( PARAM_CONFIG );
Options options = new Options();
options.addOption(repository);
options.addOption(txn);
options.addOption(rev);
options.addOption(config);
options.addOptionGroup(group);
return options;
}
707,10 → 722,8
private static void printHelp() {
// automatically generate the help statement
HelpFormatter formatter = new HelpFormatter();
String header = "\nSVN-ALFEventEmitter " + VERSION + ", a SVN hook implemented in Java to emit Eclipse ALFEvents on commit.\n\n";
 
String footer = "Please send bug reports to bru@brutex.de.\n(c)2020 Brian Rosenberger";
formatter.setWidth(80);
String header = "\nSVN-ALFEventEmitter " + VERSION +", a SVN hook implemented in Java to emit Eclipse ALFEvents on commit.\n\n";
String footer = "Please send bug reports to bru@brutex.de.\n(c)2014 Brian Rosenberger";
formatter.printHelp("java -jar SVN-ALFEventEmitter", header, getOptions(), footer, true);
}
/SVN-ALFEventEmitter/trunk/src/net/brutex/emitter/SimpleHttpEvent.java
15,6 → 15,10
*/
package net.brutex.emitter;
 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
22,12 → 26,9
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
/**
* Construct a HTTP POST and send it.
*
51,30 → 52,30
this.url = url;
this.soapBody = soapBody;
}
 
/**
* Send soap.
*
* @param isDropResponse show interest in response or not
* @param url the url
* @param soapBody the soap body
* @throws ClientProtocolException the client protocol exception
* @throws IOException Signals that an I/O exception has occurred.
* @throws IOException Signals that an I/O exception has occurred.
*/
public void sendSoap(boolean isDropResponse) throws ClientProtocolException, IOException {
long start = System.currentTimeMillis();
HttpPost post = new HttpPost(url);
post.addHeader("Accept", "text/xml");
post.addHeader("Content-Type", "text/xml; charset=utf-8");
post.addHeader("SOAPAction", "");
EntityBuilder entitybuilder = EntityBuilder.create();
entitybuilder.setContentEncoding("UTF-8");
entitybuilder.setText(soapBody);
HttpEntity entity = entitybuilder.build();
post.setEntity(entity);
 
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpResponse r = httpclient.execute(post);
logger.debug("Sending event to ALF event manager");
if (!isDropResponse) {
post.addHeader("Accept" , "text/xml");
post.addHeader("SOAPAction","");
EntityBuilder entitybuilder = EntityBuilder.create();
entitybuilder.setContentEncoding("UTF-8");
entitybuilder.setText(soapBody);
HttpEntity entity = entitybuilder.build();
post.setEntity(entity);
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpResponse r = httpclient.execute(post);
logger.debug("Sending event to ALF event manager");
if(! isDropResponse) {
HttpEntity e = r.getEntity();
StringBuilder sb = new StringBuilder();
BufferedReader in = new BufferedReader(new InputStreamReader(e.getContent()));