Commit 437938b5 authored by Ard Schrijvers's avatar Ard Schrijvers

CMS7-8719 rename web resources to web files

parent 97307ed3
......@@ -7,6 +7,6 @@ src/main/java/org/onehippo/cms7/services/autoreload/AutoReloadService.java -text
src/main/java/org/onehippo/cms7/services/eventbus/HippoEventListener.java -text svneol=unset#text/plain
src/main/java/org/onehippo/cms7/services/eventbus/Subscribe.java -text
src/main/java/org/onehippo/cms7/services/googleanalytics/GoogleAnalyticsService.java -text
src/main/java/org/onehippo/cms7/services/webresources/WebResource.java -text
src/main/java/org/onehippo/cms7/services/webresources/WebResourceEvent.java -text
src/main/java/org/onehippo/cms7/services/webresources/WebResourcesService.java -text
src/main/java/org/onehippo/cms7/services/webfiles/WebFile.java -text
src/main/java/org/onehippo/cms7/services/webfiles/WebFileEvent.java -text
src/main/java/org/onehippo/cms7/services/webfiles/WebFilesService.java -text
......@@ -16,16 +16,8 @@
package org.onehippo.cms7.services.autoreload;
import java.io.File;
import java.io.IOException;
import java.util.zip.ZipFile;
import javax.jcr.Session;
import org.onehippo.cms7.services.SingletonService;
import org.onehippo.cms7.services.WhiteboardService;
import org.onehippo.cms7.services.webresources.WebResourceBundle;
import org.onehippo.cms7.services.webresources.WebResourceException;
/**
* Automatically reloads the current page in connected browsers. If auto-reload is disabled, nothing happens when
......
/*
* Copyright 2014 Hippo B.V. (http://www.onehippo.com)
* Copyright 2014-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.
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.cms7.services.webresources;
package org.onehippo.cms7.services.webfiles;
import java.io.InputStream;
......@@ -29,14 +29,14 @@ public interface Binary {
*
* @return A stream representation of this binary.
* @throws java.lang.IllegalStateException if {@link #dispose()} has already been called.
* @throws WebResourceException if another error occurs.
* @throws WebFileException if another error occurs.
*/
InputStream getStream();
/**
* @return the size of this binary in bytes.
* @throws java.lang.IllegalStateException if {@link #dispose()} has already been called.
* @throws WebResourceException if another error occurs.
* @throws WebFileException if another error occurs.
*/
long getSize();
......
/*
* Copyright 2014 Hippo B.V. (http://www.onehippo.com)
* Copyright 2014-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.
......@@ -13,26 +13,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.cms7.services.webresources;
package org.onehippo.cms7.services.webfiles;
import java.util.Calendar;
/**
* A web resource contains binary data that can be revisioned. There is always a current working version of the content.
* A {@link WebFile} contains binary data that can be revisioned. There is always a current working version of the content.
* There can be zero or more revisions of the content. Each revision is identified by an ID that is unique within
* the revision history of this web resource.
* the revision history of this {@link WebFile}.
*/
public interface WebResource {
public interface WebFile {
/**
* @return the absolute path to this web resource, starting at web resources root.
* @return the absolute path to this {@link WebFile}, starting at the {@link WebFile}s root.
* The path always starts with a slash, and the path elements are also separated by slashes.
*/
String getPath();
/**
* @return the name of this web resource, i.e. the last element of the path.
* @return the name of this {@link WebFile}, i.e. the last element of the path.
*/
String getName();
......
/*
* Copyright 2014 Hippo B.V. (http://www.onehippo.com)
* Copyright 2014-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.
......@@ -13,90 +13,90 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.cms7.services.webresources;
package org.onehippo.cms7.services.webfiles;
import java.util.List;
/**
* A collection of web resources, i.e. binary data objects. Each web resource is identified by an absolute path
* starting at the web resources root. Paths start with a slash and consist of elements separated by slashes
* A collection of {@link WebFile}s, i.e. binary data objects. Each {@link WebFile} is identified by an absolute path
* starting at the {@link WebFile}s root. Paths start with a slash and consist of elements separated by slashes
* (e.g. "/css/style.css").
*/
public interface WebResourceBundle {
public interface WebFileBundle {
/**
* @param absPath the absolute path to the web resource, starting at the web resources root. The path must start with a slash.
* @return whether a web resource exists at the given path.
* @param absPath the absolute path to the {@link WebFile}, starting at the {@link WebFile}s root. The path must start with a slash.
* @return whether a {@link WebFile} exists at the given path.
*/
boolean exists(String absPath);
/**
* @param absPath the absolute path starting with a slash to the web resource, relative to this {@link WebResourceBundle}
* @return the web resource <b>head</b> located at the given path.
* @throws WebResourceNotFoundException if no web resource exists at the given path.
* @param absPath the absolute path starting with a slash to the {@link WebFile}, relative to this {@link WebFileBundle}
* @return the {@link WebFile} <b>head</b> located at the given path.
* @throws WebFileNotFoundException if no {@link WebFile} exists at the given path.
*/
WebResource get(String absPath) throws WebResourceNotFoundException;
WebFile get(String absPath) throws WebFileNotFoundException;
/**
* Creates a new web resource at the given location.
* @param absPath the absolute path starting with a slash to the web resource, relative to this {@link WebResourceBundle}
* @param content the content of the new web resource.
* @return the created web resource.
* @throws WebResourceException if another (web) resource already exists at the given location.
* Creates a new {@link WebFile} at the given location.
* @param absPath the absolute path starting with a slash to the {@link WebFile}, relative to this {@link WebFileBundle}
* @param content the content of the new {@link WebFile}.
* @return the created {@link WebFile}.
* @throws WebFileException if another (web) resource already exists at the given location.
* @throws java.lang.IllegalArgumentException if the given binary is <code>null</code>.
* @throws WebResourceException in case of insufficient authorization
* @throws WebFileException in case of insufficient authorization
*/
WebResource create(String absPath, Binary content) throws WebResourceException, IllegalArgumentException;
WebFile create(String absPath, Binary content) throws WebFileException, IllegalArgumentException;
/**
* Updates the content of this web resource.
* @param absPath the absolute path starting with a slash to the web resource, relative to this {@link WebResourceBundle}
* Updates the content of this {@link WebFile}.
* @param absPath the absolute path starting with a slash to the {@link WebFile}, relative to this {@link WebFileBundle}
* @param content the binary data to store.
* @return the updated {@link WebResource}
* @throws WebResourceNotFoundException if no web resource exists at the given path.
* @return the updated {@link WebFile}
* @throws WebFileNotFoundException if no {@link WebFile} exists at the given path.
* @throws java.lang.IllegalArgumentException if the given binary is <code>null</code>.
* @throws WebResourceException in case of insufficient authorization
* @throws WebFileException in case of insufficient authorization
*/
WebResource update(String absPath, Binary content) throws WebResourceNotFoundException, IllegalArgumentException;
WebFile update(String absPath, Binary content) throws WebFileNotFoundException, IllegalArgumentException;
/**
* Removes the web resource at absPath
* @param absPath the absolute path starting with a slash to the web resource, relative to this {@link WebResourceBundle}
* @throws WebResourceException in case the delete did not occur, for example because the resource is not there any more,
* Removes the {@link WebFile} at absPath
* @param absPath the absolute path starting with a slash to the {@link WebFile}, relative to this {@link WebFileBundle}
* @throws WebFileException in case the delete did not occur, for example because the resource is not there any more,
* insufficient authorization, locking, etc
*/
void delete(String absPath) throws WebResourceException;
void delete(String absPath) throws WebFileException;
/**e
* @return the latest tagName or in case not yet tagged or tagging is not supported, return <code>null</code>
*/
String getLatestTagName() throws WebResourceException;
String getLatestTagName() throws WebFileException;
/**
* @return The immutable {@link java.util.List} ordered list of tag names for this {@link WebResourceBundle} or empty List in case
* there are no tags for this {@link WebResourceBundle} or tagging is not supported (for this {@link WebResourceBundle})
* @return The immutable {@link java.util.List} ordered list of tag names for this {@link WebFileBundle} or empty List in case
* there are no tags for this {@link WebFileBundle} or tagging is not supported (for this {@link WebFileBundle})
*/
List<String> getTagNames() throws WebResourceException;
List<String> getTagNames() throws WebFileException;
/**
* @param absPath the absolute path to the web resource, starting at the web resources root. The path must start
* @param absPath the absolute path to the {@link WebFile}, starting at the {@link WebFile}s root. The path must start
* with a slash when not <code>null</code>.
* @param tagName the {@link WebResource} for tagName. When <code>tagName</code> is null, the head
* {@link org.onehippo.cms7.services.webresources.WebResource} is returned, the same as {@link #get(String)}
* @return the web resource <b>tag</b> located at the given path for <code>tagName</code>.
* @throws WebResourceNotFoundException if no web resource exists at the given path for <code>tagName</code>.
* @param tagName the {@link WebFile} for tagName. When <code>tagName</code> is null, the head
* {@link WebFile} is returned, the same as {@link #get(String)}
* @return the {@link WebFile} <b>tag</b> located at the given path for <code>tagName</code>.
* @throws WebFileNotFoundException if no {@link WebFile} exists at the given path for <code>tagName</code>.
*/
WebResource get(String absPath, String tagName) throws WebResourceNotFoundException, WebResourceTagNotFoundException;
WebFile get(String absPath, String tagName) throws WebFileNotFoundException, WebFileTagNotFoundException;
/**
* Creates a new tag for this entire {@link WebResourceBundle}
* Creates a new tag for this entire {@link WebFileBundle}
* @return the name of the newly created tag
* @throws WebResourceException
* @throws WebFileException
*/
String createTag() throws WebResourceException;
String createTag() throws WebFileException;
/**
* @return the anti-cache value of this {@link WebResourceBundle}, useful to be able to cache resources in the
* @return the anti-cache value of this {@link WebFileBundle}, useful to be able to cache resources in the
* client (browser) : Whenever the client needs new resources, the anti cache value changes resulting in different
* URLs for the resources. Only chars allowed are [a-z] and [0-9] to avoid encoding/decoding problems when used in
* URLs
......
/*
* Copyright 2014 Hippo B.V. (http://www.onehippo.com)
* Copyright 2014-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.
......@@ -13,17 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.cms7.services.webresources;
package org.onehippo.cms7.services.webfiles;
import java.nio.file.Path;
@SuppressWarnings("ALL")
public class WebResourceEvent {
public class WebFileEvent {
private final Path changedPath;
private final Path watchedRootDir;
public WebResourceEvent(final Path changedPath, final Path watchedRootDir) {
public WebFileEvent(final Path changedPath, final Path watchedRootDir) {
this.changedPath = changedPath;
this.watchedRootDir = watchedRootDir;
}
......
/*
* Copyright 2014 Hippo B.V. (http://www.onehippo.com)
* Copyright 2014-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.
......@@ -13,26 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.cms7.services.webresources;
package org.onehippo.cms7.services.webfiles;
/**
* TODO: write Javadoc
*/
public class WebResourceException extends RuntimeException {
public class WebFileException extends RuntimeException {
public WebResourceException() {
public WebFileException() {
super();
}
public WebResourceException(final String message) {
public WebFileException(final String message) {
super(message);
}
public WebResourceException(final String message, final Throwable cause) {
public WebFileException(final String message, final Throwable cause) {
super(message, cause);
}
public WebResourceException(final Throwable cause) {
public WebFileException(final Throwable cause) {
super(cause);
}
}
/*
* Copyright 2014 Hippo B.V. (http://www.onehippo.com)
* Copyright 2014-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.
......@@ -13,26 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.cms7.services.webresources;
package org.onehippo.cms7.services.webfiles;
/**
* TODO: write Javadoc
*/
public class WebResourceNotFoundException extends WebResourceException {
public class WebFileNotFoundException extends WebFileException {
public WebResourceNotFoundException() {
public WebFileNotFoundException() {
super();
}
public WebResourceNotFoundException(final String message) {
public WebFileNotFoundException(final String message) {
super(message);
}
public WebResourceNotFoundException(final String message, final Throwable cause) {
public WebFileNotFoundException(final String message, final Throwable cause) {
super(message, cause);
}
public WebResourceNotFoundException(final Throwable cause) {
public WebFileNotFoundException(final Throwable cause) {
super(cause);
}
}
/*
* Copyright 2014 Hippo B.V. (http://www.onehippo.com)
* Copyright 2014-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.
......@@ -13,26 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onehippo.cms7.services.webresources;
package org.onehippo.cms7.services.webfiles;
/**
* TODO: write Javadoc
*/
public class WebResourceTagNotFoundException extends WebResourceException {
public class WebFileTagNotFoundException extends WebFileException {
public WebResourceTagNotFoundException() {
public WebFileTagNotFoundException() {
super();
}
public WebResourceTagNotFoundException(final String message) {
public WebFileTagNotFoundException(final String message) {
super(message);
}
public WebResourceTagNotFoundException(final String message, final Throwable cause) {
public WebFileTagNotFoundException(final String message, final Throwable cause) {
super(message, cause);
}
public WebResourceTagNotFoundException(final Throwable cause) {
public WebFileTagNotFoundException(final Throwable cause) {
super(cause);
}
}
/*
* Copyright 2014 Hippo B.V. (http://www.onehippo.com)
* Copyright 2014-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.
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.onehippo.cms7.services.webresources;
package org.onehippo.cms7.services.webfiles;
import java.io.File;
import java.io.IOException;
......@@ -28,55 +28,55 @@ import org.onehippo.cms7.services.WhiteboardService;
@SingletonService
@WhiteboardService
@SuppressWarnings("UnusedDeclaration")
public interface WebResourcesService {
public interface WebFilesService {
public static final String JCR_ROOT_PATH = "/webresources";
public static final String JCR_ROOT_PATH = "/webfiles";
/**
* Creates a web resources implementation based on JCR.
* Creates a web files implementation based on JCR.
*
* @param session the JCR session used to access web resources.
* @param bundleName the name of the web resources bundle.
* @return a JCR-based web resources implementation for <code>bundleName</code>.
* @throw WebResourceException if the {@link WebResourceBundle} for <code>bundleName</code> cannot be found
* @param session the JCR session used to access web files.
* @param bundleName the name of the web files bundle.
* @return a JCR-based web files implementation for <code>bundleName</code>.
* @throw WebFileException if the {@link WebFileBundle} for <code>bundleName</code> cannot be found
*/
WebResourceBundle getJcrWebResourceBundle(Session session, String bundleName) throws WebResourceException;
WebFileBundle getJcrWebFileBundle(Session session, String bundleName) throws WebFileException;
/**
* Imports a web resource bundle from a directory. The name of the directory is used as the name of the bundle.
* Existing web resources in JCR are replaced by the new ones. Missing web resources are deleted from JCR.
* Imports a web file bundle from a directory. The name of the directory is used as the name of the bundle.
* Existing web files in JCR are replaced by the new ones. Missing web files are deleted from JCR.
* The caller of this method is responsible for saving the changes made in the session.
*
* @param session the JCR session used to access web resources.
* @param directory the directory containing the web resources to import.
* @throws IOException if an I/O error occurs while reading web resources from file system
* @throws WebResourceException if another error occurs while importing web resources
* @param session the JCR session used to access web files.
* @param directory the directory containing the web files to import.
* @throws IOException if an I/O error occurs while reading web files from file system
* @throws WebFileException if another error occurs while importing web files
*/
void importJcrWebResourceBundle(Session session, File directory) throws IOException, WebResourceException;
void importJcrWebFileBundle(Session session, File directory) throws IOException, WebFileException;
/**
* Imports a web resource bundle from the given zip file. The zip file should contain a single root directory entry
* that contains all web resources. The name of the root directory entry is used as the name of the bundle.
* Existing web resources in JCR are replaced by the new ones. Missing web resources are deleted from JCR.
* Imports a web file bundle from the given zip file. The zip file should contain a single root directory entry
* that contains all web files. The name of the root directory entry is used as the name of the bundle.
* Existing web files in JCR are replaced by the new ones. Missing web files are deleted from JCR.
* The caller of this method is responsible for saving the changes made in the session.
*
* @param session the JCR session used to access web resources.
* @param zip the ZIP file containing the web resources to import.
* @throws IOException if an I/O error occurs while reading web resources from the ZIP file
* @throws WebResourceException if another error occurs while importing web resources
* @param session the JCR session used to access web files.
* @param zip the ZIP file containing the web files to import.
* @throws IOException if an I/O error occurs while reading web files from the ZIP file
* @throws WebFileException if another error occurs while importing web files
*/
void importJcrWebResourceBundle(Session session, ZipFile zip) throws IOException, WebResourceException;
void importJcrWebFileBundle(Session session, ZipFile zip) throws IOException, WebFileException;
/**
* Imports a sub-tree of a web resource bundle from a directory. The sub-tree can consist of a directory or
* Imports a sub-tree of a web file bundle from a directory. The sub-tree can consist of a directory or
* a single file. The caller of this method is responsible for saving the changes made in the session.
*
* @param session the JCR session used to access web resources.
* @param bundleName the name of the web resource bundle
* @param bundleSubPath the relative sub-path in the web resource bundle to import the resources into.
* @param fileOrDirectory the file or directory to import web resources from.
* @throws WebResourceException if an error occurs while importing web resources
* @param session the JCR session used to access web files.
* @param bundleName the name of the web file bundle
* @param bundleSubPath the relative sub-path in the web file bundle to import the resources into.
* @param fileOrDirectory the file or directory to import web files from.
* @throws WebFileException if an error occurs while importing web files
*/
void importJcrWebResources(Session session, String bundleName, String bundleSubPath, File fileOrDirectory) throws WebResourceException;
void importJcrWebFiles(Session session, String bundleName, String bundleSubPath, File fileOrDirectory) throws WebFileException;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment