exception alert was updated

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@69373 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2013-02-18 11:40:03 +00:00
parent 9237f3d052
commit f51c6fe6f0
6 changed files with 211 additions and 12 deletions

View File

@ -1,4 +1,3 @@
#Wed Jun 27 12:10:12 CEST 2012
eclipse.preferences.version=1
jarsExcludedFromWebInfLib=
warSrcDir=

10
pom.xml
View File

@ -87,13 +87,13 @@
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>home-library</artifactId>
<version>[4.3.0-SNAPSHOT, 5.0.0-SNAPSHOT)</version>
<version>[4.3.0-SNAPSHOT, 5.0.0-SNAPSHOT)</version> <!-- INSERT RANGE [4.3.0-SNAPSHOT, 5.0.0-SNAPSHOT]-->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>home-library-jcr</artifactId>
<version>[1.3.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<version>[1.3.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> <!-- INSERT RANGE [1.3.0-SNAPSHOT, 2.0.0-SNAPSHOT) -->
<scope>provided</scope>
</dependency>
<dependency>
@ -230,7 +230,7 @@
</executions>
</plugin>
<!-- GWT Maven Plugin - not needed -->
<!-- GWT Maven Plugin -->
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
@ -243,11 +243,7 @@
</goals>
</execution>
</executions>
<!-- Plugin configuration. There are many available options, see gwt-maven-plugin
documentation at codehaus.org -->
<configuration>
<runTarget>WorkspacePortlet.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
</configuration>
</plugin>
</plugins>

View File

@ -184,7 +184,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
@Override
public void onFailure(Throwable caught) {
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR+" un share folder. "+ ConstantsExplorer.TRY_AGAIN, null);
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR+" un share folder. "+ caught.getMessage() +". " +ConstantsExplorer.TRY_AGAIN, null);
}
@ -874,7 +874,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
@Override
public void onFailure(Throwable caught) {
explorerPanel.getAsycTreePanel().unmask();
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR +" deleting item. Reload root", null);
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR +" deleting item. "+caught.getMessage()+". Reload root", null);
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
}
@ -1021,7 +1021,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
@Override
public void onFailure(Throwable caught) {
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " moving item. Reload root" , null);
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " moving item. "+caught.getMessage()+". Reload root" , null);
System.out.println(caught.getMessage());
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(event.getTargetParentFileModel().getIdentifier());

View File

@ -11,6 +11,7 @@ import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.applicationsupportlayer.social.SocialPortalBridge;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.portlets.user.homelibrary.home.exceptions.HomeNotFoundException;
import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.portlets.user.homelibrary.home.workspace.Workspace;
@ -58,7 +59,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
public static final String LAST_OPEN_FOLDER_ATTRIBUTE = "WORKSPACE.LAST_OPEN_FOLDER";
public static final String SELECTION_STATE_ATTRIBUTE = "WORKSPACE.SELECTION_STATE";
protected GCUBEClientLog workspaceLogger = new GCUBEClientLog("GWTWorkspaceServiceImpl");
protected GCUBELog workspaceLogger = new GCUBEClientLog(GWTWorkspaceServiceImpl.class);
protected GWTWorkspaceBuilder getGWTWorkspaceBuilder()

View File

@ -0,0 +1,126 @@
package org.gcube.portlets.user.workspace.server.util;
import java.util.List;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.applicationsupportlayer.social.ex.ApplicationProfileNotFoundException;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.XMLResult;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericQuery;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.portlets.user.workspace.shared.ApplicationProfile;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
*/
public class GcubeApplicationProfileReader {
protected static final String RESOURCE_PROFILE_BODY_ENDPOINT_URL_TEXT = "/Resource/Profile/Body/EndPoint/URL/text()";
protected static final String RESOURCE_PROFILE_BODY_ENDPOINT_SCOPE_TEXT = "/Resource/Profile/Body/EndPoint/Scope/text()";
protected static final String RESOURCE_PROFILE_BODY_THUMBNAIL_URL_TEXT = "/Resource/Profile/Body/ThumbnailURL/text()";
protected static final String RESOURCE_PROFILE_BODY_APP_ID_TEXT = "/Resource/Profile/Body/AppId/text()";
protected static final String RESOURCE_PROFILE_DESCRIPTION_TEXT = "/Resource/Profile/Description/text()";
protected static final String RESOURCE_PROFILE_NAME_TEXT = "/Resource/Profile/Name/text()";
private ASLSession aslSession;
private ApplicationProfile applicationProfile;
private GCUBEClientLog logger = new GCUBEClientLog(GcubeApplicationProfileReader.class);
public ApplicationProfile getApplicationProfile() {
return applicationProfile;
}
/**
*
* @param session
*/
public GcubeApplicationProfileReader(ASLSession session, String portletClassName) {
this.aslSession = session;
this.applicationProfile = readProfileFromInfrastrucure(portletClassName);
}
public GcubeApplicationProfileReader(ASLSession session) {
this.aslSession = session;
this.applicationProfile = null;
}
/**
* this method looks up the applicationProfile profile among the ones available in the infrastructure
* @param portletClassName your servlet class name will be used ad unique identifier for your applicationProfile
* @return the applicationProfile profile
*/
private ApplicationProfile readProfileFromInfrastrucure(String portletClassName) {
try {
ApplicationProfile toReturn = new ApplicationProfile();
ISClient client = GHNContext.getImplementation(ISClient.class);
GCUBEGenericQuery query = client.getQuery(GCUBEGenericQuery.class);
query.setExpression("for $profile in collection('/db/Profiles/GenericResource')//Resource " +
"where $profile/Profile/SecondaryType/string() eq 'ApplicationProfile' and $profile/Profile/Body/AppId/string() " +
" eq '" + portletClassName + "'" +
"return $profile");
GCUBEScope scope = aslSession.getScope();
List<XMLResult> appProfile = client.execute(query, scope.getInfrastructure());
if (appProfile == null || appProfile.size() == 0)
throw new ApplicationProfileNotFoundException("Your applicationProfile is not registered in the infrastructure");
else {
XMLResult node = appProfile.get(0);
List<String> currValue = null;
currValue = node.evaluate(RESOURCE_PROFILE_NAME_TEXT);
if (currValue != null && currValue.size() > 0) {
toReturn.setName(currValue.get(0));
}
else throw new ApplicationProfileNotFoundException("Your applicationProfile NAME was not found in the profile");
currValue = node.evaluate(RESOURCE_PROFILE_DESCRIPTION_TEXT);
if (currValue != null && currValue.size() > 0) {
toReturn.setDescription(currValue.get(0));
}
else logger.warn("No Description exists for " + toReturn.getName());
currValue = node.evaluate(RESOURCE_PROFILE_BODY_APP_ID_TEXT);
if (currValue != null && currValue.size() > 0) {
toReturn.setKey(currValue.get(0));
}
else throw new ApplicationProfileNotFoundException("Your applicationProfile ID n was not found in the profile, consider adding <AppId> element in <Body>");
currValue = node.evaluate(RESOURCE_PROFILE_BODY_THUMBNAIL_URL_TEXT);
if (currValue != null && currValue.size() > 0) {
toReturn.setImageUrl(currValue.get(0));
}
else throw new ApplicationProfileNotFoundException("Your applicationProfile Image Url was not found in the profile, consider adding <ThumbnailURL> element in <Body>");
currValue = node.evaluate(RESOURCE_PROFILE_BODY_ENDPOINT_SCOPE_TEXT);
if (currValue != null && currValue.size() > 0) {
List<String> scopes = currValue;
boolean foundUrl = false;
for (int i = 0; i < scopes.size(); i++) {
if (currValue.get(i).trim().compareTo(scope.toString()) == 0) {
toReturn.setUrl(node.evaluate(RESOURCE_PROFILE_BODY_ENDPOINT_URL_TEXT).get(i));
toReturn.setScope(scope.toString());
foundUrl = true;
break;
}
}
if (! foundUrl)
throw new ApplicationProfileNotFoundException("Your applicationProfile URL was not found in the profile for Scope: " + scope.toString());
}
else throw new ApplicationProfileNotFoundException("Your applicationProfile EndPoint was not found in the profile, consider adding <EndPoint><Scope> element in <Body>");
return toReturn;
}
} catch (Exception e) {
logger.error("Error while trying to fetch applicationProfile profile from the infrastructure");
e.printStackTrace();
return null;
}
}
}

View File

@ -0,0 +1,77 @@
package org.gcube.portlets.user.workspace.shared;
import java.io.Serializable;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
*
*/
@SuppressWarnings("serial")
public class ApplicationProfile implements Serializable {
private String key;
private String name;
private String description;
private String imageUrl;
private String scope;
private String url;
public ApplicationProfile() {
super();
}
public ApplicationProfile(String key, String name, String description, String imageUrl, String scope, String url) {
super();
this.key = key;
this.name = name;
this.description = description;
this.imageUrl = imageUrl;
this.scope = scope;
this.url = url;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
@Override
public String toString() {
return "ApplicationProfile [key=" + key + ", name=" + name + ", description="
+ description + ", imageUrl=" + imageUrl + ", scope=" + scope
+ ", url=" + url + "]";
}
}