Skip to content

Commit

Permalink
catalog and schema issues fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Sep 26, 2017
1 parent d837269 commit a40bea4
Show file tree
Hide file tree
Showing 5 changed files with 582 additions and 327 deletions.
17 changes: 17 additions & 0 deletions build-system/pom.xml
Expand Up @@ -89,6 +89,8 @@
<jackson.version>2.8.9</jackson.version>
<snakeyaml.version>1.15</snakeyaml.version>
<surefire.version>2.20</surefire.version>
<reflections.version>0.9.11</reflections.version>
<guava.version>20.0</guava.version>
</properties>
<dependencyManagement>
<dependencies>
Expand All @@ -101,6 +103,12 @@
<scope>import</scope>
</dependency>

<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>${reflections.version}</version>
</dependency>

<!-- WICKET -->
<dependency>
<groupId>org.apache.wicket</groupId>
Expand Down Expand Up @@ -614,8 +622,17 @@
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<groupId>org.apache.wss4j</groupId>
<artifactId>wss4j-ws-security-dom</artifactId>
Expand Down
Expand Up @@ -17,10 +17,10 @@
package com.evolveum.midpoint.web.boot;

import com.evolveum.midpoint.gui.impl.util.ReportPeerQueryInterceptor;
import com.evolveum.midpoint.prism.schema.CatalogImpl;
import com.evolveum.midpoint.web.util.MidPointProfilingServletFilter;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.apache.wicket.protocol.http.WicketFilter;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
Expand All @@ -37,11 +37,9 @@
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpStatus;
import org.springframework.web.context.request.RequestContextListener;
import org.springframework.web.filter.DelegatingFilterProxy;
import ro.isdc.wro.http.ConfigurableWroFilter;
import ro.isdc.wro.http.WroFilter;

import javax.servlet.DispatcherType;
Expand Down Expand Up @@ -86,6 +84,8 @@
public class MidPointSpringApplication extends SpringBootServletInitializer {

public static void main(String[] args) {
System.setProperty("xml.catalog.className", CatalogImpl.class.getName());

SpringApplication.run(MidPointSpringApplication.class, args);
}

Expand Down
@@ -0,0 +1,77 @@
/*
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.evolveum.midpoint.prism.schema;

import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import org.apache.commons.lang.StringUtils;
import org.apache.xml.resolver.Catalog;

import java.net.URI;

/**
* Created by Viliam Repan (lazyman).
*/
public class CatalogImpl extends Catalog {

private static final Trace LOGGER = TraceManager.getTrace(CatalogImpl.class);

/**
* This fixes catalog items. When launched as spring boot fat jar, catalog by default resolve URIs like
* <p>
* jar:file:/SOME_ABSOLUTE_PATH/midpoint.war!/WEB-INF/lib/schema-3.7-SNAPSHOT.jar!/META-INF/../xml/ns/public/common/common-core-3.xsd
* <p>
* which looks at first sight, but correct working version is:
* <p>
* jar:file:/SOME_ABSOLUTE_PATH/midpoint.war!/WEB-INF/lib/schema-3.7-SNAPSHOT.jar!/xml/ns/public/common/common-core-3.xsd
* <p>
* This catalog impl is enabled only when in spring boot fat jar is launched through main() using:
* <p>
* System.setProperty("xml.catalog.className", CatalogImpl.class.getName());
*/
@Override
protected String makeAbsolute(String sysid) {
String absolute = super.makeAbsolute(sysid);

if (absolute == null) {
return null;
}

String[] array = absolute.split("!/");
if (array.length <= 1) {
return absolute;
}

String[] normalized = new String[array.length];
for (int i = 0; i < array.length; i++) {
String part = array[i];

URI uri = java.net.URI.create(part);
uri = uri.normalize();

normalized[i] = uri.toString();
}

String newAbsolute = StringUtils.join(normalized, "!/");

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Normalized absolute path from '{}' to '{}'", absolute, newAbsolute);
}

return newAbsolute;
}
}
8 changes: 8 additions & 0 deletions infra/util/pom.xml
Expand Up @@ -32,6 +32,14 @@
<url>https://fisheye.evolveum.com/browse/midPoint</url>
</scm>
<dependencies>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
Expand Down

0 comments on commit a40bea4

Please sign in to comment.