added code errors to return

git-svn-id: https://svn.d4science-ii.research-infrastructures.eu/gcube/branches/data-access/storagehub-webapp/1.0@178696 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Lucio Lelii 2019-03-26 16:09:26 +00:00
parent f44f3fc0ad
commit b279496026
18 changed files with 174 additions and 115 deletions

View File

@ -15,16 +15,19 @@
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">

View File

@ -5,6 +5,11 @@
<projects> <projects>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name> <name>org.eclipse.jdt.core.javabuilder</name>
<arguments> <arguments>
@ -15,9 +20,18 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

12
.settings/.jsdtscope Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="src/main/webapp"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>

View File

@ -10,4 +10,5 @@ org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.compiler.source=1.8

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="storagehub">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="storagehub-model-1.0.3-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/storagehub-model_TRUNK/storagehub-model_TRUNK">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="storagehub"/>
<property name="java-output-path" value="/storagehub-webapp_BRANCH/target/classes"/>
</wb-module>
</project-modules>

View File

@ -0,0 +1,7 @@
<root>
<facet id="jst.jaxrs">
<node name="libprov">
<attribute name="provider-id" value="jaxrs-no-op-library-provider"/>
</node>
</facet>
</root>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.8"/>
<installed facet="jst.web" version="3.0"/>
<installed facet="jst.jaxrs" version="2.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>

View File

@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.baseBrowserLibrary

View File

@ -0,0 +1 @@
Window

View File

@ -0,0 +1,2 @@
disabled=06target
eclipse.preferences.version=1

View File

@ -21,6 +21,7 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList;
import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils;
@ -69,7 +70,6 @@ public class ACLManager {
* @exception {@link RepositoryException} when a generic jcr error occurs * @exception {@link RepositoryException} when a generic jcr error occurs
* @exception {@link UserNotAuthorizedException} when the caller is not authorized to access to the shared folder * @exception {@link UserNotAuthorizedException} when the caller is not authorized to access to the shared folder
*/ */
@Produces(MediaType.APPLICATION_JSON)
@GET @GET
@Path("{id}/acls") @Path("{id}/acls")
public ACLList getACL() { public ACLList getACL() {
@ -100,8 +100,8 @@ public class ACLManager {
log.error("jcr error getting acl", re); log.error("jcr error getting acl", re);
GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error getting acl", re)); GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error getting acl", re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error getting acl", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -167,8 +167,8 @@ public class ACLManager {
log.error("jcr error extracting archive", re); log.error("jcr error extracting archive", re);
GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error setting acl", re)); GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error setting acl", re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error setting acl", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();

View File

@ -55,7 +55,6 @@ public class GroupManager {
@GET @GET
@Path("") @Path("")
@Produces(MediaType.APPLICATION_JSON)
@AuthorizationControl(allowed={"lucio.lelii"}, exception=MyAuthException.class) @AuthorizationControl(allowed={"lucio.lelii"}, exception=MyAuthException.class)
public List<String> getGroups(){ public List<String> getGroups(){

View File

@ -17,6 +17,7 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.jackrabbit.api.security.JackrabbitAccessControlList; import org.apache.jackrabbit.api.security.JackrabbitAccessControlList;
import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils;
@ -76,7 +77,6 @@ public class ItemSharing {
@PUT @PUT
@Path("{id}/share") @Path("{id}/share")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA) @Consumes(MediaType.MULTIPART_FORM_DATA)
public String share(@FormDataParam("users") Set<String> users, @FormDataParam("defaultAccessType") AccessType accessType){ public String share(@FormDataParam("users") Set<String> users, @FormDataParam("defaultAccessType") AccessType accessType){
InnerMethodName.instance.set("shareFolder"); InnerMethodName.instance.set("shareFolder");
@ -146,8 +146,8 @@ public class ItemSharing {
log.error("jcr sharing", re); log.error("jcr sharing", re);
GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error extracting archive", re)); GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error extracting archive", re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error sharing", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -207,7 +207,6 @@ public class ItemSharing {
@PUT @PUT
@Path("{id}/unshare") @Path("{id}/unshare")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA) @Consumes(MediaType.MULTIPART_FORM_DATA)
public String unshare(@FormDataParam("users") Set<String> users){ public String unshare(@FormDataParam("users") Set<String> users){
InnerMethodName.instance.set("unshareFolder"); InnerMethodName.instance.set("unshareFolder");
@ -223,8 +222,8 @@ public class ItemSharing {
log.error("jcr unsharing", re); log.error("jcr unsharing", re);
GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error extracting archive", re)); GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error extracting archive", re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error unsharing", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)

View File

@ -31,6 +31,7 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.commons.compress.archivers.ArchiveEntry; import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveException; import org.apache.commons.compress.archivers.ArchiveException;
@ -105,7 +106,6 @@ public class ItemsCreator {
//@Path("/{id}/create/{type:(?!FILE)[^/?$]*}") //@Path("/{id}/create/{type:(?!FILE)[^/?$]*}")
@POST @POST
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Path("/{id}/create/FOLDER") @Path("/{id}/create/FOLDER")
public String createFolder(@PathParam("id") String id, @FormParam("name") String name, @FormParam("description") String description, @FormParam("hidden") boolean hidden) { public String createFolder(@PathParam("id") String id, @FormParam("name") String name, @FormParam("description") String description, @FormParam("hidden") boolean hidden) {
@ -146,8 +146,8 @@ public class ItemsCreator {
log.info("item with id {} correctly created",newNode.getIdentifier()); log.info("item with id {} correctly created",newNode.getIdentifier());
toReturn = newNode.getIdentifier(); toReturn = newNode.getIdentifier();
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error creating item", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}catch(RepositoryException re ){ }catch(RepositoryException re ){
log.error("jcr error creating item", re); log.error("jcr error creating item", re);
GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error creating item", re)); GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error creating item", re));
@ -160,7 +160,6 @@ public class ItemsCreator {
} }
@POST @POST
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Path("/{id}/create/GCUBEITEM") @Path("/{id}/create/GCUBEITEM")
public String createGcubeItem(@PathParam("id") String id, GCubeItem item) { public String createGcubeItem(@PathParam("id") String id, GCubeItem item) {
@ -198,8 +197,8 @@ public class ItemsCreator {
log.info("item with id {} correctly created",newNode.getIdentifier()); log.info("item with id {} correctly created",newNode.getIdentifier());
toReturn = newNode.getIdentifier(); toReturn = newNode.getIdentifier();
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error creating item", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}catch(RepositoryException re ){ }catch(RepositoryException re ){
log.error("jcr error creating item", re); log.error("jcr error creating item", re);
GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error creating item", re)); GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error creating item", re));
@ -248,8 +247,8 @@ public class ItemsCreator {
log.error("jcr error creating file item", re); log.error("jcr error creating file item", re);
GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error creating file item", re)); GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error creating file item", re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error creating file item", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}catch(Throwable e ){ }catch(Throwable e ){
log.error("unexpected error", e); log.error("unexpected error", e);
GXOutboundErrorResponse.throwException(new BackendGenericError(e)); GXOutboundErrorResponse.throwException(new BackendGenericError(e));
@ -299,7 +298,6 @@ public class ItemsCreator {
@POST @POST
@Consumes(MediaType.MULTIPART_FORM_DATA) @Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/create/ARCHIVE") @Path("/{id}/create/ARCHIVE")
public String uploadArchive(@PathParam("id") String id, @FormDataParam("parentFolderName") String parentFolderName, public String uploadArchive(@PathParam("id") String id, @FormDataParam("parentFolderName") String parentFolderName,
@FormDataParam("file") InputStream stream, @FormDataParam("file") InputStream stream,
@ -391,8 +389,8 @@ public class ItemsCreator {
log.error("jcr error extracting archive", re); log.error("jcr error extracting archive", re);
GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error extracting archive", re)); GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error extracting archive", re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error creating file item", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
} finally{ } finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();

View File

@ -20,6 +20,7 @@ import java.util.zip.ZipOutputStream;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.inject.Inject; import javax.inject.Inject;
import javax.jcr.ItemNotFoundException;
import javax.jcr.Node; import javax.jcr.Node;
import javax.jcr.NodeIterator; import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException; import javax.jcr.RepositoryException;
@ -38,6 +39,7 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.StreamingOutput; import javax.ws.rs.core.StreamingOutput;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
@ -52,6 +54,7 @@ import org.gcube.common.storagehub.model.Excludes;
import org.gcube.common.storagehub.model.NodeConstants; import org.gcube.common.storagehub.model.NodeConstants;
import org.gcube.common.storagehub.model.Paths; import org.gcube.common.storagehub.model.Paths;
import org.gcube.common.storagehub.model.exceptions.BackendGenericError; import org.gcube.common.storagehub.model.exceptions.BackendGenericError;
import org.gcube.common.storagehub.model.exceptions.IdNotFoundException;
import org.gcube.common.storagehub.model.exceptions.InvalidCallParameters; import org.gcube.common.storagehub.model.exceptions.InvalidCallParameters;
import org.gcube.common.storagehub.model.exceptions.InvalidItemException; import org.gcube.common.storagehub.model.exceptions.InvalidItemException;
import org.gcube.common.storagehub.model.exceptions.StorageHubException; import org.gcube.common.storagehub.model.exceptions.StorageHubException;
@ -116,21 +119,24 @@ public class ItemsManager {
@GET @GET
@Path("{id}") @Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
public ItemWrapper<Item> getById(@QueryParam("exclude") List<String> excludes){ public ItemWrapper<Item> getById(@QueryParam("exclude") List<String> excludes){
InnerMethodName.instance.set("getById"); InnerMethodName.instance.set("getById");
Session ses = null; Session ses = null;
Item toReturn = null; Item toReturn = null;
try{ try{
ses = repository.getRepository().login(CredentialHandler.getAdminCredentials(context)); ses = repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
Node node = ses.getNodeByIdentifier(id);
authChecker.checkReadAuthorizationControl(ses, id); authChecker.checkReadAuthorizationControl(ses, id);
toReturn = node2Item.getItem(ses.getNodeByIdentifier(id), excludes); toReturn = node2Item.getItem(node, excludes);
}catch (ItemNotFoundException e) {
log.error("id {} not found",id,e);
GXOutboundErrorResponse.throwException(new IdNotFoundException("id not found", e), Status.NOT_FOUND);
}catch(RepositoryException re){ }catch(RepositoryException re){
log.error("jcr error getting item", re); log.error("jcr error getting item", re);
GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error searching item", re)); GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error searching item", re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error getting item", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -141,7 +147,6 @@ public class ItemsManager {
@GET @GET
@Path("{id}/items/{name}") @Path("{id}/items/{name}")
@Produces(MediaType.APPLICATION_JSON)
public ItemList findChildrenByNamePattern(@QueryParam("exclude") List<String> excludes, @PathParam("name") String name){ public ItemList findChildrenByNamePattern(@QueryParam("exclude") List<String> excludes, @PathParam("name") String name){
InnerMethodName.instance.set("findChildrenByNamePattern"); InnerMethodName.instance.set("findChildrenByNamePattern");
Session ses = null; Session ses = null;
@ -166,13 +171,15 @@ public class ItemsManager {
|| (nodeName.equals(cleanedName) || title.equals(cleanedName))) || (nodeName.equals(cleanedName) || title.equals(cleanedName)))
toReturn.add(node2Item.getItem(child, excludes)); toReturn.add(node2Item.getItem(child, excludes));
} }
}catch (ItemNotFoundException e) {
log.error("id {} not found",id,e);
GXOutboundErrorResponse.throwException(new IdNotFoundException("id not found", e), Status.NOT_FOUND);
}catch(RepositoryException re){ }catch(RepositoryException re){
log.error("jcr error searching item", re); log.error("jcr error searching item", re);
GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error searching item", re)); GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error searching item", re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error searching item", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -184,23 +191,24 @@ public class ItemsManager {
@GET @GET
@Path("{id}/children/count") @Path("{id}/children/count")
@Produces(MediaType.APPLICATION_JSON)
public Long countById(@QueryParam("showHidden") Boolean showHidden, @QueryParam("exclude") List<String> excludes, @QueryParam("onlyType") String nodeType){ public Long countById(@QueryParam("showHidden") Boolean showHidden, @QueryParam("exclude") List<String> excludes, @QueryParam("onlyType") String nodeType){
InnerMethodName.instance.set("countById"); InnerMethodName.instance.set("countById");
Session ses = null; Session ses = null;
Long toReturn = null; Long toReturn = null;
try{ try{
ses = repository.getRepository().login(CredentialHandler.getAdminCredentials(context)); ses = repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
authChecker.checkReadAuthorizationControl(ses, id); authChecker.checkReadAuthorizationControl(ses, id);
toReturn = Utils.getItemCount(ses.getNodeByIdentifier(id), showHidden==null?false:showHidden, nodeType!=null ? ClassHandler.instance().get(nodeType) : null); toReturn = Utils.getItemCount(ses.getNodeByIdentifier(id), showHidden==null?false:showHidden, nodeType!=null ? ClassHandler.instance().get(nodeType) : null);
}catch (ItemNotFoundException e) {
log.error("id {} not found",id,e);
GXOutboundErrorResponse.throwException(new IdNotFoundException("id not found", e), Status.NOT_FOUND);
}catch(RuntimeException | RepositoryException re){ }catch(RuntimeException | RepositoryException re){
log.error("jcr error counting item", re); log.error("jcr error counting item", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error counting item", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -210,7 +218,6 @@ public class ItemsManager {
@GET @GET
@Path("{id}/children") @Path("{id}/children")
@Produces(MediaType.APPLICATION_JSON)
public ItemList listById(@QueryParam("showHidden") Boolean showHidden, @QueryParam("exclude") List<String> excludes, @QueryParam("onlyType") String nodeType){ public ItemList listById(@QueryParam("showHidden") Boolean showHidden, @QueryParam("exclude") List<String> excludes, @QueryParam("onlyType") String nodeType){
InnerMethodName.instance.set("listById"); InnerMethodName.instance.set("listById");
Session ses = null; Session ses = null;
@ -219,12 +226,15 @@ public class ItemsManager {
ses = repository.getRepository().login(CredentialHandler.getAdminCredentials(context)); ses = repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
authChecker.checkReadAuthorizationControl(ses, id); authChecker.checkReadAuthorizationControl(ses, id);
toReturn = Utils.getItemList(ses.getNodeByIdentifier(id), excludes, null, showHidden==null?false:showHidden, nodeType!=null ? ClassHandler.instance().get(nodeType) : null); toReturn = Utils.getItemList(ses.getNodeByIdentifier(id), excludes, null, showHidden==null?false:showHidden, nodeType!=null ? ClassHandler.instance().get(nodeType) : null);
}catch (ItemNotFoundException e) {
log.error("id {} not found",id,e);
GXOutboundErrorResponse.throwException(new IdNotFoundException("id not found", e), Status.NOT_FOUND);
}catch(RepositoryException re){ }catch(RepositoryException re){
log.error("jcr error getting children", re); log.error("jcr error getting children", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error getting children", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -235,7 +245,6 @@ public class ItemsManager {
@GET @GET
@Path("{id}/children/paged") @Path("{id}/children/paged")
@Produces(MediaType.APPLICATION_JSON)
public ItemList listByIdPaged(@QueryParam("showHidden") Boolean showHidden, @QueryParam("start") Integer start, @QueryParam("limit") Integer limit, @QueryParam("exclude") List<String> excludes, @QueryParam("onlyType") String nodeType){ public ItemList listByIdPaged(@QueryParam("showHidden") Boolean showHidden, @QueryParam("start") Integer start, @QueryParam("limit") Integer limit, @QueryParam("exclude") List<String> excludes, @QueryParam("onlyType") String nodeType){
InnerMethodName.instance.set("listByIdPaged"); InnerMethodName.instance.set("listByIdPaged");
Session ses = null; Session ses = null;
@ -244,12 +253,15 @@ public class ItemsManager {
ses = repository.getRepository().login(CredentialHandler.getAdminCredentials(context)); ses = repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
authChecker.checkReadAuthorizationControl(ses, id); authChecker.checkReadAuthorizationControl(ses, id);
toReturn = Utils.getItemList(ses.getNodeByIdentifier(id), excludes, new Range(start, limit),showHidden==null?false:showHidden, nodeType!=null ? ClassHandler.instance().get(nodeType) : null); toReturn = Utils.getItemList(ses.getNodeByIdentifier(id), excludes, new Range(start, limit),showHidden==null?false:showHidden, nodeType!=null ? ClassHandler.instance().get(nodeType) : null);
}catch (ItemNotFoundException e) {
log.error("id {} not found",id,e);
GXOutboundErrorResponse.throwException(new IdNotFoundException("id not found", e), Status.NOT_FOUND);
}catch(RepositoryException re){ }catch(RepositoryException re){
log.error("jcr error getting paged children", re); log.error("jcr error getting paged children", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error getting paged children", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -259,7 +271,6 @@ public class ItemsManager {
} }
@GET @GET
@Produces(MediaType.APPLICATION_JSON)
@Path("publiclink/{id}") @Path("publiclink/{id}")
@AuthorizationControl(allowed={"URIResolver"}, exception=MyAuthException.class) @AuthorizationControl(allowed={"URIResolver"}, exception=MyAuthException.class)
public Response resolvePublicLink() { public Response resolvePublicLink() {
@ -318,8 +329,8 @@ public class ItemsManager {
log.error("jcr error getting public link", re); log.error("jcr error getting public link", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error getting public link", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -328,7 +339,6 @@ public class ItemsManager {
} }
@GET @GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/publiclink") @Path("{id}/publiclink")
public URL getPublicLink(@QueryParam("version") String version) { public URL getPublicLink(@QueryParam("version") String version) {
InnerMethodName.instance.set("getPubliclink"); InnerMethodName.instance.set("getPubliclink");
@ -393,8 +403,8 @@ public class ItemsManager {
log.error("jcr error getting public link", re); log.error("jcr error getting public link", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error getting public link", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -412,7 +422,6 @@ public class ItemsManager {
@GET @GET
@Path("{id}/rootSharedFolder") @Path("{id}/rootSharedFolder")
@Produces(MediaType.APPLICATION_JSON)
public ItemWrapper<Item> getRootSharedFolder(@QueryParam("exclude") List<String> excludes){ public ItemWrapper<Item> getRootSharedFolder(@QueryParam("exclude") List<String> excludes){
InnerMethodName.instance.set("getRootSharedFolder"); InnerMethodName.instance.set("getRootSharedFolder");
Session ses = null; Session ses = null;
@ -434,8 +443,8 @@ public class ItemsManager {
log.error("jcr error getting rootSharedFolder", re); log.error("jcr error getting rootSharedFolder", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error getting rootSharedFolder", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -455,7 +464,6 @@ public class ItemsManager {
@GET @GET
@Path("{id}/versions") @Path("{id}/versions")
@Produces(MediaType.APPLICATION_JSON)
public VersionList getVersions(){ public VersionList getVersions(){
InnerMethodName.instance.set("getVersions"); InnerMethodName.instance.set("getVersions");
Session ses = null; Session ses = null;
@ -481,8 +489,8 @@ public class ItemsManager {
log.error("jcr error retrieving versions", re); log.error("jcr error retrieving versions", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error retrieving versions", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -506,8 +514,8 @@ public class ItemsManager {
log.error("jcr error downloading version", re); log.error("jcr error downloading version", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error downloading version", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -555,7 +563,6 @@ public class ItemsManager {
@GET @GET
@Path("{id}/anchestors") @Path("{id}/anchestors")
@Produces(MediaType.APPLICATION_JSON)
public ItemList getAnchestors(@QueryParam("exclude") List<String> excludes){ public ItemList getAnchestors(@QueryParam("exclude") List<String> excludes){
InnerMethodName.instance.set("getAnchestors"); InnerMethodName.instance.set("getAnchestors");
org.gcube.common.storagehub.model.Path absolutePath = Utils.getWorkspacePath(); org.gcube.common.storagehub.model.Path absolutePath = Utils.getWorkspacePath();
@ -589,8 +596,8 @@ public class ItemsManager {
log.error("jcr error getting anchestors", re); log.error("jcr error getting anchestors", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error getting anchestors", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -658,8 +665,8 @@ public class ItemsManager {
log.error("jcr error download", re); log.error("jcr error download", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error download", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
} finally{ } finally{
if (ses!=null) ses.logout(); if (ses!=null) ses.logout();
} }
@ -746,8 +753,8 @@ public class ItemsManager {
log.error("jcr error moving item", re); log.error("jcr error moving item", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error moving item", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
} finally{ } finally{
if (ses!=null) { if (ses!=null) {
ses.logout(); ses.logout();
@ -820,9 +827,9 @@ public class ItemsManager {
log.error("jcr error moving item", re); log.error("jcr error moving item", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error moving item", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
} finally{ }finally{
if (ses!=null) { if (ses!=null) {
ses.logout(); ses.logout();
} }
@ -875,9 +882,9 @@ public class ItemsManager {
log.error("jcr error moving item", re); log.error("jcr error moving item", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error moving item", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
} finally{ }finally{
if (ses!=null) { if (ses!=null) {
ses.logout(); ses.logout();
} }
@ -917,9 +924,9 @@ public class ItemsManager {
log.error("jcr error moving item", re); log.error("jcr error moving item", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error moving item", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
} finally{ }finally{
if (ses!=null) { if (ses!=null) {
ses.logout(); ses.logout();
} }
@ -964,9 +971,9 @@ public class ItemsManager {
log.error("jcr error moving item", re); log.error("jcr error moving item", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error moving item", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
} finally{ }finally{
if (ses!=null) { if (ses!=null) {
ses.logout(); ses.logout();
} }

View File

@ -50,7 +50,7 @@ public class UserManager {
@Inject @Inject
UnshareHandler unshareHandler; UnshareHandler unshareHandler;
@GET @GET
@Path("") @Path("")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@ -99,17 +99,17 @@ public class UserManager {
User createdUser = usrManager.createUser(user, password); User createdUser = usrManager.createUser(user, password);
userId = createdUser.getID(); userId = createdUser.getID();
Node homeNode = session.getNode("/Home"); Node homeNode = session.getNode("/Home");
Node userHome = homeNode.addNode(user, "nthl:home"); Node userHome = homeNode.addNode(user, "nthl:home");
//creating workspace folder //creating workspace folder
Node workspaceFolder = Utils.createFolderInternally(session, userHome, Constants.WORKSPACE_ROOT_FOLDER_NAME, "workspace of "+user, false, user, null); Node workspaceFolder = Utils.createFolderInternally(session, userHome, Constants.WORKSPACE_ROOT_FOLDER_NAME, "workspace of "+user, false, user, null);
//creating thrash folder //creating thrash folder
Utils.createFolderInternally(session, workspaceFolder, Constants.TRASH_ROOT_FOLDER_NAME, "trash of "+user, false, user, null); Utils.createFolderInternally(session, workspaceFolder, Constants.TRASH_ROOT_FOLDER_NAME, "trash of "+user, false, user, null);
//creating Vre container folder //creating Vre container folder
Utils.createFolderInternally(session, workspaceFolder, Constants.VRE_FOLDER_PARENT_NAME, "special folder container of "+user, false, user, null); Utils.createFolderInternally(session, workspaceFolder, Constants.VRE_FOLDER_PARENT_NAME, "special folder container of "+user, false, user, null);
session.save(); session.save();
}catch(Exception e) { }catch(Exception e) {
log.error("jcr error creating user {}", user, e); log.error("jcr error creating user {}", user, e);
@ -118,10 +118,11 @@ public class UserManager {
if (session!=null) if (session!=null)
session.logout(); session.logout();
} }
return userId; return userId;
} }
@DELETE @DELETE
@Path("{id}") @Path("{id}")
@AuthorizationControl(allowed={"lucio.lelii"}, exception=MyAuthException.class) @AuthorizationControl(allowed={"lucio.lelii"}, exception=MyAuthException.class)
@ -133,17 +134,17 @@ public class UserManager {
session = (JackrabbitSession) repository.getRepository().login(CredentialHandler.getAdminCredentials(context)); session = (JackrabbitSession) repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
org.apache.jackrabbit.api.security.user.UserManager usrManager = session.getUserManager(); org.apache.jackrabbit.api.security.user.UserManager usrManager = session.getUserManager();
org.gcube.common.storagehub.model.Path path = Utils.getWorkspacePath(id); org.gcube.common.storagehub.model.Path path = Utils.getWorkspacePath(id);
String sql2Query = String.format("SELECT * FROM [nthl:workspaceSharedItem] AS node WHERE ISDESCENDANTNODE('%s')", path.toPath()); String sql2Query = String.format("SELECT * FROM [nthl:workspaceSharedItem] AS node WHERE ISDESCENDANTNODE('%s')", path.toPath());
log.info("query sent is {}",sql2Query); log.info("query sent is {}",sql2Query);
javax.jcr.query.Query jcrQuery = session.getWorkspace().getQueryManager().createQuery(sql2Query, Constants.QUERY_LANGUAGE); javax.jcr.query.Query jcrQuery = session.getWorkspace().getQueryManager().createQuery(sql2Query, Constants.QUERY_LANGUAGE);
QueryResult result = jcrQuery.execute(); QueryResult result = jcrQuery.execute();
NodeIterator nodeIt = result.getNodes(); NodeIterator nodeIt = result.getNodes();
while (nodeIt.hasNext()) { while (nodeIt.hasNext()) {
@ -152,7 +153,7 @@ public class UserManager {
log.debug("removing sharing for folder name {} with title {} and path {} ",rNode.getName(), title, rNode.getPath()); log.debug("removing sharing for folder name {} with title {} and path {} ",rNode.getName(), title, rNode.getPath());
unshareHandler.unshare(session, Collections.singleton(id), rNode, id); unshareHandler.unshare(session, Collections.singleton(id), rNode, id);
} }
Authorizable authorizable = usrManager.getAuthorizable(new PrincipalImpl(id)); Authorizable authorizable = usrManager.getAuthorizable(new PrincipalImpl(id));
if (!authorizable.isGroup()) { if (!authorizable.isGroup()) {
log.info("removing user {}", id); log.info("removing user {}", id);
@ -166,7 +167,7 @@ public class UserManager {
if (session!=null) if (session!=null)
session.logout(); session.logout();
} }
return userId; return userId;
} }

View File

@ -23,6 +23,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.gcube.common.authorization.library.provider.AuthorizationProvider; import org.gcube.common.authorization.library.provider.AuthorizationProvider;
import org.gcube.common.gxrest.response.outbound.GXOutboundErrorResponse; import org.gcube.common.gxrest.response.outbound.GXOutboundErrorResponse;
@ -92,7 +93,6 @@ public class WorkspaceManager {
@Path("") @Path("")
@GET @GET
@Produces(MediaType.APPLICATION_JSON)
public ItemWrapper<Item> getWorkspace(@QueryParam("relPath") String relPath){ public ItemWrapper<Item> getWorkspace(@QueryParam("relPath") String relPath){
InnerMethodName.instance.set("getWorkspace"); InnerMethodName.instance.set("getWorkspace");
Session ses = null; Session ses = null;
@ -121,8 +121,8 @@ public class WorkspaceManager {
log.error("jcr error getting workspace item", re); log.error("jcr error getting workspace item", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error getting workspace item", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -155,7 +155,6 @@ public class WorkspaceManager {
@Path("vrefolder") @Path("vrefolder")
@GET @GET
@Produces(MediaType.APPLICATION_JSON)
public ItemWrapper<Item> getVreRootFolder(){ public ItemWrapper<Item> getVreRootFolder(){
InnerMethodName.instance.set("getVreRootFolder"); InnerMethodName.instance.set("getVreRootFolder");
Session ses = null; Session ses = null;
@ -167,8 +166,8 @@ public class WorkspaceManager {
log.error("jcr error getting vrefolder", re); log.error("jcr error getting vrefolder", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error getting vrefolder", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -178,7 +177,6 @@ public class WorkspaceManager {
@Path("vrefolder/recents") @Path("vrefolder/recents")
@GET @GET
@Produces(MediaType.APPLICATION_JSON)
public ItemList getVreFolderRecentsDocument(){ public ItemList getVreFolderRecentsDocument(){
InnerMethodName.instance.set("getVreFolderRecents"); InnerMethodName.instance.set("getVreFolderRecents");
Session ses = null; Session ses = null;
@ -196,8 +194,8 @@ public class WorkspaceManager {
log.error("jcr error getting recents", re); log.error("jcr error getting recents", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error getting recents", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -211,7 +209,6 @@ public class WorkspaceManager {
@Path("trash") @Path("trash")
@GET @GET
@Produces(MediaType.APPLICATION_JSON)
public ItemWrapper<Item> getTrashRootFolder(){ public ItemWrapper<Item> getTrashRootFolder(){
InnerMethodName.instance.set("getTrashRootFolder"); InnerMethodName.instance.set("getTrashRootFolder");
Session ses = null; Session ses = null;
@ -229,8 +226,8 @@ public class WorkspaceManager {
log.error("jcr error getting trash", re); log.error("jcr error getting trash", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error getting trash", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -257,8 +254,8 @@ public class WorkspaceManager {
log.error("jcr error emptying trash", re); log.error("jcr error emptying trash", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error emptying trash", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -296,9 +293,9 @@ public class WorkspaceManager {
log.error("error restoring item with id {}",identifier, re); log.error("error restoring item with id {}",identifier, re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error restoring item with id {}",identifier, she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
} finally{ }finally{
if (ses!=null) { if (ses!=null) {
ses.logout(); ses.logout();
} }
@ -310,7 +307,6 @@ public class WorkspaceManager {
@Path("vrefolders") @Path("vrefolders")
@GET @GET
@Produces(MediaType.APPLICATION_JSON)
public ItemList getVreFolders(){ public ItemList getVreFolders(){
InnerMethodName.instance.set("getVreFolders"); InnerMethodName.instance.set("getVreFolders");
Session ses = null; Session ses = null;
@ -325,8 +321,8 @@ public class WorkspaceManager {
log.error("error reading the node children of {}",vrePath, re); log.error("error reading the node children of {}",vrePath, re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error reading the node children of {}",vrePath, she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -337,7 +333,6 @@ public class WorkspaceManager {
@Path("vrefolders/paged") @Path("vrefolders/paged")
@GET @GET
@Produces(MediaType.APPLICATION_JSON)
public ItemList getVreFoldersPaged(@QueryParam("start") Integer start, @QueryParam("limit") Integer limit){ public ItemList getVreFoldersPaged(@QueryParam("start") Integer start, @QueryParam("limit") Integer limit){
InnerMethodName.instance.set("getVreFoldersPaged"); InnerMethodName.instance.set("getVreFoldersPaged");
Session ses = null; Session ses = null;
@ -350,8 +345,8 @@ public class WorkspaceManager {
log.error("(paged) error reading the node children of {}",vrePath, re); log.error("(paged) error reading the node children of {}",vrePath, re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("(paged) error reading the node children of {}",vrePath, she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();
@ -364,7 +359,6 @@ public class WorkspaceManager {
@Path("query") @Path("query")
@GET @GET
@Produces(MediaType.APPLICATION_JSON)
public ItemList searchItems(@QueryParam("n") String node, @QueryParam("e") String jsonExpr, @QueryParam("o") List<String> orderField, @QueryParam("l") Integer limit, @QueryParam("f") Integer offset){ public ItemList searchItems(@QueryParam("n") String node, @QueryParam("e") String jsonExpr, @QueryParam("o") List<String> orderField, @QueryParam("l") Integer limit, @QueryParam("f") Integer offset){
InnerMethodName.instance.set("searchItems"); InnerMethodName.instance.set("searchItems");
Session ses = null; Session ses = null;
@ -405,8 +399,8 @@ public class WorkspaceManager {
log.error("error executing the query", re); log.error("error executing the query", re);
GXOutboundErrorResponse.throwException(new BackendGenericError(re)); GXOutboundErrorResponse.throwException(new BackendGenericError(re));
}catch(StorageHubException she ){ }catch(StorageHubException she ){
log.error("error executing the query", she); log.error(she.getErrorMessage(), she);
GXOutboundErrorResponse.throwException(she); GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
}finally{ }finally{
if (ses!=null) if (ses!=null)
ses.logout(); ses.logout();

View File

@ -1,5 +1,4 @@
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd">
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd">
</beans> </beans>