Skip to content
Snippets Groups Projects
Commit aaec8474 authored by Marius Dumitru Florea's avatar Marius Dumitru Florea
Browse files

Merge branch 'master' of github.com:xwiki/xwiki-platform

parents 21b45f87 3a05a50e
No related branches found
No related tags found
No related merge requests found
......@@ -30,8 +30,7 @@ def builds = [
name: 'Main',
profiles: 'legacy,integration-tests,snapshot',
properties:
'-Dxwiki.checkstyle.skip=true -Dxwiki.surefire.captureconsole.skip=true -Dxwiki.revapi.skip=true -DskipITs',
daysToKeepStr: env.BRANCH_NAME == 'master' ? '30' : null
'-Dxwiki.checkstyle.skip=true -Dxwiki.surefire.captureconsole.skip=true -Dxwiki.revapi.skip=true -DskipITs'
)
},
// Can be used to manually trigger the main build with integration tests on the CI.
......@@ -40,8 +39,7 @@ def builds = [
name: 'Main with Integration Tests',
profiles: 'legacy,integration-tests,snapshot',
properties:
'-Dxwiki.checkstyle.skip=true -Dxwiki.surefire.captureconsole.skip=true -Dxwiki.revapi.skip=true',
daysToKeepStr: env.BRANCH_NAME == 'master' ? '30' : null
'-Dxwiki.checkstyle.skip=true -Dxwiki.surefire.captureconsole.skip=true -Dxwiki.revapi.skip=true'
)
},
'Distribution' : {
......@@ -68,7 +66,6 @@ def builds = [
buildFunctionalTest(
name: 'Flavor Test - UI',
pom: 'xwiki-platform-distribution-flavor-test-ui/pom.xml',
daysToKeepStr: env.BRANCH_NAME == 'master' ? '30' : null
)
},
'Flavor Test - Misc' : {
......@@ -124,7 +121,7 @@ def builds = [
goals: 'clean install jacoco:report sonar:sonar',
profiles: 'quality,legacy,coverage',
properties: '-Dxwiki.jacoco.itDestFile=`pwd`/target/jacoco-it.exec',
sonar: true,
sonar: true
)
}
]
......@@ -353,9 +350,9 @@ private void buildInsideNode(map)
if (map.properties != null) {
properties = map.properties
}
if (map.daysToKeepStr != null) {
daysToKeepStr = map.daysToKeepStr
}
// Keep builds for 30 days since we want to be able to see all builds if there are a lot at a given time, to be
// able to identify flickers, etc.
daysToKeepStr = '30'
if (map.pom != null) {
pom = map.pom
}
......
......@@ -90,7 +90,6 @@
<build>
<plugins>
<plugin>
<!-- Apply the Checkstyle configurations defined in the top level pom.xml file -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
......@@ -98,9 +97,7 @@
<!-- Specify the "default" execution id so that the "blocker" one is always executed -->
<id>default</id>
<configuration>
<excludes>
org/xwiki/office/viewer/internal/DefaultOfficeResourceViewer.java
</excludes>
<suppressionsLocation>${basedir}/src/main/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
</configuration>
</execution>
</executions>
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.0//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
<suppressions>
<suppress checks="ClassFanOutComplexity" files="DefaultOfficeResourceViewer.java"/>
</suppressions>
......@@ -191,17 +191,15 @@ public class DefaultOfficeResourceViewer implements OfficeResourceViewer, Initia
* @param artifactFiles specify which of the image blocks should be processed; only the image blocks
* that were generated during the office import process should be processed
* @param ownerDocumentReference specifies the document that owns the office file
* @param resourceReference a reference to the office file that is being viewed; this reference is used to compute
* the path to the temporary directory holding the image artifacts
* @param parameters the build parameters. Note that currently only {@code filterStyles} is supported and if "true"
* it means that styles will be filtered to the maximum and the focus will be put on importing only the
* @return the set of temporary files corresponding to image artifacts
*/
private Set<File> processImages(XDOM xdom, Set<File> artifactFiles, DocumentReference ownerDocumentReference,
String resourceReference, Map<String, ?> parameters)
Map<String, ?> parameters)
{
// Process all image blocks.
Set<File> temporaryFiles = new HashSet<File>();
Set<File> temporaryFiles = new HashSet<>();
List<ImageBlock> imgBlocks = xdom.getBlocks(new ClassBlockMatcher(ImageBlock.class), Block.Axes.DESCENDANT);
if (!imgBlocks.isEmpty()) {
Map<String, File> fileMap = new HashMap<>();
......@@ -238,8 +236,9 @@ private Set<File> processImages(XDOM xdom, Set<File> artifactFiles, DocumentRefe
Block newImgBlock = new ImageBlock(urlImageReference, false, imgBlock.getParameters());
imgBlock.getParent().replaceChild(Arrays.asList(newImgBlock), imgBlock);
// Make sure the new image block is not inside an ExpandedMacroBlock whose's content syntax doesn't
// support relative path resource references (we use relative paths to refer the temporary files).
// Make sure the new image block is not inside an ExpandedMacroBlock whose's content syntax
// doesn't support relative path resource references (we use relative paths to refer the
// temporary files).
maybeFixExpandedMacroAncestor(newImgBlock);
// Collect the temporary file so that it can be cleaned up when the view is disposed from cache.
......@@ -261,7 +260,7 @@ private void maybeFixExpandedMacroAncestor(Block block)
if (expandedMacro != null) {
Block parent = expandedMacro.getParent();
if (!(parent instanceof MetaDataBlock) || !((MetaDataBlock) parent).getMetaData().contains(MODULE_NAME)) {
MetaDataBlock metaData = new MetaDataBlock(Collections.<Block>emptyList());
MetaDataBlock metaData = new MetaDataBlock(Collections.emptyList());
// Use a syntax that supports relative path resource references (we use relative paths to include the
// temporary files).
metaData.getMetaData().addMetaData(MetaData.SYNTAX, Syntax.XWIKI_2_1);
......@@ -378,8 +377,9 @@ private OfficeDocumentView getView(ResourceReference reference, AttachmentRefere
// It's possible that the attachment has been deleted. We need to catch such events and cleanup the cache.
DocumentReference documentReference = attachmentReference.getDocumentReference();
if (!this.documentAccessBridge.getAttachmentReferences(documentReference).contains(attachmentReference) &&
!uploadedAttachment.isPresent()) {
if (!this.documentAccessBridge.getAttachmentReferences(documentReference).contains(attachmentReference)
&& !uploadedAttachment.isPresent())
{
// If a cached view exists, flush it.
if (view != null) {
this.attachmentCache.remove(cacheKey);
......@@ -403,12 +403,12 @@ private OfficeDocumentView getView(ResourceReference reference, AttachmentRefere
attachmentVersion = "temp";
}
XDOM xdom = xdomOfficeDocument.getContentDocument();
// We use only the file name from the resource reference because the rest of the information is specified by
// the owner document reference. This way we ensure the path to the temporary files doesn't contain
// redundant information and so it remains as small as possible (considering that the path length is limited
// on some environments).
// We use only the file name from the resource reference because the rest of the information is
// specified by the owner document reference. This way we ensure the path to the temporary files
// doesn't contain redundant information and so it remains as small as possible (considering that the
// path length is limited on some environments).
Set<File> temporaryFiles = processImages(xdom, xdomOfficeDocument.getArtifactsFiles(),
attachmentReference.getDocumentReference(), attachmentReference.getName(), parameters);
attachmentReference.getDocumentReference(), parameters);
view = new AttachmentOfficeDocumentView(reference, attachmentReference, attachmentVersion, xdom,
temporaryFiles);
......@@ -436,7 +436,7 @@ private OfficeDocumentView getView(ResourceReference resourceReference, Map<Stri
{
XDOM xdom = xdomOfficeDocument.getContentDocument();
Set<File> temporaryFiles = processImages(xdom, xdomOfficeDocument.getArtifactsFiles(), ownerDocument,
serializedResourceReference, parameters);
parameters);
view = new OfficeDocumentView(resourceReference, xdom, temporaryFiles);
this.externalCache.set(cacheKey, view);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment