Skip to content

Commit

Permalink
Add Javadoc (#13)
Browse files Browse the repository at this point in the history
Signed-off-by: Clement Escoffier <[email protected]>
  • Loading branch information
cescoffier committed Jul 1, 2014
1 parent 3ace614 commit 6decbbf
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
2 changes: 0 additions & 2 deletions core/wisdom-api/src/main/java/org/wisdom/api/asset/Asset.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/
package org.wisdom.api.asset;

import java.net.URL;

/**
* A structure representing assets.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.wisdom.api.asset;

/**
* a default implementation of asset.
* A default implementation of asset.
*/
public class DefaultAsset<T> implements Asset<T> {

Expand All @@ -34,11 +34,26 @@ public class DefaultAsset<T> implements Asset<T> {

private final long lastModified;


/**
* Creates a new default asset.
*
* @param path the path
* @param content the content
* @param source the source
*/
public DefaultAsset(String path, T content, String source) {
this(path, content, source, -1, null);
}

/**
* Creates a new default asset.
*
* @param path the path
* @param content the content
* @param source the source
* @param lastModified the last modification date
* @param etag the etag if computed (may be {@code null})
*/
public DefaultAsset(String path, T content, String source, long lastModified, String etag) {
this.path = path;
this.content = content;
Expand All @@ -47,22 +62,47 @@ public DefaultAsset(String path, T content, String source, long lastModified, St
this.lastModified = lastModified;
}

/**
* Gets the path of the asset. Emitting a request on this path allows to retrieve the asset.
*
* @return the url
*/
public String getPath() {
return path;
}

/**
* Gets the asset backend (file, url...)
*
* @return the content
*/
public T getContent() {
return content;
}

/**
* Gets the asset's source
*
* @return an identifier of the source
*/
public String getSource() {
return source;
}

/**
* Gets the ETAG of the asset if computed.
*
* @return the ETAG, {@literal null} if not computed.
*/
public String getEtag() {
return etag;
}

/**
* Gets the last modification date.
*
* @return the last modification date of the asset
*/
public long getLastModified() {
return lastModified;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,19 @@ public class AssetController extends DefaultController implements AssetProvider
Crypto crypto;


/**
* Creates an instance of the asset controller.
* @param bc the bundle context
* @param path the path of the directory containing external asset ("assets" by default).
*/
public AssetController(BundleContext bc, @Property(value = "assets") String path) {
directory = new File(configuration.getBaseDir(), path);
this.context = bc;
}

/**
* @return the 'serve' routes.
*/
@Override
public List<Route> routes() {
return ImmutableList.of(new RouteBuilder()
Expand All @@ -75,6 +83,9 @@ public List<Route> routes() {
.to(this, "serve"));
}

/**
* @return the result serving the asset.
*/
public Result serve() {
String path = context().parameterFromPath("path");
if (path.startsWith("/")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ public class AssetsSingleton extends DefaultController implements Assets {
@Requires(filter = "(name=assets/list)")
Template template;


/**
* Serves the asset list page, or a JSON form depending on the {@literal ACCEPT} header.
* @return the page, the json form or a bad request. Bad request are returned in "PROD" mode.
*/
@Route(method = HttpMethod.GET, uri = "/assets")
public Result index() {
if (configuration.isProd()) {
Expand Down

0 comments on commit 6decbbf

Please sign in to comment.