Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verapdf examples #1

Merged
merged 26 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7084ee8
Merge pull request #31 from MaximPlusov/master
MaximPlusov Apr 25, 2022
f0b6f1c
Merge pull request #32 from MaximPlusov/master
MaximPlusov Jun 20, 2022
bdf4b30
Merge pull request #33 from MaximPlusov/master
MaximPlusov Aug 11, 2022
274597a
Update dependency. Add github-actions
MaximPlusov Oct 10, 2022
1b01f03
Merge pull request #34 from veraPDF/update_tools
MaximPlusov Oct 10, 2022
c604b10
Add fix metadata tool
MaximPlusov Nov 3, 2022
539d363
Merge pull request #35 from veraPDF/fix_metadata_tool
MaximPlusov Nov 10, 2022
01e0be3
Bump pdfbox from 2.0.22 to 2.0.24 in /fix-metadata
dependabot[bot] Nov 10, 2022
705a8a0
Merge pull request #36 from veraPDF/dependabot/maven/fix-metadata/org…
MaximPlusov Nov 14, 2022
c16c885
Delete log4j dependency
MaximPlusov Nov 15, 2022
bf9c619
Merge pull request #37 from veraPDF/delete_log4j
MaximPlusov Nov 15, 2022
2002e26
Fix policy generator and fix metadata tools
MaximPlusov Nov 17, 2022
e0f9f89
Merge pull request #38 from veraPDF/fix_metadata
MaximPlusov Nov 17, 2022
23d7fff
Fix fixing metadata and policy generator
MaximPlusov Nov 26, 2022
f7caccb
Merge pull request #39 from veraPDF/fix_metadata
MaximPlusov Nov 28, 2022
4bbba31
Fix policy generator, metadata fixer. Add outlines editor
MaximPlusov Nov 28, 2022
370e3de
Merge pull request #40 from veraPDF/fix_metadata
MaximPlusov Nov 28, 2022
2350c95
Added tool for files with jpeg2000 generation
Dec 7, 2022
abca623
Update dependencies and java version
MaximPlusov Jan 1, 2023
6f8ccde
Merge pull request #41 from veraPDF/feature_jpeg
MaximPlusov May 23, 2023
a93708d
Add corpus wiki generation
MaximPlusov May 22, 2023
559b569
Change 1.23 to 1.25
MaximPlusov Jul 5, 2023
43b44d4
Update stream changing tool
MaximPlusov Aug 4, 2023
7ed22dd
Add profiles wiki generator
MaximPlusov Sep 6, 2023
56ac1cc
Add verapdf examples from documentation
MaximPlusov Sep 6, 2023
11429f2
Test
MaximPlusov Nov 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: PR QA

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:
name: Checkout and Build
runs-on: ubuntu-20.04

strategy:
matrix:
java-version: [8, 11, 16, 17]

steps:
- uses: actions/checkout@v2
- name: JDK setup
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn --batch-mode --update-snapshots verify

coverage:
name: Quality Assurance
runs-on: ubuntu-20.04
needs: [ build ]

steps:
- uses: actions/checkout@v2
- name: Codacy analysis reporting
uses: codacy/codacy-analysis-cli-action@master
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test

on:
workflow_call:

jobs:
build:
name: Checkout and Build
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- name: JDK setup
uses: actions/setup-java@v2
with:
java-version: 11
distribution: 'temurin'
cache: maven
- name: Test
run: cd policy-generator
mvn clean package
cd target
java -jar policy-generator.jar
72 changes: 72 additions & 0 deletions corpus-wiki-generation/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?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">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>verapdf-tools</artifactId>
<groupId>org.verapdf</groupId>
<version>1.0-SNAPSHOT</version>
</parent>

<groupId>org.verapdf</groupId>
<artifactId>corpus-wiki-generator</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>org.verapdf</groupId>
<artifactId>validation-model</artifactId>
<version>${verapdf.version}</version>
</dependency>

<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.26</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<plugins>

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>org.verapdf.tools.CorpusWikiGenerator</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package org.verapdf.tools;


import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;

//code from integration-tests
public class CorpusDownload {

public static File createTempFileFromCorpus(final URL downloadLoc, final String prefix) throws IOException {
File tempFile = File.createTempFile(prefix, ".zip");
System.out.println("Downloading: " + downloadLoc + ", to temp:" + tempFile);
int totalBytes = 0;
try (OutputStream output = new FileOutputStream(tempFile);
InputStream corpusInput = handleRedirects(downloadLoc)) {
byte[] buffer = new byte[8 * 1024];
int bytesRead;
while ((bytesRead = corpusInput.read(buffer)) != -1) {
output.write(buffer, 0, bytesRead);
totalBytes += bytesRead;
}
}
System.out.println("Downloaded: " + totalBytes + " bytes");
tempFile.deleteOnExit();
return tempFile;
}

static InputStream handleRedirects(URL url) throws IOException {
if (!url.getProtocol().startsWith("http")) {
return url.openStream();
}
System.err.println("Prot:" + url.getProtocol());
URL resourceUrl;
URL base;
URL next;
Map<String, Integer> visited;
HttpURLConnection conn;
String location;
String urlString = url.toExternalForm();
int times;

visited = new HashMap<>();

while (true) {
times = visited.compute(urlString, (key, count) -> count == null ? 1 : count + 1);

if (times > 3)
throw new IOException("Stuck in redirect loop");

resourceUrl = new URL(urlString);
conn = (HttpURLConnection) resourceUrl.openConnection();

conn.setConnectTimeout(15000);
conn.setReadTimeout(15000);
conn.setInstanceFollowRedirects(false); // Make the logic below easier to detect redirections
conn.setRequestProperty("User-Agent", "Mozilla/5.0...");

switch (conn.getResponseCode()) {
case HttpURLConnection.HTTP_MOVED_PERM:
case HttpURLConnection.HTTP_MOVED_TEMP:
location = conn.getHeaderField("Location");
location = URLDecoder.decode(location, "UTF-8");
base = new URL(urlString);
next = new URL(base, location); // Deal with relative URLs
urlString = next.toExternalForm();
continue;
}

break;
}

return conn.getInputStream();
}
}
Loading
Loading