From c2500edb3421f24484f4aaa2495ac72386786aa6 Mon Sep 17 00:00:00 2001 From: Igor Farinic Date: Sun, 22 Jun 2014 19:24:34 +0200 Subject: [PATCH] updated build configuration and small code fixes to make midPoint run in weblogic server --- gui/admin-gui/pom.xml | 65 +++++++++++- .../midpoint/init/InitialDataImport.java | 100 +++++++++++++++++- .../src/main/webapp/WEB-INF/wro.properties | 6 +- gui/admin-gui/src/main/webapp/WEB-INF/wro.xml | 13 ++- infra/util/pom.xml | 5 + .../evolveum/midpoint/util/ClassPathUtil.java | 35 ++++-- weblogic-build/pom.xml | 70 ++++++++++++ .../app/META-INF/weblogic-application.xml | 75 +++++++++++++ 8 files changed, 347 insertions(+), 22 deletions(-) create mode 100644 weblogic-build/pom.xml create mode 100644 weblogic-build/src/main/app/META-INF/weblogic-application.xml diff --git a/gui/admin-gui/pom.xml b/gui/admin-gui/pom.xml index 95a67be1b11..01185575bbc 100644 --- a/gui/admin-gui/pom.xml +++ b/gui/admin-gui/pom.xml @@ -114,8 +114,17 @@ slf4j-api org.slf4j + + org.webjars + webjars-locator + + + org.webjars + webjars-locator + 0.15 + ro.isdc.wro4j wro4j-extensions @@ -180,6 +189,16 @@ com.evolveum.midpoint.repo repo-api 3.1-SNAPSHOT + + + jaxb-impl + com.sun.xml.bind + + + jaxb-core + com.sun.xml.bind + + com.evolveum.midpoint.model @@ -218,6 +237,20 @@ repo-cache 3.1-SNAPSHOT runtime + + + jaxb-impl + com.sun.xml.bind + + + jaxb-api + javax.xml.bind + + + jaxb-core + com.sun.xml.bind + + com.evolveum.midpoint.repo @@ -242,6 +275,12 @@ model-impl 3.1-SNAPSHOT runtime + + + jaxb-impl + com.sun.xml.bind + + com.evolveum.midpoint.model @@ -267,12 +306,24 @@ 3.1-SNAPSHOT runtime - + com.evolveum.midpoint.model report-impl 3.1-SNAPSHOT runtime + + com.evolveum.midpoint.infra + common + 3.1-SNAPSHOT + + + xml-apis + xml-apis + + + + org.springframework @@ -362,6 +413,12 @@ --> + + javax.jws + jsr181-api + 1.0-MR1 + + com.evolveum.midpoint.repo @@ -446,6 +503,12 @@ net.sf.jasperreports jasperreports 4.7.0-e1 + + + xml-apis + xml-apis + + org.hibernate diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/init/InitialDataImport.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/init/InitialDataImport.java index eddfcca8716..3bd898ec044 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/init/InitialDataImport.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/init/InitialDataImport.java @@ -41,6 +41,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; +import com.evolveum.midpoint.common.configuration.api.MidpointConfiguration; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.Validate; @@ -52,11 +53,27 @@ import java.io.File; import java.io.FileFilter; +import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.StandardCopyOption; +import java.nio.file.attribute.BasicFileAttributes; +import java.security.CodeSource; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; /** * @author lazyman @@ -73,7 +90,9 @@ public class InitialDataImport { private transient PrismContext prismContext; private ModelService model; private TaskManager taskManager; - + @Autowired + private MidpointConfiguration configuration; + public void setModel(ModelService model) { Validate.notNull(model, "Model service must not be null."); this.model = model; @@ -193,7 +212,12 @@ private Boolean importObject(PrismObject object, File file, Task task, Operation private File getResource(String name) { URI path; try { + LOGGER.trace("getResource: name = {}", name); path = InitialDataImport.class.getClassLoader().getResource(name).toURI(); + LOGGER.trace("getResource: path = {}", path); + //String updatedPath = path.toString().replace("zip:/", "jar:/"); + //LOGGER.trace("getResource: path updated = {}", updatedPath); + //path = new URI(updatedPath); } catch (URISyntaxException e) { throw new IllegalArgumentException("parameter name = " + name, e); } @@ -201,8 +225,76 @@ private File getResource(String name) { } private File[] getInitialImportObjects() { - File folder = getResource("initial-objects"); - File[] files = folder.listFiles(new FileFilter() { + URL path = InitialDataImport.class.getClassLoader().getResource("initial-objects"); + String resourceType = path.getProtocol(); + + File[] files = null; + File folder = null; + + if ("zip".equals(resourceType) || "jar".equals(resourceType)) { + try { + File tmpDir = new File(configuration.getMidpointHome()+"/tmp"); + if (!tmpDir.mkdir()) { + LOGGER.error("Failed to create temporary directory for inital objects {}", configuration.getMidpointHome()+"/tmp"); + throw new RuntimeException("Failed to create temporary directory for inital objects " + configuration.getMidpointHome()+"/tmp"); + } + + tmpDir = new File(configuration.getMidpointHome()+"/tmp/initial-objects"); + if (!tmpDir.mkdir()) { + LOGGER.error("Failed to create temporary directory for inital objects {}", configuration.getMidpointHome()+"/tmp/initial-objects"); + throw new RuntimeException("Failed to create temporary directory for inital objects " + configuration.getMidpointHome()+"/tmp/initial-objects"); + } + + //prerequisite: we are expecting that the files are store in the same archive as the source code that is loading it + URI src = InitialDataImport.class.getProtectionDomain().getCodeSource().getLocation().toURI(); + LOGGER.trace("InitialDataImport code location: {}", src); + Map env = new HashMap<>(); + env.put("create", "false"); + URI normalizedSrc = new URI(src.toString().replaceFirst("file:", "jar:file:")); + LOGGER.trace("InitialDataImport normalized code location: {}", normalizedSrc); + try (FileSystem zipfs = FileSystems.newFileSystem(normalizedSrc, env)) { + Path pathInZipfile = zipfs.getPath("/initial-objects"); + //TODO: use some well defined directory, e.g. midPoint home + final Path destDir = Paths.get(configuration.getMidpointHome()+"/tmp"); + Files.walkFileTree(pathInZipfile, new SimpleFileVisitor(){ + @Override + public FileVisitResult visitFile(Path file, + BasicFileAttributes attrs) throws IOException { + final Path destFile = Paths.get(destDir.toString(), + file.toString()); + LOGGER.trace("Extracting file {} to {}", file, destFile); + Files.copy(file, destFile, StandardCopyOption.REPLACE_EXISTING); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult preVisitDirectory(Path dir, + BasicFileAttributes attrs) throws IOException { + final Path dirToCreate = Paths.get(destDir.toString(), + dir.toString()); + if(Files.notExists(dirToCreate)){ + LOGGER.trace("Creating directory {}", dirToCreate); + Files.createDirectory(dirToCreate); + } + return FileVisitResult.CONTINUE; + } + }); + + + } + folder = new File(configuration.getMidpointHome()+"/tmp/initial-objects"); + } catch (IOException ex) { + throw new RuntimeException("Failed to copy initial objects file out of the archive to the temporary directory", ex); + } catch (URISyntaxException ex) { + throw new RuntimeException("Failed get URI for the source code bundled with initial objects", ex); + } + } + + if ("file".equals(resourceType)) { + folder = getResource("initial-objects"); + } + + files = folder.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { @@ -223,7 +315,7 @@ public int compare(File o1, File o2) { return n1 - n2; } }); - + return files; } diff --git a/gui/admin-gui/src/main/webapp/WEB-INF/wro.properties b/gui/admin-gui/src/main/webapp/WEB-INF/wro.properties index 9875ec84cdf..127ef5dda21 100644 --- a/gui/admin-gui/src/main/webapp/WEB-INF/wro.properties +++ b/gui/admin-gui/src/main/webapp/WEB-INF/wro.properties @@ -16,8 +16,10 @@ managerFactoryClassName=ro.isdc.wro.manager.factory.ConfigurableWroManagerFactory preProcessors=cssUrlRewriting,cssImport,semicolonAppender -postProcessors=lessCss +postProcessors=less4j # disabling cache for developing purposes only, more configuration options # http://code.google.com/p/wro4j/wiki/ConfigurationOptions -disableCache=false \ No newline at end of file +disableCache=false + +uriLocators=servletContext,uri,classpath,webjar diff --git a/gui/admin-gui/src/main/webapp/WEB-INF/wro.xml b/gui/admin-gui/src/main/webapp/WEB-INF/wro.xml index f34b862de7c..38b7ec2b83d 100644 --- a/gui/admin-gui/src/main/webapp/WEB-INF/wro.xml +++ b/gui/admin-gui/src/main/webapp/WEB-INF/wro.xml @@ -18,8 +18,11 @@ - /less/*.less - /WEB-INF/classes/**.less + /less/config.less + /less/evolveum-obsolete.less + /less/global.less + /WEB-INF/classes/com/evolveum/midpoint/web/component/assignment/AssignmentHeaderPanel.less + /WEB-INF/classes/com/evolveum/midpoint/web/page/admin/home/PageMyPasswords.less @@ -45,6 +48,8 @@ /less/midpoint/midpoint.less - /js/midpoint/**.js + /js/midpoint/ace-editor.js + /js/midpoint/dropdown-multiple.js + /js/midpoint/midpoint.js - \ No newline at end of file + diff --git a/infra/util/pom.xml b/infra/util/pom.xml index fb54fa60269..7f61592db90 100644 --- a/infra/util/pom.xml +++ b/infra/util/pom.xml @@ -101,5 +101,10 @@ 3.1-SNAPSHOT test + + org.eclipse.jetty + jetty-jndi + 8.1.14.v20131031 + diff --git a/infra/util/src/main/java/com/evolveum/midpoint/util/ClassPathUtil.java b/infra/util/src/main/java/com/evolveum/midpoint/util/ClassPathUtil.java index dcaac342a50..e842d52c626 100644 --- a/infra/util/src/main/java/com/evolveum/midpoint/util/ClassPathUtil.java +++ b/infra/util/src/main/java/com/evolveum/midpoint/util/ClassPathUtil.java @@ -35,6 +35,8 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; +import org.eclipse.jetty.jndi.local.localContextRoot; + import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; @@ -64,17 +66,18 @@ public static Set listClasses(String packageName) { while (resources.hasMoreElements()) { URL candidateUrl = resources.nextElement(); - LOGGER.trace("Candidates from: " + candidateUrl.getPath()); + LOGGER.trace("Candidates from: " + candidateUrl); // test if it is a directory or JAR - if ("file".contentEquals(candidateUrl.getProtocol())) { - classes.addAll(getFromDirectory(candidateUrl, packageName)); - - } else if ("jar".contentEquals(candidateUrl.getProtocol())) { - classes.addAll(getFromJar(candidateUrl, packageName)); - - } - } + String protocol = candidateUrl.getProtocol(); + if ("file".contentEquals(protocol)) { + classes.addAll(getFromDirectory(candidateUrl, packageName)); + } else if ("jar".contentEquals(protocol) || "zip".contentEquals(protocol)) { + classes.addAll(getFromJar(candidateUrl, packageName)); + } else { + LOGGER.warn("Unsupported protocol for candidate URL {}", candidateUrl); + } + } return classes; } @@ -148,10 +151,20 @@ private static Collection getFromJar(URL srcUrl, String package // sample: // file:/C:/.m2/repository/test-util/1.9-SNAPSHOT/test-util-1.9-SNAPSHOT.jar!/test-data/opendj.template // output: - // /C:/.m2/repository/test-util/1.9-SNAPSHOT/test-util-1.9-SNAPSHOT.jar + // file/C:/.m2/repository/test-util/1.9-SNAPSHOT/test-util-1.9-SNAPSHOT.jar String srcName = srcUrl.getPath().split("!/")[0]; - // Probaly hepls fix error in windows with URI + //solution to make it work in Weblogic, because we have to make the path absolute, that means with scheme, that means basically with prefix file:/ + //in Tomcat the form is jar:file:/ + //in Weblogic the form is only zip:/ + LOGGER.trace("srcUrl.getProtocol(): {}", srcUrl.getProtocol()); + + if ("zip".equals(srcUrl.getProtocol())) { + srcName = "file:" + srcName; + } + LOGGER.trace("srcName: {}", srcName); + + // Probably hepls fix error in windows with URI File jarTmp = null; try { jarTmp = new File(new URI(srcName)); diff --git a/weblogic-build/pom.xml b/weblogic-build/pom.xml new file mode 100644 index 00000000000..8e91159c4f7 --- /dev/null +++ b/weblogic-build/pom.xml @@ -0,0 +1,70 @@ + + + + 4.0.0 + midPoint distribution package for WebLogic Server + com.evolveum.midpoint.dist + midPoint-weblogic + ear + 3.1-SNAPSHOT + midPoint distribution for WebLogic Server + + https://github.com/Evolveum/midpoint.git + git@github.com:Evolveum/midpoint.git + https://fisheye.evolveum.com/browse/midPoint + + + midpoint + + + + + + com.evolveum.midpoint.gui + admin-gui + 3.1-SNAPSHOT + war + + + + + weblogic + + false + + + + + maven-ear-plugin + + midPoint + src/main/app + + + com.evolveum.midpoint.gui + admin-gui + midpoint.war + /midpoint + + + + + + + + + diff --git a/weblogic-build/src/main/app/META-INF/weblogic-application.xml b/weblogic-build/src/main/app/META-INF/weblogic-application.xml new file mode 100644 index 00000000000..1d5ede3dc11 --- /dev/null +++ b/weblogic-build/src/main/app/META-INF/weblogic-application.xml @@ -0,0 +1,75 @@ + + + + + com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl + net.sf.saxon.dom.DocumentBuilderFactoryImpl + net.sf.saxon.TransformerFactoryImpl + + + + webapp.encoding.default + UTF-8 + + + + org.slf4j.* + ch.qos.logback.* + org.apache.commons.logging.* + + + + org.apache.commons.* + + antlr.* + org.springframework.* + + javax.servlet.jsp.jstl.* + + javax.jws.* + javax.ws.* + + + javax.xml.stream.* + + + org.apache.xmlcommons.* + org.apache.xml.serializer.* + net.sf.saxon.* + org.apache.xalan.* + com.ctc.wstx.* + org.codehaus.* + + org.mozilla.* + org.joda.* + + + META-INF/services/javax.ws.rs.ext.RuntimeDelegate + META-INF/services/javax.xml.bind.JAXBContext + META-INF/services/javax.xml.datatype.DatatypeFactory + META-INF/services/javax.xml.parsers.DocumentBuilderFactory + META-INF/services/javax.xml.parsers.SAXParserFactory + META-INF/services/javax.xml.stream.XMLEventFactory + META-INF/services/javax.xml.stream.XMLInputFactory + META-INF/services/javax.xml.stream.XMLOutputFactory + META-INF/services/javax.xml.transform.TransformerFactory + META-INF/services/javax.xml.validation.SchemaFactory + META-INF/services/javax.xml.ws.spi.Provider + META-INF/services/javax.xml.xpath.XPathFactory + META-INF/services/org.apache.cxf.bus.factory + META-INF/services/org.apache.xalan.extensions.bsf.BSFManager + META-INF/services/org.apache.xml.dtm.DTMManager + META-INF/services/org.codehaus.stax2.validation.XMLValidationSchemaFactory.dtd + META-INF/services/org.codehaus.stax2.validation.XMLValidationSchemaFactory.relaxng + META-INF/services/org.codehaus.stax2.validation.XMLValidationSchemaFactory.w3c + META-INF/services/org.osgi.framework.launch.FrameworkFactory + META-INF/services/org.relaxng.datatype.DatatypeLibraryFactory + META-INF/services/org.w3c.dom.DOMImplementationSourceList + META-INF/services/org.xml.sax.driver + + META-INF/services/com.sun.xml.ws.spi.db.BindingContextFactory + +