Skip to content

Commit

Permalink
javadoc improved and exists method improved
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwechner committed Feb 1, 2012
1 parent f1b1758 commit 16b9c1d
Showing 1 changed file with 30 additions and 12 deletions.
Expand Up @@ -17,6 +17,7 @@
package org.wyona.yanel.impl.resources.node;

import org.wyona.yanel.core.Resource;
import org.wyona.yanel.core.ResourceNotFoundException;
import org.wyona.yanel.core.api.attributes.CreatableV2;
import org.wyona.yanel.core.api.attributes.IntrospectableV1;
import org.wyona.yanel.core.api.attributes.ModifiableV2;
Expand Down Expand Up @@ -52,7 +53,6 @@
* Generic Node Resource
*/
public class NodeResource extends Resource implements ViewableV2, ModifiableV2, VersionableV2, IntrospectableV1, WorkflowableV1, CreatableV2 {
//public class NodeResource extends Resource implements ViewableV2, ModifiableV2, VersionableV2, CreatableV2 {

private static Logger log = Logger.getLogger(NodeResource.class);

Expand All @@ -71,7 +71,11 @@ public ViewDescriptor[] getViewDescriptors() {
return null;
}

/**
* @see org.wyona.yanel.core.api.attributes.VersionableV2#getView(String, String)
*/
public View getView(String viewId, String revisionName) throws Exception {
// TODO: Check first whether revision of node exists...
View view = new View();

view.setInputStream(getNode().getRevision(revisionName).getInputStream());
Expand All @@ -82,9 +86,12 @@ public View getView(String viewId, String revisionName) throws Exception {
}

/**
*
* @see org.wyona.yanel.core.api.attributes/ViewableV2#getView(String)
*/
public View getView(String viewId) throws Exception {
if (!exists()) {
throw new ResourceNotFoundException("No such repository node: " + getRepoPath());
}
View view = new View();

view.setInputStream(getNode().getInputStream());
Expand Down Expand Up @@ -267,8 +274,11 @@ public boolean isCheckedOut() throws Exception {
return node.isCheckedOut();
}

/**
* @see org.wyona.yanel.core.api.attributes.ViewableV2#exists()
*/
public boolean exists() throws Exception {
return getRealm().getRepository().existsNode(getPath());
return getRealm().getRepository().existsNode(getRepoPath());
}

/**
Expand Down Expand Up @@ -588,22 +598,30 @@ protected String fixAssetName(String name) {
}

/**
*
* Get repository node
*/
private Node getNode() throws org.wyona.yanel.core.ResourceNotFoundException {
private Node getNode() throws ResourceNotFoundException {
try {
String path = getPath();
if (getResourceConfigProperty("src") != null) {
path = getResourceConfigProperty("src");
}
String path = getRepoPath();
try {
return getRealm().getRepository().getNode(path);
} catch (org.wyona.yarep.core.NoSuchNodeException e) {
throw new org.wyona.yanel.core.ResourceNotFoundException(path);
//throw new org.wyona.yanel.core.ResourceNotFoundException(path, getRealm(), getRealm().getRepository());
throw new ResourceNotFoundException(path);
//throw new ResourceNotFoundException(path, getRealm(), getRealm().getRepository());
}
} catch (Exception e) {
throw new org.wyona.yanel.core.ResourceNotFoundException(e);
throw new ResourceNotFoundException(e);
}
}

/**
* Get repository path (We do not overwrite the getPath() method, because it's still used inside this class at many places without checking for the 'src' property!)
*/
private String getRepoPath() throws Exception {
String path = getPath();
if (getResourceConfigProperty("src") != null) {
path = getResourceConfigProperty("src");
}
return path;
}
}

0 comments on commit 16b9c1d

Please sign in to comment.