Commit dceec110 authored by Ate Douma's avatar Ate Douma

TRIVIAL cleanup master

parent a8f60f62
/*.iml
/.idea
/target
This diff is collapsed.
Hippo Plugin Gallery Picker
Copyright 2008-2018 Hippo B.V. (http://www.onehippo.com)
This product includes software developed by:
Hippo B.V., Amsterdam, The Netherlands (http://www.onehippo.com/);
The Apache Software Foundation (http://www.apache.org/).
NOTICE: Only our own original work is licensed under the terms of the
Apache License Version 2.0. The licenses of some libraries might impose
different redistribution or general licensing terms than those stated in the
Apache License. Users and redistributors are hereby requested to verify these
conditions and agree upon them.
# This is not the branch you're looking for...
BloomReach only provides the git trees for the release tags of Hippo CMS, as explained on https://www.onehippo.org/about/open-source-release-policy.html
To checkout the code for a specific release tag, after cloning this repository, use the following:
## to show the available tags
git tag
## to checkout a specific tag
git checkout <tag name>
## to modify a project
If you want to make modifications to a project, for example to create a patch, create a new fork branch from the specific tag like this:
git checkout -b forked-<tag name> <tag name>
For the latter, also see the **Build from Source** documentation at https://www.onehippo.org/library/development/build-hippo-cms-from-scratch.html
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2008-2018 Hippo B.V. (http://www.onehippo.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms7-project</artifactId>
<version>29.4-SNAPSHOT</version>
</parent>
<name>Hippo Plugin Gallery Picker</name>
<description>Hippo Plugin Gallery Picker</description>
<artifactId>hippo-plugin-gallerypicker</artifactId>
<packaging>jar</packaging>
<version>4.3.0-SNAPSHOT</version>
<inceptionYear>2008</inceptionYear>
<scm>
<connection>scm:git:https://code.onehippo.org/cms-community/hippo-plugin-gallerypicker.git</connection>
<developerConnection>scm:git:git@code.onehippo.org:cms-community/hippo-plugin-gallerypicker.git</developerConnection>
<url>https://code.onehippo.org/cms-community/hippo-plugin-gallerypicker</url>
</scm>
<properties>
<hippo.repository.version>5.3.0-SNAPSHOT</hippo.repository.version>
<hippo.cms.version>5.3.0-SNAPSHOT</hippo.cms.version>
<junit.version>4.12</junit.version>
<!-- Make sure that easymock and powermock are compatible -->
<easymock.version>3.4</easymock.version>
<powermock.version>1.6.5</powermock.version>
</properties>
<repositories>
<repository>
<id>hippo</id>
<name>Hippo Maven 2</name>
<url>https://maven.onehippo.com/maven2/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</repository>
</repositories>
<issueManagement>
<system>Jira</system>
<url>https://issues.onehippo.com/browse/HIPPLUG/component/10855</url>
</issueManagement>
<dependencies>
<!-- These dependencies are needed by normal front-end plugins, but should be flagged differenty -->
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-api</artifactId>
<version>${hippo.repository.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-engine</artifactId>
<version>${hippo.cms.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-editor-frontend</artifactId>
<version>${hippo.cms.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-gallery-frontend</artifactId>
<version>${hippo.cms.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-builtin</artifactId>
<version>${hippo.repository.version}</version>
<scope>provided</scope>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>${easymock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>package</defaultGoal>
<resources>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.html</include>
<include>**/*.png</include>
<include>**/*.gif</include>
</includes>
</resource>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/*.css</include>
<include>**/*.cnd</include>
<include>**/*.yaml</include>
<include>**/*.xml</include>
<include>**/*.json</include>
</includes>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>pedantic</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
<inherited>false</inherited>
<configuration>
<excludes combine.children="append">
<!-- ignore repository content XML -->
<exclude>src/main/resources/*.xml</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
/*
* Copyright 2017 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.addon.frontend.gallerypicker;
public interface GalleryPickerNodeType {
String NT_IMAGE_LINK = "hippogallerypicker:imagelink";
}
<!--
* Copyright 2008-2015 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<html xmlns:wicket="http://wicket.apache.org/">
<wicket:panel>
<wicket:container wicket:id="fragment"/>
</wicket:panel>
<wicket:fragment wicket:id="edit">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<img wicket:id="previewImage"/>
</td>
<td class="gallerypickerbuttons">
<a class="btn btn-default btn-sm" wicket:id="select">
<span class="button-label"><wicket:message key="picker.select">[Select]</wicket:message></span>
</a>
<a class="btn btn-default btn-sm" wicket:id="open">
<span class="button-label"><wicket:message key="picker.open">[Open]</wicket:message></span>
</a>
<a class="btn btn-default btn-sm" href="#" wicket:id="remove">
<span class="button-label"><wicket:message key="picker.remove">[Clear]</wicket:message></span>
</a>
</td>
</tr>
</table>
</wicket:fragment>
<wicket:fragment wicket:id="view">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<img wicket:id="previewImage"/>
</td>
</tr>
</table>
</wicket:fragment>
<wicket:fragment wicket:id="compare">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="hippo-gallery-removed">
<img wicket:id="baseImage"/>
</td>
<td class="hippo-gallery-added">
<img wicket:id="previewImage"/>
</td>
</tr>
</table>
</wicket:fragment>
</html>
/*
* Copyright 2008-2017 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.addon.frontend.gallerypicker;
import java.io.Serializable;
import javax.jcr.Item;
import javax.jcr.ItemNotFoundException;
import javax.jcr.Node;
import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
import org.apache.commons.lang.StringUtils;
import org.hippoecm.frontend.model.JcrHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Class management by the factory ImageItemFactory. You should not instantiate this class.
* <p/>
* The ImageItem is used to obtain the location of an image in the repository. It also gives the url of the
* default image if the provided uuid is not correct or does not exist.
*/
public class ImageItem implements Serializable {
private static final Logger log = LoggerFactory.getLogger(ImageItem.class);
public static final String BASE_PATH_BINARIES = "binaries";
public static final String BASE_IMAGES_PATH = "gallery";
private String uuid;
ImageItem() {
this(null);
}
ImageItem(String uuid) {
this.uuid = uuid;
}
public String getUuid() {
return uuid;
}
/**
* Obtains the primary url of a node identified by it's uuid. If the uuid was not provided,
* or if something goes horribly wrong, the default image path is returned.
* <p/>
* Beware that no check is done if the uuid actually belongs to an image node. Also is assumed
* that the uuid is of a node of type handle.
*
* @return String containing the url of the requested image, if no image is specified return an empty String.
*/
public String getPrimaryUrl() {
return getPrimaryUrl(WicketJcrSessionProvider.get());
}
public String getPrimaryUrl(final JcrSessionProvider sessionProvider) {
if (StringUtils.isNotEmpty(uuid)) {
Node handle;
Item item;
String path = "";
try {
handle = sessionProvider.getJcrSession().getNodeByIdentifier(uuid);
path = handle.getName();
if (!"".equals(path) && !"/".equals(path) && !BASE_IMAGES_PATH.equals(path)) {
Node document = handle.getNode(path);
item = JcrHelper.getPrimaryItem(document);
return BASE_PATH_BINARIES + item.getPath();
}
} catch (ItemNotFoundException e) {
log.warn("Unable to find item: {} : {} ", uuid, e);
} catch (PathNotFoundException e) {
log.warn("Uuid: {} exists, but path '{}' cannot be found", new Object[]{uuid, path}, e);
} catch (RepositoryException e) {
log.warn("Error while trying to get primary url for: {}", uuid, e);
}
}
return "";
}
public boolean isValid() {
return uuid != null;
}
}
\ No newline at end of file
/*
* Copyright 2008-2017 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.addon.frontend.gallerypicker;
import java.io.Serializable;
/**
* Factory class for {@link ImageItem} objects.
*/
public class ImageItemFactory implements Serializable {
public ImageItem createImageItem() {
return new ImageItem();
}
public ImageItem createImageItem(String uuid) {
return new ImageItem(uuid);
}
}
/*
* Copyright 2013 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.addon.frontend.gallerypicker;
import java.util.HashSet;
import java.util.Set;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import org.apache.wicket.model.IModel;
import org.hippoecm.frontend.editor.validator.plugins.AbstractCmsValidator;
import org.hippoecm.frontend.model.JcrNodeModel;
import org.hippoecm.frontend.plugin.IPluginContext;
import org.hippoecm.frontend.plugin.config.IPluginConfig;
import org.hippoecm.frontend.validation.IFieldValidator;
import org.hippoecm.frontend.validation.ValidationException;
import org.hippoecm.frontend.validation.Violation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Validator for checking mandatory links to images.
*
* It checks the link's reference (a node identifier) for not being set at all or being set to root node '/' or to node
* '/content/gallery'.
*/
public class ImageReferenceValidator extends AbstractCmsValidator {
static final Logger log = LoggerFactory.getLogger(ImageReferenceValidator.class);
public ImageReferenceValidator(IPluginContext context, IPluginConfig config) {
super(context, config);
}
@Override
public void preValidation(final IFieldValidator type) throws ValidationException {
// do nothing
}
@Override
public Set<Violation> validate(final IFieldValidator fieldValidator, final JcrNodeModel model, final IModel childModel) throws ValidationException {
final Set<Violation> violations = new HashSet<Violation>();
try {
final Object object = childModel.getObject();
final String ref;
if (object instanceof Node && ((Node)object).hasProperty("hippo:docbase")) {
ref = ((Node)object).getProperty("hippo:docbase").getString();
} else if (object instanceof String) {
ref = (String)object;
} else {
return violations;
}
final String contentGalleryIdentifier = model.getNode().getSession().nodeExists("/content/gallery") ?
model.getNode().getSession().getNode("/content/gallery").getIdentifier() : null;
if (ref == null || ref.equals("")
|| ref.equals("cafebabe-cafe-babe-cafe-babecafebabe")
|| ref.equals(contentGalleryIdentifier)) {
violations.add(fieldValidator.newValueViolation(childModel, "reference-is-empty"));
}
} catch (RepositoryException repositoryException) {
log.error("Error validating image reference field: " + fieldValidator.getFieldDescriptor(), repositoryException);
}
return violations;
}
}
/*
* Copyright 2008-2013 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.addon.frontend.gallerypicker;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebComponent;
import org.apache.wicket.model.IModel;
public class InlinePreviewImage extends WebComponent {
@SuppressWarnings("unused")
private final static String SVN_ID = "$Id$";
private static final long serialVersionUID = 1L;
private String width;
private String height;
public InlinePreviewImage(String id, IModel<String> model, String width, String height) {
super(id, model);
this.width = width;
this.height = height;
}
@Override
protected void onComponentTag(ComponentTag tag) {
checkComponentTag(tag, "img");
super.onComponentTag(tag);
if (width != null)
tag.put("width", width);
if (height != null)
tag.put("height", height);
tag.put("src", (String) getDefaultModelObject());
}
}
/*
* Copyright 2017 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.addon.frontend.gallerypicker;
import javax.jcr.Session;
/**
* Provides a JCR session.
*/
public interface JcrSessionProvider {
Session getJcrSession();
}
/*
* Copyright 2017 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.addon.frontend.gallerypicker;
import javax.jcr.Session;
import org.hippoecm.frontend.session.UserSession;
/**
* Provides the JCR session for the current Wicket user session.
*/
public class WicketJcrSessionProvider implements JcrSessionProvider {
private static final WicketJcrSessionProvider INSTANCE = new WicketJcrSessionProvider();
private WicketJcrSessionProvider() {
}
public static WicketJcrSessionProvider get() {
return INSTANCE;
}
@Override
public Session getJcrSession() {
return ((UserSession) org.apache.wicket.Session.get()).getJcrSession();
}
}
<!--
* Copyright 2007-2015 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<html xmlns:wicket="http://wicket.apache.org/">
<wicket:extend>
<wicket:fragment wicket:id="upload-fragment">
<div wicket:id="upload-panel">[Upload form panel]</div>
</wicket:fragment>
</wicket:extend>
</html>
/*
* Copyright 2011-2015 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.addon.frontend.gallerypicker.dialog;
import javax.jcr.Node;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.feedback.ContainerFeedbackMessageFilter;
import org.apache.wicket.markup.html.form.upload.FileUpload;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.cycle.RequestCycle;
import org.hippoecm.frontend.editor.plugins.linkpicker.GalleryUploadPanel;
import org.hippoecm.frontend.editor.plugins.linkpicker.LinkPickerDialog;
import org.hippoecm.frontend.plugin.IPluginContext;
import org.hippoecm.frontend.plugin.config.IPluginConfig;