diff --git a/core/src/org/pentaho/di/core/extension/KettleExtensionPoint.java b/core/src/org/pentaho/di/core/extension/KettleExtensionPoint.java
index eaa78e4c0591..2c543ff8d601 100644
--- a/core/src/org/pentaho/di/core/extension/KettleExtensionPoint.java
+++ b/core/src/org/pentaho/di/core/extension/KettleExtensionPoint.java
@@ -114,6 +114,7 @@ public enum KettleExtensionPoint {
RepositoryImporterPatchTransStep( "RepositoryImporterPatchTransStep", "Patch the step in a transformation during repository import" ),
RepositoryExporterPatchTransStep( "RepositoryExporterPatchTransStep", "Patch the step in a transformation during repository export" ),
+ RequestLoginToRepository( "RequestLoginToRepository", "Request to login into repository" ),
OpenMapping( "OpenMapping", "Trigger when opening a mapping from TransGraph" ),
diff --git a/plugins/repositories-plugin/src/main/java/org/pentaho/di/ui/repo/RepositoryDialog.java b/plugins/repositories-plugin/src/main/java/org/pentaho/di/ui/repo/RepositoryDialog.java
index 20a2fb97fde9..e86ef16473e0 100644
--- a/plugins/repositories-plugin/src/main/java/org/pentaho/di/ui/repo/RepositoryDialog.java
+++ b/plugins/repositories-plugin/src/main/java/org/pentaho/di/ui/repo/RepositoryDialog.java
@@ -272,9 +272,9 @@ public boolean openRelogin( RepositoryMeta repositoryMeta, String errorMessage )
return open( repositoryMeta, true, errorMessage );
}
- public void openLogin( RepositoryMeta repositoryMeta ) {
+ public boolean openLogin( RepositoryMeta repositoryMeta ) {
super.createDialog( LOGIN_TITLE, getRepoURL( LOGIN_WEB_CLIENT_PATH ), OPTIONS, LOGO );
- open( repositoryMeta );
+ return open( repositoryMeta );
}
private void setResult( boolean result ) {
diff --git a/plugins/repositories-plugin/src/main/java/org/pentaho/di/ui/repo/RequestLoginToRepositoryExtensionPoint.java b/plugins/repositories-plugin/src/main/java/org/pentaho/di/ui/repo/RequestLoginToRepositoryExtensionPoint.java
new file mode 100644
index 000000000000..3c7898ad92de
--- /dev/null
+++ b/plugins/repositories-plugin/src/main/java/org/pentaho/di/ui/repo/RequestLoginToRepositoryExtensionPoint.java
@@ -0,0 +1,119 @@
+/*! ******************************************************************************
+ *
+ * Pentaho Data Integration
+ *
+ * Copyright (C) 2002-2016 by Pentaho : http://www.pentaho.com
+ *
+ *******************************************************************************
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+package org.pentaho.di.ui.repo;
+
+import org.pentaho.di.core.exception.KettleException;
+import org.pentaho.di.core.extension.ExtensionPoint;
+import org.pentaho.di.core.extension.ExtensionPointInterface;
+import org.pentaho.di.core.logging.LogChannelInterface;
+import org.pentaho.di.i18n.BaseMessages;
+import org.pentaho.di.repository.Repository;
+import org.pentaho.di.repository.RepositoryMeta;
+import org.pentaho.di.ui.repository.ILoginCallback;
+import org.pentaho.di.ui.spoon.Spoon;
+
+@ExtensionPoint(
+ id = "RequestLoginToRepositoryExtensionPoint",
+ extensionPointId = "RequestLoginToRepository",
+ description = "Handles login requests"
+ )
+public class RequestLoginToRepositoryExtensionPoint implements ExtensionPointInterface {
+
+ private static Class> PKG = RequestLoginToRepositoryExtensionPoint.class;
+
+ private static final String KETTE_FILE_REPOSITORY_ID = "KettleFileRepository";
+
+ private final ILoginCallback defaultLoginCallback = new DefaultLoginCallback();
+
+ private final RepositoryConnectController repositoryConnectController;
+
+ public RequestLoginToRepositoryExtensionPoint( RepositoryConnectController repositoryConnectController ) {
+ this.repositoryConnectController = repositoryConnectController;
+ }
+
+ @Override
+ public void callExtensionPoint( LogChannelInterface log, Object object ) throws KettleException {
+ ILoginCallback loginCallback = defaultLoginCallback;
+ if ( ( object instanceof ILoginCallback ) ) {
+ loginCallback = (ILoginCallback) object;
+ }
+ RepositoryMeta repositoryMeta = findRepositoryToConnect();
+ if ( repositoryMeta != null ) {
+ if ( isKettleFileRepository( repositoryMeta ) ) {
+ repositoryConnectController.connectToRepository( repositoryMeta );
+ loginCallback.onSuccess( repositoryConnectController.getConnectedRepositoryInstance() );
+ } else {
+ loginToRepository( repositoryMeta, loginCallback );
+ }
+ } else {
+ String errorMessage = BaseMessages.getString( PKG, "Repository.NoDefinedRepositoryToConnect" );
+ KettleException exception = new KettleException( errorMessage );
+ loginCallback.onError( exception );
+ }
+ }
+
+ void loginToRepository( RepositoryMeta repositoryMeta, ILoginCallback loginCallback ) {
+ RepositoryDialog dialog = getRepositoryDialog();
+ boolean result = dialog.openLogin( repositoryMeta );
+ if ( result ) {
+ loginCallback.onSuccess( repositoryConnectController.getConnectedRepositoryInstance() );
+ } else {
+ loginCallback.onCancel();
+ }
+ }
+
+ RepositoryDialog getRepositoryDialog() {
+ return new RepositoryDialog( getSpoon().getShell(), repositoryConnectController );
+ }
+
+ RepositoryMeta findRepositoryToConnect() {
+ RepositoryMeta repositoryMeta = repositoryConnectController.getCurrentRepository();
+ if ( repositoryMeta == null ) {
+ repositoryMeta = repositoryConnectController.getDefaultRepositoryMeta();
+ }
+ return repositoryMeta;
+ }
+
+ static boolean isKettleFileRepository( RepositoryMeta repositoryMeta ) {
+ return KETTE_FILE_REPOSITORY_ID.equals( repositoryMeta.getId() );
+ }
+
+ private Spoon getSpoon() {
+ return Spoon.getInstance();
+ }
+
+ private final class DefaultLoginCallback implements ILoginCallback {
+
+ @Override
+ public void onSuccess( Repository repository ) {
+ }
+
+ @Override
+ public void onCancel() {
+ }
+
+ @Override
+ public void onError( Throwable t ) {
+ }
+ }
+}
diff --git a/plugins/repositories-plugin/src/main/resources/OSGI-INF/blueprint/beans.xml b/plugins/repositories-plugin/src/main/resources/OSGI-INF/blueprint/beans.xml
index 58cc92b26424..4ddbb8c816a6 100644
--- a/plugins/repositories-plugin/src/main/resources/OSGI-INF/blueprint/beans.xml
+++ b/plugins/repositories-plugin/src/main/resources/OSGI-INF/blueprint/beans.xml
@@ -25,6 +25,12 @@
+
+
+
+
+
diff --git a/plugins/repositories-plugin/src/main/resources/org/pentaho/di/ui/repo/messages/messages_en_US.properties b/plugins/repositories-plugin/src/main/resources/org/pentaho/di/ui/repo/messages/messages_en_US.properties
index 9cca07e0d152..930c2e2a49ad 100644
--- a/plugins/repositories-plugin/src/main/resources/org/pentaho/di/ui/repo/messages/messages_en_US.properties
+++ b/plugins/repositories-plugin/src/main/resources/org/pentaho/di/ui/repo/messages/messages_en_US.properties
@@ -12,6 +12,7 @@ RepositoryConnection.Error.InvalidServer=You don''t seem to be getting a connect
Repository.NoConnected.Message=Sorry, we didn''t recognize those connection details. Please check the user name and password and try again.
Repository.NoConnected.Message.Title=Unable to Login
Repository.Reconnection.Message=You''ve been disconnected due to inactivity. Please reconnect to continue.
+Repository.NoDefinedRepositoryToConnect=Can''t choose repository connection to process login request. Use connection menu to login into a repository.
RepositoryDialog.Dialog.NewRepo.Title=New Repository Connection
RepositoryDialog.Dialog.Manager.Title=Repository Manager