use of nl.nn.adapterframework.soap.Wsdl in project iaf by ibissource.
the class Webservices method getLogDirectory.
@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/webservices")
@Relation("webservices")
@Produces(MediaType.APPLICATION_JSON)
public Response getLogDirectory() throws ApiException {
initBase(servletConfig);
Map<String, Object> returnMap = new HashMap<String, Object>();
List<Map<String, Object>> webServices = new ArrayList<Map<String, Object>>();
for (IAdapter a : ibisManager.getRegisteredAdapters()) {
Adapter adapter = (Adapter) a;
Iterator<IReceiver> recIt = adapter.getReceiverIterator();
while (recIt.hasNext()) {
IReceiver receiver = recIt.next();
if (receiver instanceof ReceiverBase) {
ReceiverBase rb = (ReceiverBase) receiver;
IListener listener = rb.getListener();
if (listener instanceof RestListener) {
RestListener rl = (RestListener) listener;
if (rl.isView()) {
Map<String, Object> service = new HashMap<String, Object>(2);
service.put("name", rb.getName());
service.put("uriPattern", rl.getUriPattern());
webServices.add(service);
}
}
}
}
}
returnMap.put("services", webServices);
List<Map<String, Object>> wsdls = new ArrayList<Map<String, Object>>();
for (IAdapter a : ibisManager.getRegisteredAdapters()) {
Map<String, Object> wsdlMap = new HashMap<String, Object>(2);
try {
Adapter adapter = (Adapter) a;
Wsdl wsdl = new Wsdl(adapter.getPipeLine());
wsdlMap.put("name", wsdl.getName());
wsdlMap.put("extention", getWsdlExtention());
} catch (Exception e) {
wsdlMap.put("name", a.getName());
if (e.getMessage() != null) {
wsdlMap.put("error", e.getMessage());
} else {
wsdlMap.put("error", e.toString());
}
}
wsdls.add(wsdlMap);
}
returnMap.put("wsdls", wsdls);
return Response.status(Response.Status.OK).entity(returnMap).build();
}
use of nl.nn.adapterframework.soap.Wsdl in project iaf by ibissource.
the class WsdlGeneratorPipe method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
String result = null;
IAdapter adapter;
if ("input".equals(getFrom())) {
adapter = ((Adapter) getAdapter()).getConfiguration().getIbisManager().getRegisteredAdapter((String) input);
if (adapter == null) {
throw new PipeRunException(this, "Could not find adapter: " + input);
}
} else {
adapter = getPipeLine().getAdapter();
}
try {
Wsdl wsdl = new Wsdl(((Adapter) adapter).getPipeLine());
wsdl.setDocumentation("Generated at " + AppConstants.getInstance().getResolvedProperty("otap.stage") + "-" + AppConstants.getInstance().getResolvedProperty("otap.side") + " on " + DateUtils.getIsoTimeStamp() + ".");
wsdl.init();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
wsdl.wsdl(outputStream, null);
result = outputStream.toString("UTF-8");
} catch (Exception e) {
throw new PipeRunException(this, "Could not generate WSDL for adapter '" + adapter.getName() + "'", e);
}
return new PipeRunResult(getForward(), result);
}
use of nl.nn.adapterframework.soap.Wsdl in project iaf by ibissource.
the class WsdlGeneratorPipe method doPipe.
@Override
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
InputStream inputStream = (InputStream) session.get("file");
if (inputStream == null) {
throw new PipeRunException(this, getLogPrefix(session) + "got null value from session under key [" + getSessionKey() + "]");
}
File tempDir;
String fileName;
try {
tempDir = FileUtils.createTempDir(null, "WEB-INF" + File.separator + "classes");
fileName = (String) session.get("fileName");
if (FileUtils.extensionEqualsIgnoreCase(fileName, "zip")) {
FileUtils.unzipStream(inputStream, tempDir);
} else {
File file = new File(tempDir, fileName);
Misc.streamToFile(inputStream, file);
file.deleteOnExit();
}
} catch (IOException e) {
throw new PipeRunException(this, getLogPrefix(session) + " Exception on uploading and unzipping/writing file", e);
}
File propertiesFile = new File(tempDir, getPropertiesFileName());
PipeLine pipeLine;
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
DirectoryClassLoader directoryClassLoader = new DirectoryClassLoader(tempDir.getPath());
Thread.currentThread().setContextClassLoader(directoryClassLoader);
if (propertiesFile.exists()) {
pipeLine = createPipeLineFromPropertiesFile(propertiesFile);
} else {
File xsdFile = FileUtils.getFirstFile(tempDir);
pipeLine = createPipeLineFromXsdFile(xsdFile);
}
} catch (Exception e) {
throw new PipeRunException(this, getLogPrefix(session) + " Exception on generating wsdl", e);
} finally {
if (originalClassLoader != null) {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
}
Object result = null;
OutputStream zipOut = null;
OutputStream fullWsdlOut = null;
try {
Adapter adapter = new Adapter();
adapter.setConfiguration(new Configuration(null));
String fileBaseName = FileUtils.getBaseName(fileName).replaceAll(" ", "_");
adapter.setName(fileBaseName);
GenericReceiver genericReceiver = new GenericReceiver();
EsbJmsListener esbJmsListener = new EsbJmsListener();
esbJmsListener.setQueueConnectionFactoryName("jms/qcf_" + fileBaseName);
esbJmsListener.setDestinationName("jms/dest_" + fileBaseName);
genericReceiver.setListener(esbJmsListener);
adapter.registerReceiver(genericReceiver);
pipeLine.setAdapter(adapter);
Wsdl wsdl = null;
wsdl = new Wsdl(pipeLine);
wsdl.setIndent(true);
wsdl.setDocumentation(getWsdlDocumentation(wsdl.getFilename()));
wsdl.init();
File wsdlDir = FileUtils.createTempDir(tempDir);
// zip (with includes)
File zipOutFile = new File(wsdlDir, wsdl.getFilename() + ".zip");
zipOutFile.deleteOnExit();
zipOut = new FileOutputStream(zipOutFile);
wsdl.setUseIncludes(true);
wsdl.zip(zipOut, null);
// full wsdl (without includes)
File fullWsdlOutFile = new File(wsdlDir, wsdl.getFilename() + ".wsdl");
fullWsdlOutFile.deleteOnExit();
fullWsdlOut = new FileOutputStream(fullWsdlOutFile);
wsdl.setUseIncludes(false);
wsdl.wsdl(fullWsdlOut, null);
Dir2Xml dx = new Dir2Xml();
dx.setPath(wsdlDir.getPath());
result = dx.getDirList();
} catch (Exception e) {
throw new PipeRunException(this, getLogPrefix(session) + " Exception on generating wsdl", e);
} finally {
try {
if (zipOut != null) {
zipOut.close();
}
if (fullWsdlOut != null) {
fullWsdlOut.close();
}
} catch (IOException e1) {
log.warn("exception closing outputstream", e1);
}
}
return new PipeRunResult(getForward(), result);
}
use of nl.nn.adapterframework.soap.Wsdl in project iaf by ibissource.
the class Webservices method zip.
private void zip(Adapter adapter, IPipeLineSession session) throws ConfigurationException, XMLStreamException, IOException, NamingException {
Wsdl wsdl = new Wsdl(adapter.getPipeLine());
wsdl.setUseIncludes(true);
wsdl.setDocumentation(getDocumentation(wsdl, session));
wsdl.init();
wsdl.zip(RestListenerUtils.retrieveServletOutputStream(session), RestListenerUtils.retrieveSOAPRequestURL(session));
}
use of nl.nn.adapterframework.soap.Wsdl in project iaf by ibissource.
the class Webservices method wsdl.
private void wsdl(Adapter adapter, IPipeLineSession session, String indent, String useIncludes) throws ConfigurationException, XMLStreamException, IOException, NamingException {
Wsdl wsdl = new Wsdl(adapter.getPipeLine());
if (indent != null) {
wsdl.setIndent(StringUtils.equalsIgnoreCase(indent, "true"));
}
if (useIncludes != null) {
wsdl.setUseIncludes(StringUtils.equalsIgnoreCase(useIncludes, "true"));
}
wsdl.setDocumentation(getDocumentation(wsdl, session));
wsdl.init();
wsdl.wsdl(RestListenerUtils.retrieveServletOutputStream(session), RestListenerUtils.retrieveSOAPRequestURL(session));
}
Aggregations