diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml
new file mode 100644
index 0000000..645e671
--- /dev/null
+++ b/.github/workflows/docker-publish.yml
@@ -0,0 +1,97 @@
+name: Publish Docker Images
+
+on:
+ workflow_dispatch:
+ inputs:
+ version:
+ description: 'Version tag for docker images (e.g. 25.6)'
+ required: true
+ type: string
+ push_images:
+ description: 'Push images to Docker Hub'
+ required: true
+ type: boolean
+ default: false
+ update_description:
+ description: 'Update Docker Hub repository description'
+ required: true
+ type: boolean
+ default: false
+ latest:
+ description: 'Also tag openjdk18-bullseye-spring as latest (when pushing images)'
+ required: true
+ type: boolean
+ default: false
+
+run-name: "Docker ${{ inputs.version }} | push=${{ inputs.push_images }} | docs=${{ inputs.update_description }} | latest=${{ inputs.latest }}"
+
+jobs:
+ update-description:
+ if: ${{ inputs.update_description }}
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Render Docker Hub overview
+ run: |
+ sed "s/{{VERSION}}/${{ inputs.version }}/g" docs/docker-hub-overview.md > /tmp/docker-hub-overview.md
+
+ - name: Update Docker Hub description
+ uses: peter-evans/dockerhub-description@v5
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+ repository: groupdocs/annotation
+ readme-filepath: /tmp/docker-hub-overview.md
+ short-description: GroupDocs.Annotation for Java ${{ inputs.version }} demo (Spring & Dropwizard)
+
+ build:
+ if: ${{ inputs.push_images }}
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ framework: [spring, dropwizard]
+ jdk: [openjdk8, openjdk11, openjdk18]
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Login to Docker Hub
+ uses: docker/login-action@v3
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Set context directory
+ id: ctx
+ run: |
+ if [ "${{ matrix.framework }}" = "spring" ]; then
+ echo "dir=Demos/Spring" >> "$GITHUB_OUTPUT"
+ else
+ echo "dir=Demos/Dropwizard" >> "$GITHUB_OUTPUT"
+ fi
+
+ - name: Determine tags
+ id: tags
+ run: |
+ TAG="groupdocs/annotation:${{ inputs.version }}-java-${{ matrix.jdk }}-bullseye-${{ matrix.framework }}"
+ TAGS="${TAG}"
+ if [ "${{ inputs.latest }}" = "true" ] && [ "${{ matrix.framework }}" = "spring" ] && [ "${{ matrix.jdk }}" = "openjdk18" ]; then
+ TAGS="${TAGS},groupdocs/annotation:latest"
+ fi
+ echo "tags=${TAGS}" >> "$GITHUB_OUTPUT"
+
+ - name: Build and push
+ uses: docker/build-push-action@v6
+ with:
+ context: ${{ steps.ctx.outputs.dir }}
+ file: ${{ steps.ctx.outputs.dir }}/docker/Dockerfile-${{ matrix.jdk }}-bullseye
+ push: true
+ tags: ${{ steps.tags.outputs.tags }}
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
diff --git a/.github/workflows/update-version.yml b/.github/workflows/update-version.yml
new file mode 100644
index 0000000..7f405a3
--- /dev/null
+++ b/.github/workflows/update-version.yml
@@ -0,0 +1,60 @@
+name: Update Version
+
+on:
+ workflow_dispatch:
+ inputs:
+ version:
+ description: 'New version (e.g. 25.6)'
+ required: true
+ type: string
+ create_pr:
+ description: 'Create a pull request with the changes'
+ required: true
+ type: boolean
+ default: true
+
+run-name: "Update version to ${{ inputs.version }}"
+
+jobs:
+ update-version:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Update versions
+ run: ./scripts/update-version.sh ${{ inputs.version }}
+
+ - name: Verify versions
+ run: ./scripts/update-version.sh
+
+ - name: Show changed files
+ run: git diff --name-only
+
+ - name: Create pull request
+ if: ${{ inputs.create_pr }}
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ VERSION: ${{ inputs.version }}
+ run: |
+ BRANCH="update-version-${VERSION}"
+ git config user.name "github-actions[bot]"
+ git config user.email "github-actions[bot]@users.noreply.github.com"
+ git checkout -b "${BRANCH}"
+ git add -A
+ git commit -m "Update version to ${VERSION}"
+ git push -u origin "${BRANCH}"
+ gh pr create \
+ --title "Update version to ${VERSION}" \
+ --body "Automated version update to **${VERSION}** across all projects, Dockerfiles, and README."
+
+ - name: Commit directly
+ if: ${{ !inputs.create_pr }}
+ env:
+ VERSION: ${{ inputs.version }}
+ run: |
+ git config user.name "github-actions[bot]"
+ git config user.email "github-actions[bot]@users.noreply.github.com"
+ git add -A
+ git commit -m "Update version to ${VERSION}"
+ git push
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..70ac879
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+/Examples/target
+/Examples/Resources/Output
+Examples/.classpath
+Examples/.project
+Examples/.settings/
+deploy_key
+
+#License files
+*.lic
diff --git a/Demos/Dropwizard/.dockerignore b/Demos/Dropwizard/.dockerignore
new file mode 100644
index 0000000..996d586
--- /dev/null
+++ b/Demos/Dropwizard/.dockerignore
@@ -0,0 +1,9 @@
+.git
+target
+client/node_modules
+client/.angular
+client/package-lock.json
+docker
+Dockerfile
+DocumentSamples/*
+!DocumentSamples/.gitkeep
\ No newline at end of file
diff --git a/Demos/Dropwizard/.gitignore b/Demos/Dropwizard/.gitignore
new file mode 100644
index 0000000..21ed7b3
--- /dev/null
+++ b/Demos/Dropwizard/.gitignore
@@ -0,0 +1,23 @@
+.idea/*
+*.iml
+*.ipr
+*.iws
+target/*
+.DS_Store
+vs.bin
+App_Data/*
+node_modules
+client/.angular
+src/main/resources/assets/*
+!src/main/resources/assets/angular/
+!src/main/resources/assets/angular/**
+node/
+etc/
+package-lock.json
+Licenses/*
+!Licenses/.gitkeep
+DocumentSamples/*
+!DocumentSamples/.gitkeep
+
+#License files
+*.lic
diff --git a/Demos/Dropwizard/.travis.yml b/Demos/Dropwizard/.travis.yml
new file mode 100644
index 0000000..d996b1c
--- /dev/null
+++ b/Demos/Dropwizard/.travis.yml
@@ -0,0 +1,40 @@
+dist: trusty
+language: java
+jdk:
+- oraclejdk8
+- oraclejdk9
+- openjdk8
+#- oraclejdk11
+#- openjdk10
+#- openjdk11
+services:
+ - docker
+jobs:
+ include:
+ - stage: Coverage
+ jdk: oraclejdk8
+ script:
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
+ - chmod +x ./cc-test-reporter
+ - ./cc-test-reporter before-build
+ - mvn clean package
+ - JACOCO_SOURCE_PATH=src/main/java ./cc-test-reporter format-coverage target/site/jacoco/jacoco.xml --input-type jacoco
+ - ./cc-test-reporter upload-coverage
+ - stage: Tag Release
+ if: type = push AND branch = master AND commit_message !~ /^Travis bot released/
+ install: skip
+ script: git checkout master && git reset --hard $sha1 && git config --global push.followTags true && git config --global user.email "travis@travis-ci.org" && git config --global user.name "Travis CI" && export current_version=$(mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec) && echo "current version ${current_version}" && export minor=$(echo $current_version | sed "s/^[0-9]\{1,\}\.[0-9]\{1,\}\.\([0-9]\{1,\}\)/\1/") && export major=$(echo $current_version | sed "s/^\([0-9]\{1,\}\.[0-9]\{1,\}\)\.[0-9]\{1,\}/\1/") && export next_version=$major.$((minor+1)) && echo "next version ${next_version}" && sed -i.bak "s/$current_version/$next_version/g" README.md && rm README.md.bak && sed -i.bak "s/^
+
+
+
+
+
+
+ Text annotation
+
+
+
+
+ Freehand Drawing
+
+
+
+ Blackout & Redaction
+
+
+
+ Comments
+

+ * Create annotator instance depending on type of annotation + *
+ * + * @return + * @param annotationData AnnotationDataEntity + * @param pageInfo PageInfo + */ + public static BaseAnnotator createAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) { + AnnotationDataEntity roundedAnnotationData = roundCoordinates(annotationData); + switch (roundedAnnotationData.getType().toLowerCase()) { // addev .toLowerCase() + case "text": + case "texthighlight": //textHighlight + return new TextHighlightAnnotator(roundedAnnotationData, pageInfo); + case "area": + return new AreaAnnotator(roundedAnnotationData, pageInfo); + case "point": + return new PointAnnotator(roundedAnnotationData, pageInfo); + case "textstrikeout": //textStrikeout + return new TextStrikeoutAnnotator(roundedAnnotationData, pageInfo); + case "polyline": + return new PolylineAnnotator(roundedAnnotationData, pageInfo); + case "textfield": //textField + return new TextFieldAnnotator(roundedAnnotationData, pageInfo); + case "watermark": + return new WatermarkAnnotator(roundedAnnotationData, pageInfo); + case "textreplacement": //textReplacement + return new TextReplacementAnnotator(roundedAnnotationData, pageInfo); + case "arrow": + return new ArrowAnnotator(roundedAnnotationData, pageInfo); + case "textredaction": //textRedaction + return new TextRedactionAnnotator(roundedAnnotationData, pageInfo); + case "resourcesredaction": //resourcesRedaction + return new ResourceRedactionAnnotator(roundedAnnotationData, pageInfo); + case "textunderline": //textUnderline + return new TextUnderlineAnnotator(roundedAnnotationData, pageInfo); + case "distance": + return new DistanceAnnotator(roundedAnnotationData, pageInfo); + default: + throw new TotalGroupDocsException("Wrong annotation data without annotation type!"); + } + } + + private static AnnotationDataEntity roundCoordinates(AnnotationDataEntity annotationData) { + annotationData.setHeight((float) Math.round(annotationData.getHeight())); + annotationData.setLeft((float) Math.round(annotationData.getLeft())); + annotationData.setTop((float) Math.round(annotationData.getTop())); + annotationData.setWidth((float) Math.round(annotationData.getWidth())); + return annotationData; + } +} \ No newline at end of file diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/AreaAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/AreaAnnotator.java new file mode 100644 index 0000000..6edbf8a --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/AreaAnnotator.java @@ -0,0 +1,55 @@ +package com.groupdocs.ui.annotation.annotator; + +import com.groupdocs.annotation.models.PageInfo; +import com.groupdocs.annotation.models.annotationmodels.AnnotationBase; +import com.groupdocs.annotation.models.annotationmodels.AreaAnnotation; +import com.groupdocs.annotation.options.export.AnnotationType; +import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity; + +public class AreaAnnotator extends BaseAnnotator { + + private AreaAnnotation areaAnnotation; + + public AreaAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) { + super(annotationData, pageInfo); + + areaAnnotation = new AreaAnnotation(); + areaAnnotation.setBox(getBox()); + } + + @Override + public AnnotationBase annotateWord() { + areaAnnotation = (AreaAnnotation) initAnnotationBase(areaAnnotation); + return areaAnnotation; + } + + @Override + public AnnotationBase annotatePdf() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateCells() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateSlides() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateImage() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateDiagram() { + return annotateWord(); + } + + @Override + protected int getType() { + return AnnotationType.AREA; + } +} diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/ArrowAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/ArrowAnnotator.java new file mode 100644 index 0000000..d5b10bc --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/ArrowAnnotator.java @@ -0,0 +1,90 @@ +package com.groupdocs.ui.annotation.annotator; + +import com.groupdocs.annotation.models.PageInfo; +import com.groupdocs.annotation.models.Rectangle; +import com.groupdocs.annotation.models.Reply; +import com.groupdocs.annotation.models.annotationmodels.AnnotationBase; +import com.groupdocs.annotation.models.annotationmodels.ArrowAnnotation; +import com.groupdocs.annotation.options.export.AnnotationType; +import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity; +import com.groupdocs.ui.annotation.entity.web.CommentsEntity; + +public class ArrowAnnotator extends BaseAnnotator { + + private boolean withGuid = false; + private ArrowAnnotation arrowAnnotation; + + public ArrowAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) { + super(annotationData, pageInfo); + + this.arrowAnnotation = new ArrowAnnotation(); + this.arrowAnnotation.setBox(getBox()); + } + + @Override + public AnnotationBase annotateWord() { + withGuid = false; + arrowAnnotation = (ArrowAnnotation) initAnnotationBase(arrowAnnotation); + return arrowAnnotation; + } + + @Override + public AnnotationBase annotatePdf() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateCells() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateSlides() { + withGuid = true; + arrowAnnotation = (ArrowAnnotation) initAnnotationBase(arrowAnnotation); + return arrowAnnotation; + } + + @Override + public AnnotationBase annotateImage() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateDiagram() { + return annotateWord(); + } + + @Override + protected Reply getAnnotationReplyInfo(CommentsEntity comment) { + Reply annotationReplyInfo = super.getAnnotationReplyInfo(comment); + if (withGuid) { + annotationReplyInfo.setParentReply(new Reply()); + annotationReplyInfo.getParentReply().setId(annotationData.getId()); + } + return annotationReplyInfo; + } + + @Override + protected int getType() { + return AnnotationType.ARROW; + } + + @Override + protected Rectangle getBox() { + String svgPath = annotationData.getSvgPath(); + + String startPoint = svgPath.replace("[a-zA-Z]+", "").split(" ")[0]; + String endPoint = svgPath.replace("[a-zA-Z]+", "").split(" ")[1]; + + String[] start = startPoint.split(","); + float startX = Float.parseFloat(start.length > 0 ? start[0].replace("M", "").replace(",", ".") : "0"); + float startY = Float.parseFloat(start.length > 0 ? start[1].replace("M", "").replace(",", ".") : "0"); + + String[] end = endPoint.split(","); + float endX = Float.parseFloat(end.length > 0 ? end[0].replace("L", "").replace(",", ".") : "0") - startX; + float endY = Float.parseFloat(end.length > 1 ? end[1].replace("L", "").replace(",", ".") : "0") - startY; + + return new Rectangle(startX, startY, endX, endY); + } +} \ No newline at end of file diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/BaseAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/BaseAnnotator.java new file mode 100644 index 0000000..7bc2c5e --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/BaseAnnotator.java @@ -0,0 +1,225 @@ +package com.groupdocs.ui.annotation.annotator; + + +import com.groupdocs.annotation.models.PageInfo; +import com.groupdocs.annotation.models.Rectangle; +import com.groupdocs.annotation.models.Reply; +import com.groupdocs.annotation.models.User; +import com.groupdocs.annotation.models.annotationmodels.AnnotationBase; +import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity; +import com.groupdocs.ui.annotation.entity.web.CommentsEntity; +import com.groupdocs.ui.common.exception.TotalGroupDocsException; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Locale; +import java.util.TimeZone; + +/** + *+ * BaseSigner + *
+ */ +public abstract class BaseAnnotator { + + public String Message = "Annotation of type {0} for this file type is not supported"; + protected AnnotationDataEntity annotationData; + protected PageInfo pageInfo; + + /** + *+ * Constructor + *
+ * + * @param annotationData + * @param pageInfo + */ + protected BaseAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) { + this.annotationData = annotationData; + this.pageInfo = pageInfo; + } + + /** + *+ * Add area annotation into the Word document + *
+ * + * @return AnnotationBase + */ + public abstract AnnotationBase annotateWord(); + + /** + *+ * Add area annotation into the pdf document + *
+ * + * @return AnnotationBase + */ + public abstract AnnotationBase annotatePdf(); + + /////+ * Add area annotation into the Power Point document + *
+ * + * @return AnnotationBase + */ + public abstract AnnotationBase annotateSlides(); + + /** + *+ * Add area annotation into the image document + *
+ * + * @return AnnotationBase + */ + public abstract AnnotationBase annotateImage(); + + /** + *+ * Add area annotation into the document + *
+ * + * @return AnnotationBase + */ + public abstract AnnotationBase annotateDiagram(); + + /** + *+ * Initial for annotation info + *
+ * + * @param annotationBase + * @return AnnotationBase + */ + protected final AnnotationBase initAnnotationBase(AnnotationBase annotationBase) { + // set page number to add annotation + annotationBase.setPageNumber(annotationData.getPageNumber() - 1); + // set annotation type + annotationBase.setType(getType()); + annotationBase.setCreatedOn(Date.from(Instant.now())); + annotationBase.setId(annotationData.getId()); + // add replies + CommentsEntity[] comments = annotationData.getComments(); + if (comments != null && comments.length != 0) { + java.util.List+ * Initial for reply annotation info + *
+ * + * @return AnnotationReplyInfo + * @param comment CommentsEntity + */ + protected Reply getAnnotationReplyInfo(CommentsEntity comment) { + Reply reply = new Reply(); + reply.setComment(comment.getText()); + DateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss"); + format.setTimeZone(TimeZone.getTimeZone("GMT")); + Date date; + try { + date = new Date(Long.parseLong(comment.getTime())); + } catch (Exception e) { + try { + date = format.parse(comment.getTime()); + } catch (Exception exc) { + format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US); + try { + date = format.parse(comment.getTime()); + } catch (ParseException ex) { + throw new TotalGroupDocsException(ex.getMessage()); + } + } + } + reply.setRepliedOn(date); + reply.setUser(new User()); + reply.getUser().setName(comment.getUserName()); + return reply; + } + + /** + *+ * Get rectangle + *
+ * + * @return Rectangle + */ + protected Rectangle getBox() { + return new Rectangle(annotationData.getLeft(), annotationData.getTop(), annotationData.getWidth(), annotationData.getHeight()); + } + + /** + *+ * Get type of annotation + *
+ * + * @return byte + */ + protected abstract int getType(); + + /** + *+ * Get Annotation info depending on document type + *
+ * + * @return AnnotationBase + * @param documentType string + */ + public final AnnotationBase getAnnotationBase(String documentType) { + switch (documentType) { + case "Portable Document Format": + return annotatePdf(); + case "Microsoft Word": + case "Open Document Text": + return annotateWord(); + case "Rich Text Format": + return annotateWord(); + case "Microsoft PowerPoint": + return annotateSlides(); + case "image": + return annotateImage(); + case "Microsoft Excel": + return annotateCells(); + case "AutoCAD Drawing File Format": + return annotateDiagram(); + default: + throw new TotalGroupDocsException("Wrong annotation data without document type!"); + } + } + + /** + *+ * Check if the current annotatin is supported + *
+ * + * @return + * @param documentType string + */ + public final boolean isSupported(String documentType) { + try { + AnnotatorFactory.createAnnotator(annotationData, pageInfo).getAnnotationBase(documentType); + return true; + } catch (java.lang.UnsupportedOperationException e) { + Message += annotationData.getType(); + return false; + } + } +} \ No newline at end of file diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/DistanceAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/DistanceAnnotator.java new file mode 100644 index 0000000..1efc61b --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/DistanceAnnotator.java @@ -0,0 +1,92 @@ +package com.groupdocs.ui.annotation.annotator; + +import com.groupdocs.annotation.models.PageInfo; +import com.groupdocs.annotation.models.Rectangle; +import com.groupdocs.annotation.models.Reply; +import com.groupdocs.annotation.models.annotationmodels.AnnotationBase; +import com.groupdocs.annotation.models.annotationmodels.DistanceAnnotation; +import com.groupdocs.annotation.options.export.AnnotationType; +import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity; +import com.groupdocs.ui.annotation.entity.web.CommentsEntity; + +public class DistanceAnnotator extends BaseAnnotator { + + private DistanceAnnotation distanceAnnotation; + + public DistanceAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) { + super(annotationData, pageInfo); + + distanceAnnotation = new DistanceAnnotation(); + distanceAnnotation.setBox(getBox()); + } + + @Override + public AnnotationBase annotateWord() { + distanceAnnotation = (DistanceAnnotation) initAnnotationBaseDistanceAnnotator(distanceAnnotation); + return distanceAnnotation; + } + + @Override + public AnnotationBase annotatePdf() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateCells() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateSlides() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateImage() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateDiagram() { + return annotateWord(); + } + + protected final AnnotationBase initAnnotationBaseDistanceAnnotator(AnnotationBase annotationBase) { + distanceAnnotation = (DistanceAnnotation) super.initAnnotationBase(annotationBase); + String tmp0 = annotationData.getText(); + if (tmp0 == null) { + tmp0 = ""; + } + // add replies + String text = tmp0; + CommentsEntity[] comments = annotationData.getComments(); + if (comments != null && comments.length != 0) { + Reply reply = distanceAnnotation.getReplies().get(0); + if (reply != null) { + reply.setComment(String.format("%s %s", text, reply.getComment())); + } + } + + return distanceAnnotation; + } + + @Override + protected int getType() { + return AnnotationType.DISTANCE; + } + + @Override + protected Rectangle getBox() { + String svgPath = annotationData.getSvgPath(); + + String startPoint = svgPath.replaceAll("[a-zA-Z]+", "").split(" ")[0]; + String endPoint = svgPath.replaceAll("[a-zA-Z]+", "").split(" ")[1]; + String[] start = startPoint.split(","); + float startX = Float.parseFloat(start.length > 0 ? start[0] : "0"); + float startY = Float.parseFloat(start.length > 1 ? start[1] : "0"); + String[] end = endPoint.split(","); + float endX = Float.parseFloat(end.length > 0 ? end[0] : "0") - startX; + float endY = Float.parseFloat(end.length > 1 ? end[1] : "0") - startY; + return new Rectangle(startX, startY, endX, endY); + } +} diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/PointAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/PointAnnotator.java new file mode 100644 index 0000000..82c853f --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/PointAnnotator.java @@ -0,0 +1,56 @@ +package com.groupdocs.ui.annotation.annotator; + +import com.groupdocs.annotation.models.PageInfo; +import com.groupdocs.annotation.models.annotationmodels.AnnotationBase; +import com.groupdocs.annotation.models.annotationmodels.PointAnnotation; +import com.groupdocs.annotation.options.export.AnnotationType; +import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity; + + +public class PointAnnotator extends BaseAnnotator { + + private PointAnnotation pointAnnotation; + + public PointAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) { + super(annotationData, pageInfo); + + pointAnnotation = new PointAnnotation(); + pointAnnotation.setBox(getBox()); + } + + @Override + public AnnotationBase annotateWord() { + pointAnnotation = (PointAnnotation) super.initAnnotationBase(pointAnnotation); + return pointAnnotation; + } + + @Override + public AnnotationBase annotatePdf() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateCells() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateSlides() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateImage() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateDiagram() { + return annotateWord(); + } + + @Override + protected int getType() { + return AnnotationType.POINT; + } +} diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/PolylineAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/PolylineAnnotator.java new file mode 100644 index 0000000..a554cb1 --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/PolylineAnnotator.java @@ -0,0 +1,79 @@ +package com.groupdocs.ui.annotation.annotator; + +import com.groupdocs.annotation.models.PageInfo; +import com.groupdocs.annotation.models.User; +import com.groupdocs.annotation.models.annotationmodels.AnnotationBase; +import com.groupdocs.annotation.models.annotationmodels.PolylineAnnotation; +import com.groupdocs.annotation.options.export.AnnotationType; +import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity; +import com.groupdocs.ui.annotation.entity.web.CommentsEntity; + + +public class PolylineAnnotator extends BaseAnnotator { + + private PolylineAnnotation polylineAnnotation; + + public PolylineAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) { + super(annotationData, pageInfo); + + this.polylineAnnotation = new PolylineAnnotation(); + this.polylineAnnotation.setBox(getBox()); + this.polylineAnnotation.setPenColor(1201033); + this.polylineAnnotation.setPenWidth((byte) 2); + this.polylineAnnotation.setSvgPath(annotationData.getSvgPath()); + } + + @Override + public AnnotationBase annotateWord() { + polylineAnnotation = (PolylineAnnotation) initAnnotationBase(polylineAnnotation); + return polylineAnnotation; + } + + @Override + public AnnotationBase annotatePdf() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateCells() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateSlides() { + polylineAnnotation = (PolylineAnnotation) initAnnotationBase(polylineAnnotation); + fillCreatorName(polylineAnnotation, annotationData); + return polylineAnnotation; + } + + /** + *+ * Fill creator name field in annotation info + *
+ * + * @param polylineAnnotation AnnotationBase + * @param annotationData + */ + protected static void fillCreatorName(AnnotationBase polylineAnnotation, AnnotationDataEntity annotationData) { + CommentsEntity[] comments = annotationData.getComments(); + if (comments != null && comments.length > 0 && comments[0] != null) { + polylineAnnotation.setUser(new User()); + polylineAnnotation.getUser().setName(comments[0].getUserName()); + } + } + + @Override + public AnnotationBase annotateImage() { + return annotateSlides(); + } + + @Override + public AnnotationBase annotateDiagram() { + return annotateSlides(); + } + + @Override + protected int getType() { + return AnnotationType.POLYLINE; + } +} diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/ResourceRedactionAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/ResourceRedactionAnnotator.java new file mode 100644 index 0000000..bef6255 --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/ResourceRedactionAnnotator.java @@ -0,0 +1,57 @@ +package com.groupdocs.ui.annotation.annotator; + +import com.groupdocs.annotation.models.PageInfo; +import com.groupdocs.annotation.models.annotationmodels.AnnotationBase; +import com.groupdocs.annotation.models.annotationmodels.ResourcesRedactionAnnotation; +import com.groupdocs.annotation.options.export.AnnotationType; +import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity; +import com.groupdocs.ui.common.exception.TotalGroupDocsException; + + +public class ResourceRedactionAnnotator extends BaseAnnotator { + + private ResourcesRedactionAnnotation resourcesRedactionAnnotation; + + public ResourceRedactionAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) { + super(annotationData, pageInfo); + + this.resourcesRedactionAnnotation = new ResourcesRedactionAnnotation(); + this.resourcesRedactionAnnotation.setBox(getBox()); + } + + @Override + public AnnotationBase annotateWord() { + resourcesRedactionAnnotation = (ResourcesRedactionAnnotation) initAnnotationBase(resourcesRedactionAnnotation); + return resourcesRedactionAnnotation; + } + + @Override + public AnnotationBase annotatePdf() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateCells() { + throw new TotalGroupDocsException(Message + annotationData.getType()); + } + + @Override + public AnnotationBase annotateSlides() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateImage() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateDiagram() { + return annotateWord(); + } + + @Override + protected int getType() { + return AnnotationType.RESOURCES_REDACTION; + } +} \ No newline at end of file diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextFieldAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextFieldAnnotator.java new file mode 100644 index 0000000..4df87dc --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextFieldAnnotator.java @@ -0,0 +1,61 @@ +package com.groupdocs.ui.annotation.annotator; + +import com.groupdocs.annotation.models.PageInfo; +import com.groupdocs.annotation.models.annotationmodels.AnnotationBase; +import com.groupdocs.annotation.models.annotationmodels.TextFieldAnnotation; +import com.groupdocs.annotation.options.export.AnnotationType; +import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity; + + +public class TextFieldAnnotator extends BaseAnnotator { + + private TextFieldAnnotation textFieldAnnotation; + + public TextFieldAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) { + super(annotationData, pageInfo); + + textFieldAnnotation = new TextFieldAnnotation(); + textFieldAnnotation.setBox(getBox()); + + textFieldAnnotation.setFontFamily(annotationData.getFont() != null || !"".equals(annotationData.getFont()) ? annotationData.getFont() : "Arial"); + textFieldAnnotation.setFontColor(annotationData.getFontColor()); + textFieldAnnotation.setFontSize(annotationData.getFontSize() == 0 ? 12 : annotationData.getFontSize()); + textFieldAnnotation.setText(annotationData.getText()); + } + + @Override + public AnnotationBase annotateWord() { + textFieldAnnotation = (TextFieldAnnotation) initAnnotationBase(textFieldAnnotation); + return textFieldAnnotation; + } + + @Override + public AnnotationBase annotatePdf() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateCells() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateSlides() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateImage() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateDiagram() { + return annotateWord(); + } + + @Override + protected int getType() { + return AnnotationType.TEXT_FIELD; + } +} \ No newline at end of file diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextHighlightAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextHighlightAnnotator.java new file mode 100644 index 0000000..cc4b08d --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextHighlightAnnotator.java @@ -0,0 +1,57 @@ +package com.groupdocs.ui.annotation.annotator; + +import com.groupdocs.annotation.models.PageInfo; +import com.groupdocs.annotation.models.annotationmodels.AnnotationBase; +import com.groupdocs.annotation.models.annotationmodels.HighlightAnnotation; +import com.groupdocs.annotation.options.export.AnnotationType; +import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity; +import com.groupdocs.ui.common.exception.TotalGroupDocsException; + + +public class TextHighlightAnnotator extends AbstractTextAnnotator { + + private HighlightAnnotation highlightAnnotation; + + public TextHighlightAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) { + super(annotationData, pageInfo); + + highlightAnnotation = new HighlightAnnotation(); + highlightAnnotation.setPoints(getPoints(annotationData, pageInfo)); + } + + @Override + public AnnotationBase annotateWord() { + highlightAnnotation = (HighlightAnnotation) initAnnotationBase(highlightAnnotation); + return highlightAnnotation; + } + + @Override + public AnnotationBase annotatePdf() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateCells() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateSlides() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateImage() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateDiagram() { + throw new TotalGroupDocsException(Message + annotationData.getType()); + } + + @Override + protected int getType() { + return AnnotationType.TEXT_HIGHLIGHT; + } +} \ No newline at end of file diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextRedactionAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextRedactionAnnotator.java new file mode 100644 index 0000000..f1b3a4b --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextRedactionAnnotator.java @@ -0,0 +1,56 @@ +package com.groupdocs.ui.annotation.annotator; + +import com.groupdocs.annotation.models.PageInfo; +import com.groupdocs.annotation.models.annotationmodels.AnnotationBase; +import com.groupdocs.annotation.models.annotationmodels.TextRedactionAnnotation; +import com.groupdocs.annotation.options.export.AnnotationType; +import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity; +import com.groupdocs.ui.common.exception.TotalGroupDocsException; + +public class TextRedactionAnnotator extends TextHighlightAnnotator { + + private TextRedactionAnnotation textRedactionAnnotation; + + public TextRedactionAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) { + super(annotationData, pageInfo); + + textRedactionAnnotation = new TextRedactionAnnotation(); + textRedactionAnnotation.setPoints(getPoints(annotationData, pageInfo)); + } + + @Override + public AnnotationBase annotateCells() { + return annotatePdf(); + } + + @Override + public AnnotationBase annotateSlides() { + return annotatePdf(); + } + + @Override + public AnnotationBase annotateImage() { + throw new TotalGroupDocsException(Message + annotationData.getType()); + } + + @Override + public AnnotationBase annotateDiagram() { + throw new TotalGroupDocsException(Message + annotationData.getType()); + } + + @Override + public AnnotationBase annotatePdf() { + textRedactionAnnotation = (TextRedactionAnnotation) initAnnotationBase(textRedactionAnnotation); + return textRedactionAnnotation; + } + + @Override + public AnnotationBase annotateWord() { + return annotatePdf(); + } + + @Override + protected int getType() { + return AnnotationType.TEXT_REDACTION; + } +} \ No newline at end of file diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextReplacementAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextReplacementAnnotator.java new file mode 100644 index 0000000..c6d92ca --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextReplacementAnnotator.java @@ -0,0 +1,58 @@ +package com.groupdocs.ui.annotation.annotator; + +import com.groupdocs.annotation.models.PageInfo; +import com.groupdocs.annotation.models.annotationmodels.AnnotationBase; +import com.groupdocs.annotation.models.annotationmodels.ReplacementAnnotation; +import com.groupdocs.annotation.options.export.AnnotationType; +import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity; +import com.groupdocs.ui.common.exception.TotalGroupDocsException; + + +public class TextReplacementAnnotator extends AbstractTextAnnotator { + + private ReplacementAnnotation replacementAnnotation; + + public TextReplacementAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) { + super(annotationData, pageInfo); + + replacementAnnotation = new ReplacementAnnotation(); + replacementAnnotation.setPoints(getPoints(annotationData, pageInfo)); + replacementAnnotation.setTextToReplace(annotationData.getText()); + } + + @Override + public AnnotationBase annotateWord() { + replacementAnnotation = (ReplacementAnnotation) initAnnotationBase(replacementAnnotation); + return replacementAnnotation; + } + + @Override + public AnnotationBase annotatePdf() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateCells() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateSlides() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateImage() { + throw new TotalGroupDocsException(Message + annotationData.getType()); + } + + @Override + public AnnotationBase annotateDiagram() { + throw new TotalGroupDocsException(Message + annotationData.getType()); + } + + @Override + protected int getType() { + return AnnotationType.TEXT_REPLACEMENT; + } +} \ No newline at end of file diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextStrikeoutAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextStrikeoutAnnotator.java new file mode 100644 index 0000000..3f36675 --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextStrikeoutAnnotator.java @@ -0,0 +1,58 @@ +package com.groupdocs.ui.annotation.annotator; + +import com.groupdocs.annotation.models.PageInfo; +import com.groupdocs.annotation.models.annotationmodels.AnnotationBase; +import com.groupdocs.annotation.models.annotationmodels.StrikeoutAnnotation; +import com.groupdocs.annotation.options.export.AnnotationType; +import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity; +import com.groupdocs.ui.common.exception.TotalGroupDocsException; + +public class TextStrikeoutAnnotator extends AbstractTextAnnotator { + + private StrikeoutAnnotation strikeoutAnnotation; + + public TextStrikeoutAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) { + super(annotationData, pageInfo); + + strikeoutAnnotation = new StrikeoutAnnotation(); + strikeoutAnnotation.setPoints(getPoints(annotationData, pageInfo)); + } + + @Override + public AnnotationBase annotateWord() { + strikeoutAnnotation = (StrikeoutAnnotation) initAnnotationBase(strikeoutAnnotation); + return strikeoutAnnotation; + } + + @Override + public AnnotationBase annotatePdf() { + strikeoutAnnotation = (StrikeoutAnnotation) initAnnotationBase(strikeoutAnnotation); + this.strikeoutAnnotation.setFontColor(0); + return strikeoutAnnotation; + } + + @Override + public AnnotationBase annotateCells() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateSlides() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateImage() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateDiagram() { + throw new TotalGroupDocsException(Message + annotationData.getType()); + } + + @Override + protected int getType() { + return AnnotationType.TEXT_STRIKEOUT; + } +} \ No newline at end of file diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextUnderlineAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextUnderlineAnnotator.java new file mode 100644 index 0000000..ef09636 --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextUnderlineAnnotator.java @@ -0,0 +1,60 @@ +package com.groupdocs.ui.annotation.annotator; + +import com.groupdocs.annotation.models.PageInfo; +import com.groupdocs.annotation.models.annotationmodels.AnnotationBase; +import com.groupdocs.annotation.models.annotationmodels.UnderlineAnnotation; +import com.groupdocs.annotation.options.export.AnnotationType; +import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity; +import com.groupdocs.ui.common.exception.TotalGroupDocsException; + + +public class TextUnderlineAnnotator extends AbstractTextAnnotator { + + private UnderlineAnnotation underlineAnnotation; + + public TextUnderlineAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) { + super(annotationData, pageInfo); + + underlineAnnotation = new UnderlineAnnotation(); + underlineAnnotation.setPoints(getPoints(annotationData, pageInfo)); + } + + @Override + public AnnotationBase annotateWord() { + underlineAnnotation = (UnderlineAnnotation) initAnnotationBase(underlineAnnotation); + underlineAnnotation.setFontColor(1201033); + return underlineAnnotation; + } + + @Override + public AnnotationBase annotatePdf() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateCells() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateSlides() { + underlineAnnotation = (UnderlineAnnotation) initAnnotationBase(underlineAnnotation); + underlineAnnotation.setFontColor(0); + return underlineAnnotation; + } + + @Override + public AnnotationBase annotateImage() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateDiagram() { + throw new TotalGroupDocsException(Message + annotationData.getType()); + } + + @Override + protected int getType() { + return AnnotationType.TEXT_UNDERLINE; + } +} \ No newline at end of file diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/WatermarkAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/WatermarkAnnotator.java new file mode 100644 index 0000000..b395e0a --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/WatermarkAnnotator.java @@ -0,0 +1,60 @@ +package com.groupdocs.ui.annotation.annotator; + +import com.groupdocs.annotation.models.PageInfo; +import com.groupdocs.annotation.models.annotationmodels.AnnotationBase; +import com.groupdocs.annotation.models.annotationmodels.WatermarkAnnotation; +import com.groupdocs.annotation.options.export.AnnotationType; +import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity; +import com.groupdocs.ui.common.exception.TotalGroupDocsException; + +public class WatermarkAnnotator extends BaseAnnotator { + + private WatermarkAnnotation watermarkAnnotation; + + public WatermarkAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) { + super(annotationData, pageInfo); + + watermarkAnnotation = new WatermarkAnnotation(); + watermarkAnnotation.setBox(getBox()); + watermarkAnnotation.setFontFamily(annotationData.getFont() != null || !"".equals(annotationData.getFont()) ? annotationData.getFont() : "Arial"); + watermarkAnnotation.setFontColor(annotationData.getFontColor()); + watermarkAnnotation.setFontSize(annotationData.getFontSize() == 0 ? 12 : annotationData.getFontSize()); + watermarkAnnotation.setText(annotationData.getText()); + } + + @Override + public AnnotationBase annotateWord() { + watermarkAnnotation = (WatermarkAnnotation) initAnnotationBase(watermarkAnnotation); + return watermarkAnnotation; + } + + @Override + public AnnotationBase annotatePdf() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateCells() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateSlides() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateImage() { + return annotateWord(); + } + + @Override + public AnnotationBase annotateDiagram() { + throw new TotalGroupDocsException(Message + annotationData.getType()); + } + + @Override + protected int getType() { + return AnnotationType.WATERMARK; + } +} \ No newline at end of file diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/config/AnnotationConfiguration.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/config/AnnotationConfiguration.java new file mode 100644 index 0000000..55738cb --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/config/AnnotationConfiguration.java @@ -0,0 +1,270 @@ +package com.groupdocs.ui.annotation.config; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.dropwizard.Configuration; +import org.apache.commons.lang3.StringUtils; + +import javax.validation.Valid; + +import static com.groupdocs.ui.common.config.DefaultDirectories.defaultAnnotationDirectory; +import static com.groupdocs.ui.common.config.DefaultDirectories.relativePathToAbsolute; + +/** + * AnnotationConfiguration + * + * @author Aspose Pty Ltd + */ +public class AnnotationConfiguration extends Configuration { + + @Valid + @JsonProperty + private String filesDirectory; + + @Valid + @JsonProperty + private String defaultDocument; + + @Valid + @JsonProperty + private int preloadPageCount; + + @Valid + @JsonProperty + private String fontsDirectory; + + @Valid + @JsonProperty + private boolean textAnnotation; + + @Valid + @JsonProperty + private boolean areaAnnotation; + + @Valid + @JsonProperty + private boolean pointAnnotation; + + @Valid + @JsonProperty + private boolean textStrikeoutAnnotation; + + @Valid + @JsonProperty + private boolean polylineAnnotation; + + @Valid + @JsonProperty + private boolean textFieldAnnotation; + + @Valid + @JsonProperty + private boolean watermarkAnnotation; + + @Valid + @JsonProperty + private boolean textReplacementAnnotation; + + @Valid + @JsonProperty + private boolean arrowAnnotation; + + @Valid + @JsonProperty + private boolean textRedactionAnnotation; + + @Valid + @JsonProperty + private boolean resourcesRedactionAnnotation; + + @Valid + @JsonProperty + private boolean textUnderlineAnnotation; + + @Valid + @JsonProperty + private boolean distanceAnnotation; + + @Valid + @JsonProperty + private boolean downloadOriginal; + + @Valid + @JsonProperty + private boolean downloadAnnotated; + + @Valid + @JsonProperty + private boolean zoom; + + @Valid + @JsonProperty + private boolean fitWidth; + + public String getFilesDirectory() { + return filesDirectory; + } + + public void setFilesDirectory(String filesDirectory) { + this.filesDirectory = StringUtils.isEmpty(filesDirectory) ? defaultAnnotationDirectory() : relativePathToAbsolute(filesDirectory); + } + + public String getDefaultDocument() { + return defaultDocument; + } + + public void setDefaultDocument(String defaultDocument) { + this.defaultDocument = defaultDocument; + } + + public int getPreloadPageCount() { + return preloadPageCount; + } + + public void setPreloadPageCount(int preloadPageCount) { + this.preloadPageCount = preloadPageCount; + } + + public String getFontsDirectory() { + return fontsDirectory; + } + + public void setFontsDirectory(String fontsDirectory) { + this.fontsDirectory = fontsDirectory; + } + + public boolean getTextAnnotation() { + return textAnnotation; + } + + public void setTextAnnotation(boolean textAnnotation) { + this.textAnnotation = textAnnotation; + } + + public boolean getAreaAnnotation() { + return areaAnnotation; + } + + public void setAreaAnnotation(boolean areaAnnotation) { + this.areaAnnotation = areaAnnotation; + } + + public boolean getPointAnnotation() { + return pointAnnotation; + } + + public void setPointAnnotation(boolean pointAnnotation) { + this.pointAnnotation = pointAnnotation; + } + + public boolean getTextStrikeoutAnnotation() { + return textStrikeoutAnnotation; + } + + public void setTextStrikeoutAnnotation(boolean textStrikeoutAnnotation) { + this.textStrikeoutAnnotation = textStrikeoutAnnotation; + } + + public boolean getPolylineAnnotation() { + return polylineAnnotation; + } + + public void setPolylineAnnotation(boolean polylineAnnotation) { + this.polylineAnnotation = polylineAnnotation; + } + + public boolean getTextFieldAnnotation() { + return textFieldAnnotation; + } + + public void setTextFieldAnnotation(boolean textFieldAnnotation) { + this.textFieldAnnotation = textFieldAnnotation; + } + + public boolean getWatermarkAnnotation() { + return watermarkAnnotation; + } + + public void setWatermarkAnnotation(boolean watermarkAnnotation) { + this.watermarkAnnotation = watermarkAnnotation; + } + + public boolean getTextReplacementAnnotation() { + return textReplacementAnnotation; + } + + public void setTextReplacementAnnotation(boolean textReplacementAnnotation) { + this.textReplacementAnnotation = textReplacementAnnotation; + } + + public boolean getArrowAnnotation() { + return arrowAnnotation; + } + + public void setArrowAnnotation(boolean arrowAnnotation) { + this.arrowAnnotation = arrowAnnotation; + } + + public boolean getTextRedactionAnnotation() { + return textRedactionAnnotation; + } + + public void setTextRedactionAnnotation(boolean textRedactionAnnotation) { + this.textRedactionAnnotation = textRedactionAnnotation; + } + + public boolean getResourcesRedactionAnnotation() { + return resourcesRedactionAnnotation; + } + + public void setResourcesRedactionAnnotation(boolean resourcesRedactionAnnotation) { + this.resourcesRedactionAnnotation = resourcesRedactionAnnotation; + } + + public boolean getTextUnderlineAnnotation() { + return textUnderlineAnnotation; + } + + public void setTextUnderlineAnnotation(boolean textUnderlineAnnotation) { + this.textUnderlineAnnotation = textUnderlineAnnotation; + } + + public boolean getDistanceAnnotation() { + return distanceAnnotation; + } + + public void setDistanceAnnotation(boolean distanceAnnotation) { + this.distanceAnnotation = distanceAnnotation; + } + + public boolean getDownloadOriginal() { + return downloadOriginal; + } + + public void setDownloadOriginal(boolean downloadOriginal) { + this.downloadOriginal = downloadOriginal; + } + + public boolean getDownloadAnnotated() { + return downloadAnnotated; + } + + public void setDownloadAnnotated(boolean downloadAnnotated) { + this.downloadAnnotated = downloadAnnotated; + } + + public boolean getZoom() { + return zoom; + } + + public void setZoom(boolean zoom) { + this.zoom = zoom; + } + + public boolean getFitWidth() { + return fitWidth; + } + + public void setFitWidth(boolean fitWidth) { + this.fitWidth = fitWidth; + } +} \ No newline at end of file diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/config/AnnotationConfigurationModel.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/config/AnnotationConfigurationModel.java new file mode 100644 index 0000000..e71e628 --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/config/AnnotationConfigurationModel.java @@ -0,0 +1,289 @@ +package com.groupdocs.ui.annotation.config; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.groupdocs.ui.common.config.CommonConfiguration; +import com.groupdocs.ui.common.config.CommonConfigurationModel; + +import javax.validation.Valid; + +public class AnnotationConfigurationModel extends CommonConfigurationModel { + + @Valid + @JsonProperty + private String filesDirectory; + + @Valid + @JsonProperty + private String defaultDocument; + + @Valid + @JsonProperty + private int preloadPageCount; + + @Valid + @JsonProperty + private String fontsDirectory; + + @Valid + @JsonProperty + private boolean textAnnotation; + + @Valid + @JsonProperty + private boolean areaAnnotation; + + @Valid + @JsonProperty + private boolean pointAnnotation; + + @Valid + @JsonProperty + private boolean textStrikeoutAnnotation; + + @Valid + @JsonProperty + private boolean polylineAnnotation; + + @Valid + @JsonProperty + private boolean textFieldAnnotation; + + @Valid + @JsonProperty + private boolean watermarkAnnotation; + + @Valid + @JsonProperty + private boolean textReplacementAnnotation; + + @Valid + @JsonProperty + private boolean arrowAnnotation; + + @Valid + @JsonProperty + private boolean textRedactionAnnotation; + + @Valid + @JsonProperty + private boolean resourcesRedactionAnnotation; + + @Valid + @JsonProperty + private boolean textUnderlineAnnotation; + + @Valid + @JsonProperty + private boolean distanceAnnotation; + + @Valid + @JsonProperty + private boolean downloadOriginal; + + @Valid + @JsonProperty + private boolean downloadAnnotated; + + @Valid + @JsonProperty + private boolean zoom; + + @Valid + @JsonProperty + private boolean fitWidth; + + public String getFilesDirectory() { + return filesDirectory; + } + + public void setFilesDirectory(String filesDirectory) { + this.filesDirectory = filesDirectory; + } + + public String getDefaultDocument() { + return defaultDocument; + } + + public void setDefaultDocument(String defaultDocument) { + this.defaultDocument = defaultDocument; + } + + public int getPreloadPageCount() { + return preloadPageCount; + } + + public void setPreloadPageCount(int preloadPageCount) { + this.preloadPageCount = preloadPageCount; + } + + public String getFontsDirectory() { + return fontsDirectory; + } + + public void setFontsDirectory(String fontsDirectory) { + this.fontsDirectory = fontsDirectory; + } + + public boolean isTextAnnotation() { + return textAnnotation; + } + + public void setTextAnnotation(boolean textAnnotation) { + this.textAnnotation = textAnnotation; + } + + public boolean isAreaAnnotation() { + return areaAnnotation; + } + + public void setAreaAnnotation(boolean areaAnnotation) { + this.areaAnnotation = areaAnnotation; + } + + public boolean isPointAnnotation() { + return pointAnnotation; + } + + public void setPointAnnotation(boolean pointAnnotation) { + this.pointAnnotation = pointAnnotation; + } + + public boolean isTextStrikeoutAnnotation() { + return textStrikeoutAnnotation; + } + + public void setTextStrikeoutAnnotation(boolean textStrikeoutAnnotation) { + this.textStrikeoutAnnotation = textStrikeoutAnnotation; + } + + public boolean isPolylineAnnotation() { + return polylineAnnotation; + } + + public void setPolylineAnnotation(boolean polylineAnnotation) { + this.polylineAnnotation = polylineAnnotation; + } + + public boolean isTextFieldAnnotation() { + return textFieldAnnotation; + } + + public void setTextFieldAnnotation(boolean textFieldAnnotation) { + this.textFieldAnnotation = textFieldAnnotation; + } + + public boolean isWatermarkAnnotation() { + return watermarkAnnotation; + } + + public void setWatermarkAnnotation(boolean watermarkAnnotation) { + this.watermarkAnnotation = watermarkAnnotation; + } + + public boolean isTextReplacementAnnotation() { + return textReplacementAnnotation; + } + + public void setTextReplacementAnnotation(boolean textReplacementAnnotation) { + this.textReplacementAnnotation = textReplacementAnnotation; + } + + public boolean isArrowAnnotation() { + return arrowAnnotation; + } + + public void setArrowAnnotation(boolean arrowAnnotation) { + this.arrowAnnotation = arrowAnnotation; + } + + public boolean isTextRedactionAnnotation() { + return textRedactionAnnotation; + } + + public void setTextRedactionAnnotation(boolean textRedactionAnnotation) { + this.textRedactionAnnotation = textRedactionAnnotation; + } + + public boolean isResourcesRedactionAnnotation() { + return resourcesRedactionAnnotation; + } + + public void setResourcesRedactionAnnotation(boolean resourcesRedactionAnnotation) { + this.resourcesRedactionAnnotation = resourcesRedactionAnnotation; + } + + public boolean isTextUnderlineAnnotation() { + return textUnderlineAnnotation; + } + + public void setTextUnderlineAnnotation(boolean textUnderlineAnnotation) { + this.textUnderlineAnnotation = textUnderlineAnnotation; + } + + public boolean isDistanceAnnotation() { + return distanceAnnotation; + } + + public void setDistanceAnnotation(boolean distanceAnnotation) { + this.distanceAnnotation = distanceAnnotation; + } + + public boolean isDownloadOriginal() { + return downloadOriginal; + } + + public void setDownloadOriginal(boolean downloadOriginal) { + this.downloadOriginal = downloadOriginal; + } + + public boolean isDownloadAnnotated() { + return downloadAnnotated; + } + + public void setDownloadAnnotated(boolean downloadAnnotated) { + this.downloadAnnotated = downloadAnnotated; + } + + public boolean isZoom() { + return zoom; + } + + public void setZoom(boolean zoom) { + this.zoom = zoom; + } + + public boolean isFitWidth() { + return fitWidth; + } + + public void setFitWidth(boolean fitWidth) { + this.fitWidth = fitWidth; + } + + public static AnnotationConfigurationModel createAnnotationConfiguration(AnnotationConfiguration annotation, CommonConfiguration common) { + AnnotationConfigurationModel config = new AnnotationConfigurationModel(); + config.init(common); + config.setFilesDirectory(annotation.getFilesDirectory()); + config.setDefaultDocument(annotation.getDefaultDocument()); + config.setPreloadPageCount(annotation.getPreloadPageCount()); + config.setFontsDirectory(annotation.getFontsDirectory()); + config.setTextAnnotation(annotation.getTextAnnotation()); + config.setAreaAnnotation(annotation.getAreaAnnotation()); + config.setPointAnnotation(annotation.getPointAnnotation()); + config.setTextStrikeoutAnnotation(annotation.getTextStrikeoutAnnotation()); + config.setPolylineAnnotation(annotation.getPolylineAnnotation()); + config.setTextFieldAnnotation(annotation.getTextFieldAnnotation()); + config.setTextReplacementAnnotation(annotation.getTextReplacementAnnotation()); + config.setTextRedactionAnnotation(annotation.getTextRedactionAnnotation()); + config.setTextUnderlineAnnotation(annotation.getTextUnderlineAnnotation()); + config.setWatermarkAnnotation(annotation.getWatermarkAnnotation()); + config.setArrowAnnotation(annotation.getArrowAnnotation()); + config.setDistanceAnnotation(annotation.getDistanceAnnotation()); + config.setResourcesRedactionAnnotation(annotation.getResourcesRedactionAnnotation()); + config.setZoom(annotation.getZoom()); + config.setFitWidth(annotation.getFitWidth()); + config.setDownloadOriginal(annotation.getDownloadOriginal()); + config.setDownloadAnnotated(annotation.getDownloadAnnotated()); + return config; + } +} diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/request/AnnotateDocumentRequest.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/request/AnnotateDocumentRequest.java new file mode 100644 index 0000000..3a005b9 --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/request/AnnotateDocumentRequest.java @@ -0,0 +1,49 @@ +package com.groupdocs.ui.annotation.entity.request; + +import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity; +import com.groupdocs.ui.common.entity.web.request.LoadDocumentRequest; + +/** + * AnnotateDocumentRequest + * + * @author Aspose Pty Ltd + */ +public class AnnotateDocumentRequest extends LoadDocumentRequest { + /** + * List of annotation data + */ + private AnnotationDataEntity[] annotationsData; + /** + * Document type + */ + private String documentType; + + /** + * For print annotated file + */ + private Boolean print; + + public AnnotationDataEntity[] getAnnotationsData() { + return annotationsData; + } + + public void setAnnotationsData(AnnotationDataEntity[] annotationsData) { + this.annotationsData = annotationsData; + } + + public String getDocumentType() { + return documentType; + } + + public void setDocumentType(String documentType) { + this.documentType = documentType; + } + + public Boolean getPrint() { + return print; + } + + public void setPrint(Boolean print) { + this.print = print; + } +} diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/request/PostedDataEntity.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/request/PostedDataEntity.java new file mode 100644 index 0000000..cf02445 --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/request/PostedDataEntity.java @@ -0,0 +1,183 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.groupdocs.ui.annotation.entity.request; + +import java.util.List; + +/** + * + * @author AlexT + */ +public class PostedDataEntity { + /** + *+ * Absolute path to the posted document. + *
+ * @return + */ + public String getPath() { + return path; + } + + /** + *+ * Absolute path to the posted document. + *
+ * @param value + */ + public void setPath(String value) { + path = value; + } + private String path; + + /** + *+ * Absolute path to the document. + *
+ * @return + */ + public String getGuid() { + return guid; + } + + /** + *+ * Absolute path to the document. + *
+ * @param value + */ + public void setGuid(String value) { + guid = value; + } + private String guid; + + /** + *+ * Document password. + *
+ * @return + */ + public String getPassword() { + return password; + } + + /** + *+ * Document password. + *
+ * @param value + */ + public void setPassword(String value) { + password = value; + } + private String password; + + /** + *+ * Url of the posted file. + *
+ * @return + */ + public String getUrl() { + return url; + } + + /** + *+ * Url of the posted file. + *
+ * @param value + */ + public void setUrl(String value) { + url = value; + } + private String url; + + /** + *+ * Page number. + *
+ * @return + */ + public int getPage() { + return page; + } + + /** + *+ * Page number. + *
+ * @param value + */ + public void setPage(int value) { + page = value; + } + private int page; + + /** + *+ * Page rotation angle. + *
+ * @return + */ + public int getAngle() { + return angle; + } + + /** + *+ * Page rotation angle. + *
+ * @param value + */ + public void setAngle(int value) { + angle = value; + } + private int angle; + + /** + *+ * Collection of the document pages with their data. + *
+ * @return + */ + public List+ * Collection of the document pages with their data. + *
+ * @param value + */ + public void setPages(List+ * Flag indicating whether the file should be overwritten. + *
+ * @return + */ + public boolean getRewrite() { + return rewrite; + } + + /** + *+ * Flag indicating whether the file should be overwritten. + *
+ * @param value + */ + public void setRewrite(boolean value) { + rewrite = value; + } + private boolean rewrite; +} diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotatedDocumentEntity.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotatedDocumentEntity.java new file mode 100644 index 0000000..143983a --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotatedDocumentEntity.java @@ -0,0 +1,48 @@ +package com.groupdocs.ui.annotation.entity.web; + +import java.util.ArrayList; +import java.util.List; + +/** + * AnnotatedDocumentEntity + * + * @author Aspose Pty Ltd + */ +public class AnnotatedDocumentEntity extends PageDescriptionEntity { + /** + * Document Guid + */ + private String guid; + /** + * List of supported types of annotations + */ + public String[] supportedAnnotations; + /** + * list of pages + */ + private List+ * Map AnnotationInfo instances into AnnotationDataEntity + *
+ * + * @param pageInfo + * @return + * @param annotations AnnotationInfo[] + * @param pageNumber int + */ + // AnnotationDataEntity[] => List+ * Map AnnotationInfo instances into AnnotationDataEntity + *
+ * + * @param pageInfo + * @return AnnotationDataEntity + * @param annotationInfo AnnotationInfo + */ + public static AnnotationDataEntity mapAnnotationDataEntity(AnnotationBase annotationInfo, PageInfo pageInfo) { + String annotationTypeName = AnnotationType.getName(annotationInfo.getType()); + float maxY = 0, minY = Float.MAX_VALUE, maxX = 0, minX = Float.MAX_VALUE; // minY = 0, minX = 0 + float boxX = 0, boxY = 0, boxHeight = 0, boxWidth = 0; + String svgPath = ""; + + if (annotationInfo instanceof IPoints) { + List+ * Convert document type from string into int + *
+ * + * @return int + * @param documentType string + */ +// public static int getDocumentType(String documentType) { +// switch (documentType) { +// case "Portable Document Format": +// case "PDF": +// return DocumentType.Pdf; +// case "Microsoft Word": +// case "WORDS": +// case "Microsoft Word Open XML format (.docx)": +// return DocumentType.Words; +// case "Microsoft PowerPoint": +// case "SLIDES": +// return DocumentType.Slides; +// case "image": +// return DocumentType.Images; +// case "Microsoft Excel": +// case "CELLS": +// return DocumentType.Cells; +// case "AutoCAD Drawing File Format": +// case "diagram": +// return DocumentType.Diagram; +// default: +// return DocumentType.Undefined; +// } +// } + + /** + * Check image and diagram document types + * + * @param documentGuid document name + * @param documentType string value of document type + * @return correct document type + */ + public static String checkedDocumentType(String documentGuid, String documentType) { + String fileExtension = parseFileExtension(documentGuid); + // check if document type is image + if (supportedImageFormats.contains(fileExtension)) { + documentType = "image"; + } else if (supportedDiagramFormats.contains(fileExtension)) { + documentType = "diagram"; + } + return documentType; + } +} \ No newline at end of file diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/SupportedAnnotations.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/SupportedAnnotations.java new file mode 100644 index 0000000..f523ff4 --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/SupportedAnnotations.java @@ -0,0 +1,102 @@ +package com.groupdocs.ui.annotation.util; + +/** + * The list of supported annotation types for each document type + */ +public class SupportedAnnotations { + public static String[] CELLS = { + "text" + }; + public static String[] DIAGRAM = { + "area", + "point", + "polyline", + "textField", + "arrow", + "textRedaction", + "resourcesRedaction", + "distance" + }; + public static String[] WORD = { + "point", + "textStrikeout", + "polyline", + "textField", + "watermark", + "textReplacement", + "arrow", + "textRedaction", + "resourcesRedaction", + "textUnderline", + "distance", + "text" + }; + public static String[] PDF = { + "area", + "point", + "textStrikeout", + "polyline", + "textField", + "watermark", + "textReplacement", + "arrow", + "textRedaction", + "resourcesRedaction", + "textUnderline", + "distance", + "text" + }; + public static String[] IMAGE = { + "area", + "point", + "textStrikeout", + "polyline", + "textField", + "watermark", + "arrow", + "textRedaction", + "resourcesRedaction", + "textUnderline", + "distance", + "text" + }; + public static String[] SLIDES = { + "area", + "point", + "textStrikeout", + "polyline", + "textField", + "watermark", + "arrow", + "textRedaction", + "resourcesRedaction", + "textUnderline", + "text" + }; + + public static String[] getSupportedAnnotations(String documentType) { + switch (documentType) { + case "Adobe Portable Document format": + case "Portable Document Format": + case "PDF": + return PDF; + case "Microsoft Word Open XML format": + case "Microsoft Word": + case "WORDS": + return WORD; + case "Microsoft PowerPoint": + case "SLIDES": + return SLIDES; + case "image": + return IMAGE; + case "Microsoft Excel": + case "CELLS": + return CELLS; + case "AutoCAD Drawing File Format": + case "diagram": + return DIAGRAM; + default: + return PDF; + } + } +} diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/directory/DirectoryUtils.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/directory/DirectoryUtils.java new file mode 100644 index 0000000..6025fe0 --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/directory/DirectoryUtils.java @@ -0,0 +1,28 @@ +package com.groupdocs.ui.annotation.util.directory; + +import com.groupdocs.ui.annotation.config.AnnotationConfiguration; + +/** + * DirectoryUtils + * Compare and sort file types - folders first + * @author Aspose Pty Ltd + */ +public class DirectoryUtils { + private FilesDirectoryUtils filesDirectory; + + /** + * Constructor + * @param annotationConfiguration + */ + public DirectoryUtils(AnnotationConfiguration annotationConfiguration){ + filesDirectory = new FilesDirectoryUtils(annotationConfiguration); + } + + /** + * Get files directory - path where all documents for signing are stored + * @return FilesDirectoryUtils + */ + public FilesDirectoryUtils getFilesDirectory() { + return filesDirectory; + } +} diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/directory/FilesDirectoryUtils.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/directory/FilesDirectoryUtils.java new file mode 100644 index 0000000..160c080 --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/directory/FilesDirectoryUtils.java @@ -0,0 +1,30 @@ +package com.groupdocs.ui.annotation.util.directory; + +import com.groupdocs.ui.annotation.config.AnnotationConfiguration; + +/** + * FilesDirectoryUtils + * Compare and sort file types - folders first + * @author Aspose Pty Ltd + */ +public class FilesDirectoryUtils implements IDirectoryUtils { + private AnnotationConfiguration annotationConfiguration; + + /** + * Constructor + * @param annotationConfiguration + */ + public FilesDirectoryUtils(AnnotationConfiguration annotationConfiguration){ + this.annotationConfiguration = annotationConfiguration; + } + + /** + * Get path for files directory + * @return path of the files directory + */ + @Override + public String getPath() { + return annotationConfiguration.getFilesDirectory(); + } + +} diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/directory/IDirectoryUtils.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/directory/IDirectoryUtils.java new file mode 100644 index 0000000..3bfe9d9 --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/directory/IDirectoryUtils.java @@ -0,0 +1,11 @@ +package com.groupdocs.ui.annotation.util.directory; + +/** + * IDirectoryUtils + * Compare and sort file types - folders first + * @author Aspose Pty Ltd + */ +public interface IDirectoryUtils { + + String getPath(); +} diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/views/Annotation.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/views/Annotation.java new file mode 100644 index 0000000..d5452d8 --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/views/Annotation.java @@ -0,0 +1,43 @@ +package com.groupdocs.ui.annotation.views; + +import com.groupdocs.ui.common.config.GlobalConfiguration; +import io.dropwizard.views.View; + +import java.nio.charset.Charset; + +/** + * Annotation + * + * @author Aspose Pty Ltd + */ + +public class Annotation extends View { + private GlobalConfiguration globalConfiguration; + + /** + * Constructor + * @param globalConfiguration total configuration + * @param charset charset + */ + public Annotation(GlobalConfiguration globalConfiguration, String charset){ + super("annotation.ftl", Charset.forName(charset)); + this.globalConfiguration = globalConfiguration; + } + + /** + * Get total config + * @return total config + */ + public GlobalConfiguration getGlobalConfiguration() { + return globalConfiguration; + } + + /** + * Set total config + * @param globalConfiguration total config + */ + public void setGlobalConfiguration(GlobalConfiguration globalConfiguration) { + this.globalConfiguration = globalConfiguration; + } + +} diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/MainService.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/MainService.java new file mode 100644 index 0000000..76f92d6 --- /dev/null +++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/MainService.java @@ -0,0 +1,107 @@ +package com.groupdocs.ui.common; + +import com.google.common.collect.Sets; +import com.groupdocs.ui.annotation.resources.AnnotationResources; +import com.groupdocs.ui.common.config.GlobalConfiguration; +import com.groupdocs.ui.common.exception.TotalGroupDocsExceptionMapper; +import com.groupdocs.ui.common.health.TemplateHealthCheck; +import io.dropwizard.Application; +import io.dropwizard.assets.AssetsBundle; +import io.dropwizard.configuration.ResourceConfigurationSourceProvider; +import io.dropwizard.forms.MultiPartBundle; +import io.dropwizard.setup.Bootstrap; +import io.dropwizard.setup.Environment; +import io.dropwizard.views.ViewBundle; +import org.apache.commons.lang3.StringUtils; +import org.eclipse.jetty.servlets.CrossOriginFilter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.DispatcherType; +import javax.servlet.FilterRegistration; +import java.io.File; +import java.util.EnumSet; +import java.util.HashSet; + +/** + * Main class + * Where all the magic starts + * + * @author Aspose Pty Ltd + */ + +public class MainService extends Application