Commit 4ef68e45 authored by Nacho's avatar Nacho
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+4 −0
Original line number Diff line number Diff line
.*
!.gitignore
!.gitlab-ci.yml
target

.gitlab-ci.yml

0 → 100644
+24 −0
Original line number Diff line number Diff line
stages:
  - build

maven-build:
  stage: build
  image: redmic/maven-gitlab
  variables:
    MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
  only:
    - branches
  cache:
    paths:
      - .m2/repository/
  script:
    - mvn deploy -B
    - "COVERAGE=$(xmllint --html --xpath '//table[@id=\"coveragetable\"]/tfoot//td[@class=\"ctr2\"][1]/text()' target/site/jacoco/index.html)"
    - 'echo "Coverage: $COVERAGE"'
  after_script:
    - rm -r .m2/repository/es
  artifacts:
    name: "$CI_PROJECT_NAME"
    expire_in: '6 months'
    paths:
      - target/*.jar

README.md

0 → 100644
+2 −0
Original line number Diff line number Diff line
[![pipeline status](https://git.redmic.net/redmic-server/utils/badges/dev/pipeline.svg)](https://git.redmic.net/redmic-server/utils/commits/dev) [![coverage report](https://git.redmic.net/redmic-server/utils/badges/dev/coverage.svg)](https://git.redmic.net/redmic-server/utils/commits/dev)
 No newline at end of file

pom.xml

0 → 100644
+119 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

	<parent>
		<groupId>es.redmic.lib</groupId>
		<artifactId>libs</artifactId>
		<version>0.6.0</version>
	</parent>

	<modelVersion>4.0.0</modelVersion>
	<artifactId>utils</artifactId>
	<packaging>jar</packaging>
	<name>Utils</name>

	<dependencies>

		<!-- Redmic -->

		<dependency>
			<groupId>es.redmic.lib</groupId>
			<artifactId>models</artifactId>
			<version>${redmic.version}</version>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>es.redmic.lib</groupId>
			<artifactId>exceptions</artifactId>
			<version>${redmic.version}</version>
			<scope>provided</scope>
		</dependency>
		
		<!--  Generate sitemap -->
		<dependency>
			<groupId>es.redmic.lib</groupId>
			<artifactId>sitemapgen4j</artifactId>
			<version>${redmic.version}</version>
			<scope>provided</scope>
		</dependency>

		<!-- Otros -->

		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>com.optimaize.languagedetector</groupId>
			<artifactId>language-detector</artifactId>
			<version>${language-detector.version}</version>
		</dependency>

		<!-- Super CSV -->
		<dependency>
			<groupId>net.sf.supercsv</groupId>
			<artifactId>super-csv</artifactId>
			<version>${super-csv.version}</version>
		</dependency>

		<!-- GeoTools -->
		<dependency>
			<groupId>org.geotools</groupId>
			<artifactId>gt-shapefile</artifactId>
			<version>${geotools.version}</version>
		</dependency>

		<dependency>
			<groupId>org.geotools</groupId>
			<artifactId>gt-geopkg</artifactId>
			<version>${geotools.version}</version>
			<exclusions>
				<exclusion>
					<groupId>commons-io</groupId>
					<artifactId>commons-io</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.geotools</groupId>
			<artifactId>gt-geojson</artifactId>
			<version>${geotools.version}</version>
		</dependency>

		<dependency>
			<groupId>org.geotools</groupId>
			<artifactId>gt-epsg-hsql</artifactId>
			<version>${geotools.version}</version>
		</dependency>

		<dependency>
			<groupId>com.google.code.gson</groupId>
			<artifactId>gson</artifactId>
		</dependency>

		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>${commons-io.version}</version>
			<scope>provided</scope>
		</dependency>
		
		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpclient</artifactId>
		</dependency>
		
		<dependency>
       		<groupId>org.springframework.boot</groupId>
        	<artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

	</dependencies>

</project>
 No newline at end of file
+64 −0
Original line number Diff line number Diff line
package es.redmic.utils.compressor;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import es.redmic.exception.utils.DecompressException;

public class Zip {

	public Zip() {
	}

	@SuppressWarnings("resource")
	public void extract(String file, String destinationDirectory) {

		byte[] buffer = new byte[1024];

		try {

			createDirectory(destinationDirectory);

			ZipInputStream zis = new ZipInputStream(new FileInputStream(file));

			ZipEntry zipEntry = zis.getNextEntry();

			if (zipEntry == null) {
				throw new DecompressException();
			}

			while (zipEntry != null) {
				String fileName = zipEntry.getName();
				File newFile = new File(destinationDirectory + fileName);
				FileOutputStream fos = new FileOutputStream(newFile);
				int len;
				while ((len = zis.read(buffer)) > 0) {
					fos.write(buffer, 0, len);
				}
				fos.close();
				zipEntry = zis.getNextEntry();
			}
			zis.closeEntry();
			zis.close();
		} catch (IOException e) {
			throw new DecompressException(e);
		}
	}

	private void createDirectory(String path) {

		File dir = new File(path);

		if (!dir.exists()) {
			try {
				dir.mkdir();
			} catch (SecurityException e) {
				throw new DecompressException(e);
			}
		}
	}
}