Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jun 23, 2014
2 parents a9a7d90 + 3859d6e commit 7991231
Show file tree
Hide file tree
Showing 8 changed files with 371 additions and 22 deletions.
91 changes: 90 additions & 1 deletion gui/admin-gui/pom.xml
Expand Up @@ -114,8 +114,17 @@
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator</artifactId>
<version>0.15</version>
</dependency>
<dependency>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-extensions</artifactId>
Expand Down Expand Up @@ -180,6 +189,16 @@
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>repo-api</artifactId>
<version>3.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<artifactId>jaxb-impl</artifactId>
<groupId>com.sun.xml.bind</groupId>
</exclusion>
<exclusion>
<artifactId>jaxb-core</artifactId>
<groupId>com.sun.xml.bind</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.model</groupId>
Expand Down Expand Up @@ -218,6 +237,20 @@
<artifactId>repo-cache</artifactId>
<version>3.1-SNAPSHOT</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<artifactId>jaxb-impl</artifactId>
<groupId>com.sun.xml.bind</groupId>
</exclusion>
<exclusion>
<artifactId>jaxb-api</artifactId>
<groupId>javax.xml.bind</groupId>
</exclusion>
<exclusion>
<artifactId>jaxb-core</artifactId>
<groupId>com.sun.xml.bind</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
Expand All @@ -242,6 +275,12 @@
<artifactId>model-impl</artifactId>
<version>3.1-SNAPSHOT</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<artifactId>jaxb-impl</artifactId>
<groupId>com.sun.xml.bind</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.model</groupId>
Expand All @@ -267,12 +306,24 @@
<version>3.1-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<dependency>
<groupId>com.evolveum.midpoint.model</groupId>
<artifactId>report-impl</artifactId>
<version>3.1-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.infra</groupId>
<artifactId>common</artifactId>
<version>3.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- SPRING -->
<dependency>
<groupId>org.springframework</groupId>
Expand Down Expand Up @@ -362,6 +413,12 @@
</dependency>
-->

<dependency>
<groupId>javax.jws</groupId>
<artifactId>jsr181-api</artifactId>
<version>1.0-MR1</version>
</dependency>

<!-- TEST -->
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
Expand Down Expand Up @@ -446,6 +503,12 @@
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>4.7.0-e1</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
Expand Down Expand Up @@ -490,5 +553,31 @@
</plugins>
</build>
</profile>

<profile>
<id>tomcat</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>

<dependencies>
<dependency>
<artifactId>jaxb-impl</artifactId>
<groupId>com.sun.xml.bind</groupId>
</dependency>
<dependency>
<artifactId>jaxb-api</artifactId>
<groupId>javax.xml.bind</groupId>
<version>${jaxb.version}</version>
</dependency>
<dependency>
<artifactId>jaxb-core</artifactId>
<groupId>com.sun.xml.bind</groupId>
<version>${jaxb.version}</version>
</dependency>
</dependencies>

</profile>

</profiles>
</project>
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -193,16 +212,87 @@ 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);
}
return new File(path);
}

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.warn("Failed to create temporary directory for inital objects {}. Maybe it already exists", configuration.getMidpointHome()+"/tmp");
}

tmpDir = new File(configuration.getMidpointHome()+"/tmp/initial-objects");
if (!tmpDir.mkdir()) {
LOGGER.warn("Failed to create temporary directory for inital objects {}. Maybe it already exists", 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<String, String> 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<Path>(){
@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) {
Expand All @@ -223,7 +313,7 @@ public int compare(File o1, File o2) {
return n1 - n2;
}
});

return files;
}

Expand Down
6 changes: 4 additions & 2 deletions gui/admin-gui/src/main/webapp/WEB-INF/wro.properties
Expand Up @@ -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
disableCache=false

uriLocators=servletContext,uri,classpath,webjar
13 changes: 9 additions & 4 deletions gui/admin-gui/src/main/webapp/WEB-INF/wro.xml
Expand Up @@ -18,8 +18,11 @@
<groups xmlns="http://www.isdc.ro/wro">
<!-- this group is obsolete, will be removed -->
<group name="all">
<css>/less/*.less</css>
<css>/WEB-INF/classes/**.less</css>
<css>/less/config.less</css>
<css>/less/evolveum-obsolete.less</css>
<css>/less/global.less</css>
<css>/WEB-INF/classes/com/evolveum/midpoint/web/component/assignment/AssignmentHeaderPanel.less</css>
<css>/WEB-INF/classes/com/evolveum/midpoint/web/page/admin/home/PageMyPasswords.less</css>
</group>

<group name="bootstrap">
Expand All @@ -45,6 +48,8 @@

<group name="midpoint">
<css>/less/midpoint/midpoint.less</css>
<js>/js/midpoint/**.js</js>
<js>/js/midpoint/ace-editor.js</js>
<js>/js/midpoint/dropdown-multiple.js</js>
<js>/js/midpoint/midpoint.js</js>
</group>
</groups>
</groups>
5 changes: 5 additions & 0 deletions infra/util/pom.xml
Expand Up @@ -101,5 +101,10 @@
<version>3.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jndi</artifactId>
<version>8.1.14.v20131031</version>
</dependency>
</dependencies>
</project>

0 comments on commit 7991231

Please sign in to comment.