ref 8541: StatisticalAlgorithmImporter - Support Java 8 compatibility

https://support.d4science.org/issues/8541

Updated to support Java 8 compatibility

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/github-connector@148621 82a268e6-3cf1-43bd-a215-b396298e98cf
master
Giancarlo Panichi 7 years ago
parent 5cfedadc44
commit 6044205964

@ -1,19 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/github-connector-1.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/github-connector-1.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry including="**/*.java" kind="src" path="src/main/resources"/>
<classpathentry excluding="**" kind="src" output="target/github-connector-1.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry including="**/*.java" kind="src" path="src/test/resources"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
@ -26,5 +34,5 @@
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="target/github-connector-1.3.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/github-connector-1.4.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

@ -1,4 +1,8 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets.widgets.githubconnector.1-4-0"
date="2017-06-12">
<Change>Support Java 8 compatibility [ticket #8541]</Change>
</Changeset>
<Changeset component="org.gcube.portlets.widgets.githubconnector.1-3-0"
date="2017-02-15">
<Change>Updated PortalContext support[ticket #6279]</Change>

@ -12,7 +12,7 @@
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>github-connector</artifactId>
<version>1.3.0-SNAPSHOT</version>
<version>1.4.0-SNAPSHOT</version>
<packaging>jar</packaging>
<description>github-connector</description>
@ -40,8 +40,9 @@
<configDirectory>config</configDirectory>
<!-- Java Version -->
<javaVersion>1.7</javaVersion>
<!-- Java -->
<maven.compiler.source>1.7</maven.compiler.source>
<!-- GWT configuration -->
<gwtVersion>2.7.0</gwtVersion>
@ -183,14 +184,10 @@
<scope>provided</scope>
</dependency>
<!-- GCube Widgets
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>gcube-widgets</artifactId>
<scope>compile</scope>
</dependency> -->
<!-- GCube Widgets <dependency> <groupId>org.gcube.portlets.user</groupId>
<artifactId>gcube-widgets</artifactId> <scope>compile</scope> </dependency> -->
<!-- Storage -->
<dependency>
<groupId>org.gcube.contentmanagement</groupId>
@ -347,21 +344,12 @@
</plugin>
<!-- Maven Compiler Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${javaVersion}</source>
<target>${javaVersion}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<descriptors>
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
@ -381,7 +369,8 @@
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>

@ -12,8 +12,8 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class GitHubConnectorController {

@ -20,7 +20,7 @@ import com.google.gwt.user.client.ui.TextBox;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*
*/
public class GitHubConnectorCredentialCard extends WizardCard {

@ -10,7 +10,7 @@ import com.google.gwt.core.shared.GWT;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*
*/
public class GitHubConnectorManager implements EntryPoint {

@ -28,8 +28,8 @@ import com.google.gwt.user.client.ui.TextBox;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class GitHubConnectorRepositorySelectionCard extends WizardCard {

@ -8,8 +8,8 @@ import com.google.gwt.user.client.Timer;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class GitHubConnectorWizard extends WizardWindow {

@ -6,8 +6,8 @@ import com.google.gwt.resources.client.ImageResource;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public interface GCResources extends ClientBundle {

@ -7,8 +7,8 @@ import com.google.gwt.resources.client.CssResource;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public interface WizardCSS extends CssResource {

@ -14,7 +14,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*
*/
@RemoteServiceRelativePath("githubconnectorservice")

@ -13,7 +13,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*
*/
public interface GitHubConnectorServiceAsync {

@ -11,8 +11,8 @@ import com.google.gwt.user.client.ui.HTML;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class AlertDialog extends DialogBox implements ClickHandler {

@ -4,8 +4,8 @@ import com.google.gwt.core.client.Callback;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class GWTMessages {

@ -14,8 +14,8 @@ import com.google.gwt.user.client.ui.HTML;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class WaitDialog extends DialogBox {

@ -10,8 +10,8 @@ import com.google.gwt.user.client.ui.SimplePanel;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class SimpleWizardCard extends WizardCard {

@ -17,8 +17,8 @@ import com.google.gwt.user.client.ui.Widget;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class WizardCard extends SimplePanel {

@ -5,7 +5,7 @@ import com.google.gwt.i18n.client.Messages;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*
*/
public interface WizardMessages extends Messages {

@ -37,8 +37,8 @@ import com.google.gwt.user.client.ui.Widget;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEventHandler {
@ -73,11 +73,10 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
// protected FillToolItem fillSpacingCardMoveToolBar;
protected WizardMessages msgs;
protected DeckPanel deckPanel;
private Node closeEventTarget = null;
private int zIndex=-1;
private int zIndex = -1;
/**
* Create a new Wizard Window with the specified title.
@ -102,17 +101,10 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
deckPanel = new DeckPanel();
backButton = new Button("<div><img class='"
+ GCResources.INSTANCE.wizardCSS()
.getWizardPreviousButtonIcon()
+ "' src='"
+ GCResources.INSTANCE.wizardPrevious24().getSafeUri()
.asString()
+ "'/>"
+ "<span class='"
+ GCResources.INSTANCE.wizardCSS()
.getWizardPreviousButtonText() + "'>"
+ msgs.buttonBackLabel() + "</span>" + "</div>");
backButton = new Button("<div><img class='" + GCResources.INSTANCE.wizardCSS().getWizardPreviousButtonIcon()
+ "' src='" + GCResources.INSTANCE.wizardPrevious24().getSafeUri().asString() + "'/>" + "<span class='"
+ GCResources.INSTANCE.wizardCSS().getWizardPreviousButtonText() + "'>" + msgs.buttonBackLabel()
+ "</span>" + "</div>");
backButton.setEnabled(false);
backButton.setTabIndex(1001);
@ -163,15 +155,14 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
}
private void initHandler() {
resizeHandlerRegistration = Window
.addResizeHandler(new ResizeHandler() {
resizeHandlerRegistration = Window.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
center();
@Override
public void onResize(ResizeEvent event) {
center();
}
});
}
});
}
@ -184,7 +175,6 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
this.originalTitle = title;
}
/**
* Shows the next available card.
*/
@ -279,7 +269,7 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
/**
* Returns the number of available cards.
*
* @return
* @return the number of available cards
*/
public int getCardStackSize() {
return cardStack.size();
@ -288,7 +278,7 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
/**
* Returns the current active card.
*
* @return
* @return active card position
*/
public int getCurrentCard() {
int index = deckPanel.getVisibleWidget();
@ -309,13 +299,10 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
* Sets the label of next button to "Finish" value
*/
public void setNextButtonToFinish() {
nextButton.setHTML("<div><span class='"
+ GCResources.INSTANCE.wizardCSS().getWizardNextButtonText()
+ "'>" + msgs.buttonFinishLabel() + "</span>" + "<img class='"
+ GCResources.INSTANCE.wizardCSS().getWizardNextButtonIcon()
+ "'" + " src='"
+ GCResources.INSTANCE.wizardGo24().getSafeUri().asString()
+ "'/></div>");
nextButton.setHTML("<div><span class='" + GCResources.INSTANCE.wizardCSS().getWizardNextButtonText() + "'>"
+ msgs.buttonFinishLabel() + "</span>" + "<img class='"
+ GCResources.INSTANCE.wizardCSS().getWizardNextButtonIcon() + "'" + " src='"
+ GCResources.INSTANCE.wizardGo24().getSafeUri().asString() + "'/></div>");
// nextButton.setIcon(GCResources.INSTANCE.wizardGo());
// nextButton.setIconAlign(IconAlign.RIGHT);
/*
@ -327,13 +314,10 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
}
public void setNextButtonToDefault() {
nextButton.setHTML("<div><span class='"
+ GCResources.INSTANCE.wizardCSS().getWizardNextButtonText()
+ "'>" + msgs.buttonNextLabel() + "</span>" + "<img class='"
+ GCResources.INSTANCE.wizardCSS().getWizardNextButtonIcon()
+ "'" + " src='"
+ GCResources.INSTANCE.wizardNext24().getSafeUri().asString()
+ "'/></div>");
nextButton.setHTML("<div><span class='" + GCResources.INSTANCE.wizardCSS().getWizardNextButtonText() + "'>"
+ msgs.buttonNextLabel() + "</span>" + "<img class='"
+ GCResources.INSTANCE.wizardCSS().getWizardNextButtonIcon() + "'" + " src='"
+ GCResources.INSTANCE.wizardNext24().getSafeUri().asString() + "'/></div>");
}
/**
@ -402,6 +386,7 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
* Set the card list.
*
* @param cards
* set the card list
*/
public void setCards(ArrayList<WizardCard> cards) {
for (WizardCard card : cards) {
@ -477,6 +462,7 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
* Sets visible next button.
*
* @param visible
* true if next button is visible
*/
protected void setNextButtonVisible(boolean visible) {
nextButton.setVisible(visible);
@ -486,6 +472,7 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
* Sets visible back button.
*
* @param visible
* true if back button is visible
*/
protected void setBackButtonVisible(boolean visible) {
backButton.setVisible(visible);
@ -516,20 +503,16 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
public ArrayList<WizardCard> getCardStack() {
return cardStack;
}
public void showErrorAndHide(final String title, final String message) {
showErrorAndHide(title, message,
new Throwable());
}
public void showErrorAndHide(final String title, final String message,
final Throwable throwable) {
final WizardEvent event=new WizardEvent(WizardEventType.Failed);
showErrorAndHide(title, message, new Throwable());
}
public void showErrorAndHide(final String title, final String message, final Throwable throwable) {
final WizardEvent event = new WizardEvent(WizardEventType.Failed);
event.setErrorMessage(message);
event.setException(new Exception(throwable));
GWTMessages.alert(title, message, getZIndex(), new Callback<Void, Void>() {
@Override
@ -550,24 +533,15 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
}
private void addToolIcon() {
// get the "dialogTopRight" class td
Element dialogTopRight = getCellElement(0, 2);
// close button image html
dialogTopRight.setInnerHTML("<div class='"
+ GCResources.INSTANCE.wizardCSS().getWizardToolButtonText()
+ "'>"
+ "<img src='"
+ GCResources.INSTANCE.toolButtonClose20().getSafeUri()
.asString() + "' class='"
+ GCResources.INSTANCE.wizardCSS().getWizardToolButtonIcon()
+ "' /></div>");
dialogTopRight.setInnerHTML("<div class='" + GCResources.INSTANCE.wizardCSS().getWizardToolButtonText() + "'>"
+ "<img src='" + GCResources.INSTANCE.toolButtonClose20().getSafeUri().asString() + "' class='"
+ GCResources.INSTANCE.wizardCSS().getWizardToolButtonIcon() + "' /></div>");
// set the event target
closeEventTarget = dialogTopRight.getChild(0).getChild(0);
@ -577,9 +551,8 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
protected void onPreviewNativeEvent(NativePreviewEvent event) {
NativeEvent nativeEvent = event.getNativeEvent();
if (!event.isCanceled() && (event.getTypeInt() == Event.ONCLICK)
&& isCloseEvent(nativeEvent)) {
final WizardEvent wizardEvent=new WizardEvent(WizardEventType.Aborted);
if (!event.isCanceled() && (event.getTypeInt() == Event.ONCLICK) && isCloseEvent(nativeEvent)) {
final WizardEvent wizardEvent = new WizardEvent(WizardEventType.Aborted);
fireEvent(wizardEvent);
this.hide();
}
@ -601,15 +574,14 @@ public class WizardWindow extends DialogBox implements WizardEvent.HasWizardEven
}
public void setZIndex(int zIndex) {
this.zIndex=zIndex;
this.zIndex = zIndex;
getGlassElement().getStyle().setZIndex(zIndex);
getElement().getStyle().setZIndex(zIndex+1);
getElement().getStyle().setZIndex(zIndex + 1);
}
public int getZIndex(){
public int getZIndex() {
return zIndex;
}
}

@ -9,8 +9,8 @@ import com.google.gwt.event.shared.HasHandlers;
* Wizard Event
*
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class WizardEvent extends GwtEvent<WizardEvent.WizardEventHandler> {

@ -5,17 +5,13 @@ import java.util.List;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public enum WizardEventType {
Completed("Completed"), Failed("Failed"), Aborted("Aborted"), Background(
"Background");
Completed("Completed"), Failed("Failed"), Aborted("Aborted"), Background("Background");
/**
* @param text
*/
private WizardEventType(final String id) {
this.id = id;
}
@ -35,11 +31,6 @@ public enum WizardEventType {
return id;
}
/**
*
* @param id
* @return
*/
public static WizardEventType getTypeFromId(String id) {
if (id == null || id.isEmpty())
return null;

@ -18,7 +18,7 @@ import org.slf4j.LoggerFactory;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*
*/
public class GitHubConnectorPortlet extends GenericPortlet {

@ -19,8 +19,8 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
@SuppressWarnings("serial")

@ -18,8 +18,8 @@ import org.gcube.vomanagement.usermanagement.model.GCubeUser;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
@ -30,11 +30,12 @@ public class SessionUtil {
/**
*
* @param httpServletRequest
* @return
* @throws TDGWTServiceException
* http servlet request
* @return service credentials
* @throws ServiceException
* service exception
*/
public static ServiceCredentials getServiceCredentials(
HttpServletRequest httpServletRequest)
public static ServiceCredentials getServiceCredentials(HttpServletRequest httpServletRequest)
throws ServiceException {
return getServiceCredentials(httpServletRequest, null);
}
@ -42,12 +43,14 @@ public class SessionUtil {
/**
*
* @param httpServletRequest
* http service request
* @param scopeGroupId
* @return
* @throws TDGWTServiceException
* scope group id
* @return service credentials
* @throws ServiceException
* service exception
*/
public static ServiceCredentials getServiceCredentials(
HttpServletRequest httpServletRequest, String scopeGroupId)
public static ServiceCredentials getServiceCredentials(HttpServletRequest httpServletRequest, String scopeGroupId)
throws ServiceException {
ServiceCredentials sCredentials = null;
@ -105,8 +108,7 @@ public class SessionUtil {
GCubeUser gCubeUser = pContext.getCurrentUser(httpServletRequest);
if (gCubeUser == null) {
String error = "Error retrieving gCubeUser in scope " + scope
+ ": " + gCubeUser;
String error = "Error retrieving gCubeUser in scope " + scope + ": " + gCubeUser;
logger.error(error);
throw new ServiceException(error);
}
@ -114,8 +116,7 @@ public class SessionUtil {
userName = gCubeUser.getUsername();
if (userName == null || userName.isEmpty()) {
String error = "Error retrieving username in scope " + scope
+ ": " + userName;
String error = "Error retrieving username in scope " + scope + ": " + userName;
logger.error(error);
throw new ServiceException(error);
}
@ -123,8 +124,7 @@ public class SessionUtil {
token = pContext.getCurrentUserToken(scope, userName);
if (token == null || token.isEmpty()) {
String error = "Error retrieving token for " + userName
+ " in " + scope + ": " + token;
String error = "Error retrieving token for " + userName + " in " + scope + ": " + token;
logger.error(error);
throw new ServiceException(error);
}
@ -168,16 +168,14 @@ public class SessionUtil {
} else {
groupId = String.valueOf(pContext
.getCurrentGroupId(httpServletRequest));
groupId = String.valueOf(pContext.getCurrentGroupId(httpServletRequest));
groupName = pContext.getCurrentGroupName(httpServletRequest);
}
sCredentials = new ServiceCredentials(userName, fullName, name,
lastName, email, scope, groupId, groupName, userAvatarURL,
token);
sCredentials = new ServiceCredentials(userName, fullName, name, lastName, email, scope, groupId, groupName,
userAvatarURL, token);
}
logger.info("ServiceCredentials: " + sCredentials);
@ -185,5 +183,4 @@ public class SessionUtil {
return sCredentials;
}
}

@ -24,8 +24,8 @@ import org.slf4j.LoggerFactory;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class GitConnectorService {
@ -37,8 +37,8 @@ public class GitConnectorService {
/**
*
* @param userName
* @param gitHubCredential
* @param userName user name
* @param gitHubCredential github credential
*/
public GitConnectorService(String userName, GitHubCredential gitHubCredential) {
this.userName = userName;

@ -12,44 +12,36 @@ import org.gcube.portlets.widgets.githubconnector.shared.git.data.GitHubUser;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*
*/
public class GitHubRepositoryBuilder {
private static Logger logger = Logger
.getLogger(GitHubRepositoryBuilder.class);
private static Logger logger = Logger.getLogger(GitHubRepositoryBuilder.class);
/**
*
* @param repository
* @return
* repository
* @return github repository
* @throws ServiceException
* service exception
*/
public static GitHubRepository build(Repository repository)
throws ServiceException {
public static GitHubRepository build(Repository repository) throws ServiceException {
try {
if (repository != null) {
if (repository.getOwner() != null) {
GitHubUser gitHubUser = new GitHubUser(repository
.getOwner().getId(), repository.getOwner()
.getName(), repository.getOwner().getLogin(),
repository.getOwner().getCompany(), repository
.getOwner().getLocation(), repository
.getOwner().getUrl(), repository.getOwner()
.getEmail());
GitHubUser gitHubUser = new GitHubUser(repository.getOwner().getId(),
repository.getOwner().getName(), repository.getOwner().getLogin(),
repository.getOwner().getCompany(), repository.getOwner().getLocation(),
repository.getOwner().getUrl(), repository.getOwner().getEmail());
GitHubRepository gitHubRepository = new GitHubRepository(
repository.getId(), repository.getName(),
gitHubUser, repository.getDescription(),
repository.getGitUrl(), repository.getWatchers(),
repository.getCreatedAt(),
repository.getUpdatedAt());
GitHubRepository gitHubRepository = new GitHubRepository(repository.getId(), repository.getName(),
gitHubUser, repository.getDescription(), repository.getGitUrl(), repository.getWatchers(),
repository.getCreatedAt(), repository.getUpdatedAt());
return gitHubRepository;
} else {
logger.error("Invalid owner for repository: "
+ repository.getName());
throw new ServiceException("Invalid owner for repository: "
+ repository.getName());
logger.error("Invalid owner for repository: " + repository.getName());
throw new ServiceException("Invalid owner for repository: " + repository.getName());
}
} else {
logger.error("Invalid repository: null");
@ -67,11 +59,12 @@ public class GitHubRepositoryBuilder {
/**
*
* @param repositories
* @return
* list of repositories
* @return list of github repository
* @throws ServiceException
* service exception
*/
public static ArrayList<GitHubRepository> build(
List<Repository> repositories) throws ServiceException {
public static ArrayList<GitHubRepository> build(List<Repository> repositories) throws ServiceException {
if (repositories != null) {
ArrayList<GitHubRepository> gitHubRepositories = new ArrayList<>();
for (Repository repository : repositories) {

@ -19,8 +19,8 @@ import org.gcube.portlets.widgets.githubconnector.shared.exception.ServiceExcept
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class StorageUtil {
@ -30,11 +30,13 @@ public class StorageUtil {
/**
*
* @param user
* user
* @param itemId
* item id
* @throws ServiceException
* service exception
*/
public static void deleteItem(String user, String itemId)
throws ServiceException {
public static void deleteItem(String user, String itemId) throws ServiceException {
Workspace ws;
try {
logger.debug("User: " + user + ", ItemId:" + itemId);
@ -43,8 +45,7 @@ public class StorageUtil {
ws.removeItems(itemId);
return;
} catch (InsufficientPrivilegesException
| WorkspaceFolderNotFoundException | InternalErrorException
} catch (InsufficientPrivilegesException | WorkspaceFolderNotFoundException | InternalErrorException
| HomeNotFoundException | ItemNotFoundException e) {
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage(), e);
@ -52,71 +53,74 @@ public class StorageUtil {
}
}
/**
*
* @param user
* user
* @param destinationFolderId
* destination folder id
* @param folderName
* folder name
* @param folderDescription
* @return
* folder description
* @return folder id
* @throws ServiceException
* service exception
*/
public static String createFolderOnWorkspace(String user,
String destinationFolderId, String folderName,
public static String createFolderOnWorkspace(String user, String destinationFolderId, String folderName,
String folderDescription) throws ServiceException {
try {
logger.debug("CreateFolderOnWorkspace: [User=" + user
+ ", FolderId:" + destinationFolderId + ", folderName="
+ folderName + ", folderDescription=" + folderDescription
+ "]");
logger.debug("CreateFolderOnWorkspace: [User=" + user + ", FolderId:" + destinationFolderId
+ ", folderName=" + folderName + ", folderDescription=" + folderDescription + "]");
Workspace ws = HomeLibrary.getUserWorkspace(user);
WorkspaceFolder workspaceFolder=ws.createFolder(folderName, folderDescription, destinationFolderId);
WorkspaceFolder workspaceFolder = ws.createFolder(folderName, folderDescription, destinationFolderId);
return workspaceFolder.getId();
} catch (WorkspaceFolderNotFoundException | InternalErrorException
| HomeNotFoundException | InsufficientPrivilegesException | ItemAlreadyExistException | WrongDestinationException | ItemNotFoundException e) {
} catch (WorkspaceFolderNotFoundException | InternalErrorException | HomeNotFoundException
| InsufficientPrivilegesException | ItemAlreadyExistException | WrongDestinationException
| ItemNotFoundException e) {
logger.error("CreateFolderOnWorkspace: " + e.getLocalizedMessage());
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
/**
*
* @param user
* user
* @param destinationFolderId
* destination folder id
* @param fileName
* file name
* @param fileDescription
* @param mimeType
* file description
* @param is
* @return
* input stream
* @return file id
* @throws ServiceException
* service exception
*/
public static String saveOnWorkspace(String user,
String destinationFolderId, String fileName,
String fileDescription, InputStream is)
throws ServiceException {
public static String saveOnWorkspace(String user, String destinationFolderId, String fileName,
String fileDescription, InputStream is) throws ServiceException {
try {
logger.debug("saveOnWorkspace: [User=" + user + ", FolderId:"
+ destinationFolderId + ", fileName=" + fileName
+ ", fileDescription=" + fileDescription + "]");
logger.debug("saveOnWorkspace: [User=" + user + ", FolderId:" + destinationFolderId + ", fileName="
+ fileName + ", fileDescription=" + fileDescription + "]");
Workspace ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workspaceItem = ws.getItem(destinationFolderId);
if (workspaceItem.isFolder()) {
ExternalFile externalfile = ws.createExternalFile(fileName,
fileDescription, null, is, destinationFolderId);
ExternalFile externalfile = ws.createExternalFile(fileName, fileDescription, null, is,
destinationFolderId);
return externalfile.getId();
} else {
throw new ServiceException("Invalid destination folder!");
}
} catch (WorkspaceFolderNotFoundException | InternalErrorException
| HomeNotFoundException | InsufficientPrivilegesException
| ItemAlreadyExistException | WrongDestinationException
} catch (WorkspaceFolderNotFoundException | InternalErrorException | HomeNotFoundException
| InsufficientPrivilegesException | ItemAlreadyExistException | WrongDestinationException
| ItemNotFoundException e) {
logger.error("SaveOnWorkspace: " + e.getLocalizedMessage());
e.printStackTrace();

@ -4,8 +4,8 @@ import java.io.Serializable;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class ServiceCredentials implements Serializable {

@ -3,7 +3,7 @@ package org.gcube.portlets.widgets.githubconnector.shared;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*
*/
public class Constants {

@ -5,11 +5,10 @@ package org.gcube.portlets.widgets.githubconnector.shared.exception;
*
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*
*/
public class ExpiredSessionServiceException extends
ServiceException {
public class ExpiredSessionServiceException extends ServiceException {
private static final long serialVersionUID = -4831171355042165166L;
@ -22,6 +21,7 @@ public class ExpiredSessionServiceException extends
/**
* @param message
* message
*/
public ExpiredSessionServiceException(String message) {
super(message);
@ -30,10 +30,12 @@ public class ExpiredSessionServiceException extends
/**
*
* @param message
* @param t
* message
* @param throwable
* throwable
*/
public ExpiredSessionServiceException(String message, Throwable t) {
super(message, t);
public ExpiredSessionServiceException(String message, Throwable throwable) {
super(message, throwable);
}
}

@ -5,16 +5,14 @@ package org.gcube.portlets.widgets.githubconnector.shared.exception;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class ServiceException extends Exception {
private static final long serialVersionUID = -2255657546267656458L;
/**
*
*/
@ -24,15 +22,21 @@ public class ServiceException extends Exception {
/**
* @param message
* message
*/
public ServiceException(String message) {
super(message);
}
public ServiceException(String message,Throwable t) {
super(message,t);
/**
*
* @param message
* message
* @param throwable
* throwable
*/
public ServiceException(String message, Throwable throwable) {
super(message, throwable);
}
}

@ -6,8 +6,8 @@ import org.gcube.portlets.widgets.githubconnector.shared.git.data.credential.Git
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class GitHubCloneSession implements Serializable {
@ -20,25 +20,29 @@ public class GitHubCloneSession implements Serializable {
public GitHubCloneSession() {
super();
}
/**
*
* @param destinationFolderId
* destination folder id
*/
public GitHubCloneSession(String destinationFolderId) {
super();
this.destinationFolderId = destinationFolderId;
}
/**
*
* @param destinationFolderId
* destination folder id
* @param gitHubCredential
* git hub credential
* @param repositoryOwner
* repository owner
* @param repositoryName
* repository name
*/
public GitHubCloneSession(String destinationFolderId,
GitHubCredential gitHubCredential, String repositoryOwner,
public GitHubCloneSession(String destinationFolderId, GitHubCredential gitHubCredential, String repositoryOwner,
String repositoryName) {
super();
this.destinationFolderId = destinationFolderId;
@ -81,12 +85,9 @@ public class GitHubCloneSession implements Serializable {
@Override
public String toString() {
return "GitHubCloneSession [destinationFolderId=" + destinationFolderId
+ ", gitHubCredential=" + gitHubCredential
+ ", repositoryOwner=" + repositoryOwner + ", repositoryName="
+ repositoryName + "]";
return "GitHubCloneSession [destinationFolderId=" + destinationFolderId + ", gitHubCredential="
+ gitHubCredential + ", repositoryOwner=" + repositoryOwner + ", repositoryName=" + repositoryName
+ "]";
}
}

@ -6,7 +6,7 @@ import java.util.Date;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*
*/
public class GitHubRepository implements Serializable {

@ -5,7 +5,7 @@ import java.io.Serializable;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*
*/
public class GitHubUser implements Serializable {

@ -4,8 +4,8 @@ import java.io.Serializable;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class GitHubCredential implements Serializable {

@ -3,7 +3,7 @@ package org.gcube.portlets.widgets.githubconnector.shared.git.data.credential;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*
*/
public class GitHubCredentialAnonymous extends GitHubCredential {

@ -2,8 +2,8 @@ package org.gcube.portlets.widgets.githubconnector.shared.git.data.credential;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class GitHubCredentialLogin extends GitHubCredential {

@ -2,8 +2,8 @@ package org.gcube.portlets.widgets.githubconnector.shared.git.data.credential;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class GitHubCredentialOAuth2 extends GitHubCredential {

@ -4,7 +4,7 @@ package org.gcube.portlets.widgets.githubconnector.shared.git.data.credential;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*
*/
public enum GitHubCredentialType {

@ -4,8 +4,8 @@ import java.io.Serializable;
/**
*
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class UserInfo implements Serializable {
@ -26,15 +26,20 @@ public class UserInfo implements Serializable {
/**
*
* @param username
* user name
* @param groupId
* group id
* @param groupName
* group name
* @param scope
* @param scopeName
* scope
* @param userEmailAddress
* email
* @param userFullName
* full name
*/
public UserInfo(String username, String groupId, String groupName,
String scope, String userEmailAddress, String userFullName) {
public UserInfo(String username, String groupId, String groupName, String scope, String userEmailAddress,
String userFullName) {
super();
this.username = username;
this.groupId = groupId;
@ -94,10 +99,8 @@ public class UserInfo implements Serializable {
@Override
public String toString() {
return "UserInfo [username=" + username + ", groupId=" + groupId
+ ", groupName=" + groupName + ", scope=" + scope
+ ", userEmailAddress=" + userEmailAddress + ", userFullName="
+ userFullName + "]";
return "UserInfo [username=" + username + ", groupId=" + groupId + ", groupName=" + groupName + ", scope="
+ scope + ", userEmailAddress=" + userEmailAddress + ", userFullName=" + userFullName + "]";
}
}

@ -23,8 +23,8 @@ import org.slf4j.LoggerFactory;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author Giancarlo Panichi
*
*
*/
public class GitHubConnectorTest extends TestCase {

Loading…
Cancel
Save