teiid SVN: r739 - in trunk: server/src/main/java/com/metamatrix/common/comm/platform/socket/server and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-09 14:18:42 -0400 (Thu, 09 Apr 2009)
New Revision: 739
Modified:
trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerConfigAdmin.java
trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerMonitoringAdmin.java
trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerRuntimeStateAdmin.java
trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerSecurityAdmin.java
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/AdminAuthorizationInterceptor.java
trunk/server/src/test/java/com/metamatrix/common/comm/platform/server/TestAdminAuthInterceptor.java
Log:
TEIID-275 interfaces do not directly inherit annotations, so we need to add base roles to the server admin interfaces
Modified: trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerConfigAdmin.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerConfigAdmin.java 2009-04-09 17:37:28 UTC (rev 738)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerConfigAdmin.java 2009-04-09 18:18:42 UTC (rev 739)
@@ -22,15 +22,16 @@
package com.metamatrix.admin.api.server;
-import java.util.Properties;
+import java.util.Properties;
+
+import com.metamatrix.admin.RolesAllowed;
+import com.metamatrix.admin.api.core.CoreConfigAdmin;
+import com.metamatrix.admin.api.exception.AdminException;
+import com.metamatrix.admin.api.objects.ConnectorBinding;
+import com.metamatrix.admin.api.objects.ScriptsContainer;
+import com.metamatrix.admin.api.objects.VDB;
-import com.metamatrix.admin.api.core.CoreConfigAdmin;
-import com.metamatrix.admin.api.objects.ConnectorBinding;
-import com.metamatrix.admin.api.objects.ScriptsContainer;
-import com.metamatrix.admin.api.objects.VDB;
-import com.metamatrix.admin.api.exception.AdminException;
-
/**
* Interface that exposes MetaMatrix server configuration for administration.
* <p>
@@ -38,7 +39,8 @@
* </p>
*
* @since 4.3
- */
+ */
+(a)RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
public interface ServerConfigAdmin extends
CoreConfigAdmin {
Modified: trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerMonitoringAdmin.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerMonitoringAdmin.java 2009-04-09 17:37:28 UTC (rev 738)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerMonitoringAdmin.java 2009-04-09 18:18:42 UTC (rev 739)
@@ -36,6 +36,7 @@
* should instead use {@link ServerAdmin}.</p>
* @since 4.3
*/
+(a)RolesAllowed(value=AdminRoles.RoleName.ADMIN_READONLY)
public interface ServerMonitoringAdmin extends CoreMonitoringAdmin {
/**
Modified: trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerRuntimeStateAdmin.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerRuntimeStateAdmin.java 2009-04-09 17:37:28 UTC (rev 738)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerRuntimeStateAdmin.java 2009-04-09 18:18:42 UTC (rev 739)
@@ -22,6 +22,7 @@
package com.metamatrix.admin.api.server;
+import com.metamatrix.admin.RolesAllowed;
import com.metamatrix.admin.api.core.CoreRuntimeStateAdmin;
import com.metamatrix.admin.api.exception.AdminException;
@@ -33,6 +34,7 @@
* should instead use {@link ServerAdmin}.</p>
* @since 4.3
*/
+(a)RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
public interface ServerRuntimeStateAdmin extends CoreRuntimeStateAdmin {
/**
Modified: trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerSecurityAdmin.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerSecurityAdmin.java 2009-04-09 17:37:28 UTC (rev 738)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerSecurityAdmin.java 2009-04-09 18:18:42 UTC (rev 739)
@@ -26,6 +26,7 @@
import java.util.Collection;
import java.util.List;
+import com.metamatrix.admin.RolesAllowed;
import com.metamatrix.admin.api.core.CoreSecurityAdmin;
import com.metamatrix.admin.api.exception.AdminException;
import com.metamatrix.admin.api.objects.AdminObject;
@@ -43,6 +44,7 @@
*
* @since 4.3
*/
+(a)RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
public interface ServerSecurityAdmin extends CoreSecurityAdmin {
/**
Modified: trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/AdminAuthorizationInterceptor.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/AdminAuthorizationInterceptor.java 2009-04-09 17:37:28 UTC (rev 738)
+++ trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/AdminAuthorizationInterceptor.java 2009-04-09 18:18:42 UTC (rev 739)
@@ -30,7 +30,6 @@
import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.admin.RolesAllowed;
-import com.metamatrix.admin.api.exception.AdminProcessingException;
import com.metamatrix.admin.api.server.AdminRoles;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.api.exception.security.AuthorizationException;
Modified: trunk/server/src/test/java/com/metamatrix/common/comm/platform/server/TestAdminAuthInterceptor.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/common/comm/platform/server/TestAdminAuthInterceptor.java 2009-04-09 17:37:28 UTC (rev 738)
+++ trunk/server/src/test/java/com/metamatrix/common/comm/platform/server/TestAdminAuthInterceptor.java 2009-04-09 18:18:42 UTC (rev 739)
@@ -72,6 +72,7 @@
return getTestServerAdmin(userRoles, iface, SimpleMock.createSimpleMock(iface));
}
+ @SuppressWarnings("unchecked")
private <T> T getTestServerAdmin(final Set<String> userRoles, Class<T> iface, T impl) {
AuthorizationServiceInterface service = Mockito.mock(AuthorizationServiceInterface.class);
try {
@@ -118,4 +119,12 @@
serverAdmin.getSourceDescriptors();
}
+ @Test public void testBounce_succeed() throws Exception {
+ Set<String> userRoles = new HashSet<String>();
+ userRoles.add(AdminRoles.RoleName.ADMIN_PRODUCT);
+ ServerAdmin serverAdmin = getTestServerAdmin(userRoles, ServerAdmin.class);
+ serverAdmin.bounceSystem(false);
+ }
+
+
}
15 years, 8 months
teiid SVN: r738 - trunk/common-internal/src/test/java/com/metamatrix/common/queue.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-09 13:37:28 -0400 (Thu, 09 Apr 2009)
New Revision: 738
Modified:
trunk/common-internal/src/test/java/com/metamatrix/common/queue/TestQueueWorkerPool.java
Log:
adding a valid range so that the test is more tolerant
Modified: trunk/common-internal/src/test/java/com/metamatrix/common/queue/TestQueueWorkerPool.java
===================================================================
--- trunk/common-internal/src/test/java/com/metamatrix/common/queue/TestQueueWorkerPool.java 2009-04-09 17:28:05 UTC (rev 737)
+++ trunk/common-internal/src/test/java/com/metamatrix/common/queue/TestQueueWorkerPool.java 2009-04-09 17:37:28 UTC (rev 738)
@@ -150,7 +150,7 @@
}, 0, 5, TimeUnit.MILLISECONDS);
Thread.sleep(99);
future.cancel(true);
- assertEquals(10, result.size());
+ assertTrue(result.size() > 8 && result.size() < 12);
}
@Test public void testFailingWork() throws Exception {
15 years, 8 months
teiid SVN: r737 - trunk/adminshell/src/main/resources/scripts.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-04-09 13:28:05 -0400 (Thu, 09 Apr 2009)
New Revision: 737
Modified:
trunk/adminshell/src/main/resources/scripts/adminapi.bsh
Log:
JBEDSP 977 - In updating the utility scripts, the adminapi.bsh needed to expose the method to support passing in the AdminOptions
Modified: trunk/adminshell/src/main/resources/scripts/adminapi.bsh
===================================================================
--- trunk/adminshell/src/main/resources/scripts/adminapi.bsh 2009-04-09 15:57:28 UTC (rev 736)
+++ trunk/adminshell/src/main/resources/scripts/adminapi.bsh 2009-04-09 17:28:05 UTC (rev 737)
@@ -13,7 +13,7 @@
/**
* Import a {@link VDB} file. <br>
- * A VDB file with internal definitions. This is the default VDB export configuration begining with MetaMatrix version 4.3.</br>
+ * A VDB file with internal definitions. This is the default VDB export configuration beginning with MetaMatrix version 4.3.</br>
*
* @param name
* VDB Name
@@ -33,7 +33,7 @@
/**
* Import a {@link VDB} file.
* <br>A VDB file with internal definitions. This is the default VDB export configuration
- * begining with MetaMatrix version 4.3.</br>
+ * beginning with MetaMatrix version 4.3.</br>
*
* @param name
* VDB Name
@@ -54,6 +54,28 @@
}
/**
+ * Import a {@link VDB} file.
+ * <br>A VDB file with internal definitions. This is the default VDB export configuration
+ * begining with MetaMatrix version 4.3.</br>
+ *
+ * @param name
+ * VDB Name
+ * @param vdbFile
+ * byte array of the VDB Archive
+ * @param AdminOptions that defines the options on how to import the vdb and its related connector bindings.
+ * See {@link AdminOptions}.
+ * @throws AdminException
+ * if there's a system error.
+ * @return the {@link VDB} representing the current property values and runtime state.
+ * @since 6.1.0
+ */
+VDB addVDB(String name, String vdbFile, AdminOptions options) {
+ debug("Adding VDB " + name + " from " + vdbFile);
+ checkAdmin();
+ return currentContext().internalAdmin.addVDB(name, readBinaryFile(vdbFile), options);
+}
+
+/**
* Export VDB to a file.
*
* @param name
15 years, 8 months
teiid SVN: r736 - branches.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-09 11:57:28 -0400 (Thu, 09 Apr 2009)
New Revision: 736
Added:
branches/remove_psc/
Log:
TEIID-323 adding a branch to remove psc
Copied: branches/remove_psc (from rev 735, trunk)
15 years, 8 months
teiid SVN: r735 - in trunk: server/src/main/java/com/metamatrix/admin and 3 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-09 11:53:24 -0400 (Thu, 09 Apr 2009)
New Revision: 735
Removed:
trunk/common-internal/src/main/java/com/metamatrix/common/xa/
trunk/server/src/main/java/com/metamatrix/admin/util/
trunk/server/src/main/resources/com/metamatrix/admin/util/
trunk/server/src/main/resources/com/metamatrix/service/
trunk/server/src/test/java/com/metamatrix/admin/util/
Log:
TEIID-275, TEIID-480 removing security boiler-plate code and ensuring subsystem calls must at least have readonly
15 years, 8 months
teiid SVN: r734 - in trunk: client/src/main/java/com/metamatrix/admin/api/core and 11 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-09 11:53:21 -0400 (Thu, 09 Apr 2009)
New Revision: 734
Added:
trunk/client/src/main/java/com/metamatrix/admin/RolesAllowed.java
Removed:
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/AdminHelper.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/IAdminHelper.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/SubSystemAdminAPIImpl.java
trunk/server/src/test/java/com/metamatrix/common/comm/platform/FakeAdminHelper.java
Modified:
trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreConfigAdmin.java
trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreMonitoringAdmin.java
trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreRuntimeStateAdmin.java
trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreSecurityAdmin.java
trunk/client/src/main/java/com/metamatrix/admin/api/server/AdminRoles.java
trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerAdmin.java
trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerMonitoringAdmin.java
trunk/client/src/main/java/com/metamatrix/client/ExceptionUtil.java
trunk/client/src/main/resources/com/metamatrix/common/comm/platform/i18n.properties
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/ConfigurationAdminAPI.java
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/ExtensionSourceAdminAPI.java
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/SubSystemAdminAPI.java
trunk/console/src/main/java/com/metamatrix/console/models/ExtensionSourceManager.java
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/AdminAuthorizationInterceptor.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/AdminAPIHelper.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/AuthorizationAdminAPIImpl.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ConfigurationAdminAPIImpl.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ExtensionSourceAdminAPIImpl.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIHelper.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIImpl.java
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java
trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataAdminAPIImpl.java
trunk/server/src/test/java/com/metamatrix/common/comm/platform/server/TestAdminAuthInterceptor.java
Log:
TEIID-275, TEIID-480 removing security boiler-plate code and ensuring subsystem calls must at least have readonly
Added: trunk/client/src/main/java/com/metamatrix/admin/RolesAllowed.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/RolesAllowed.java (rev 0)
+++ trunk/client/src/main/java/com/metamatrix/admin/RolesAllowed.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.admin;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Documented
+(a)Retention(value=RetentionPolicy.RUNTIME)
+(a)Target(value={ElementType.TYPE,ElementType.METHOD})
+public @interface RolesAllowed {
+ String[] value();
+}
Property changes on: trunk/client/src/main/java/com/metamatrix/admin/RolesAllowed.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreConfigAdmin.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreConfigAdmin.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreConfigAdmin.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -24,6 +24,7 @@
import java.util.Properties;
+import com.metamatrix.admin.RolesAllowed;
import com.metamatrix.admin.api.exception.AdminException;
import com.metamatrix.admin.api.objects.AdminObject;
import com.metamatrix.admin.api.objects.AdminOptions;
@@ -32,6 +33,7 @@
import com.metamatrix.admin.api.objects.ExtensionModule;
import com.metamatrix.admin.api.objects.LogConfiguration;
import com.metamatrix.admin.api.objects.VDB;
+import com.metamatrix.admin.api.server.AdminRoles;
/**
@@ -41,6 +43,7 @@
* this administration is common to both the MetaMatrix server and MM Query.</p>
* @since 4.3
*/
+(a)RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
public interface CoreConfigAdmin {
/**
@@ -259,6 +262,7 @@
* if there's a system error.
* @since 4.3
*/
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_READONLY)
LogConfiguration getLogConfiguration() throws AdminException;
/**
Modified: trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreMonitoringAdmin.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreMonitoringAdmin.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreMonitoringAdmin.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -24,18 +24,24 @@
import java.util.Collection;
+import com.metamatrix.admin.RolesAllowed;
import com.metamatrix.admin.api.exception.AdminException;
import com.metamatrix.admin.api.objects.AdminObject;
import com.metamatrix.admin.api.objects.Cache;
import com.metamatrix.admin.api.objects.ConnectorBinding;
import com.metamatrix.admin.api.objects.ConnectorType;
+import com.metamatrix.admin.api.objects.DQP;
import com.metamatrix.admin.api.objects.ExtensionModule;
+import com.metamatrix.admin.api.objects.Host;
+import com.metamatrix.admin.api.objects.ProcessObject;
import com.metamatrix.admin.api.objects.QueueWorkerPool;
import com.metamatrix.admin.api.objects.Request;
+import com.metamatrix.admin.api.objects.Resource;
import com.metamatrix.admin.api.objects.Session;
import com.metamatrix.admin.api.objects.SystemObject;
import com.metamatrix.admin.api.objects.Transaction;
import com.metamatrix.admin.api.objects.VDB;
+import com.metamatrix.admin.api.server.AdminRoles;
@@ -50,6 +56,7 @@
*
* @since 4.3
*/
+(a)RolesAllowed(value=AdminRoles.RoleName.ADMIN_READONLY)
public interface CoreMonitoringAdmin {
/**
@@ -90,6 +97,7 @@
* @throws AdminException if there's a system error.
* @since 4.3
*/
+ @RolesAllowed(value=AdminRoles.RoleName.ANONYMOUS)
Collection getVDBs(String vdbIdentifier) throws AdminException;
/**
@@ -133,7 +141,7 @@
* @throws AdminException if there's a system error.
* @since 4.3
*/
- Collection getExtensionModules(String extensionModuleIdentifier) throws AdminException;
+ Collection<ExtensionModule> getExtensionModules(String extensionModuleIdentifier) throws AdminException;
/**
* Get the Queue Worker Pools that correspond to the specified identifier pattern.
Modified: trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreRuntimeStateAdmin.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreRuntimeStateAdmin.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreRuntimeStateAdmin.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -24,7 +24,9 @@
import javax.transaction.xa.Xid;
+import com.metamatrix.admin.RolesAllowed;
import com.metamatrix.admin.api.exception.AdminException;
+import com.metamatrix.admin.api.server.AdminRoles;
/**
@@ -36,6 +38,7 @@
*
* @since 4.3
*/
+(a)RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
public interface CoreRuntimeStateAdmin {
/**
@@ -75,6 +78,7 @@
* @throws AdminException if there's a system error.
* @since 4.3
*/
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
void clearCache(String cacheIdentifier) throws AdminException;
/**
Modified: trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreSecurityAdmin.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreSecurityAdmin.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreSecurityAdmin.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -22,7 +22,10 @@
package com.metamatrix.admin.api.core;
+import com.metamatrix.admin.RolesAllowed;
+import com.metamatrix.admin.api.server.AdminRoles;
+
/**
* This interface defines the methods available for security administration
* in the MetaMatrix system.
@@ -34,6 +37,7 @@
* for a description of methods to administer MetaMatrix server security.</p>
* @since 4.3
*/
+(a)RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
public interface CoreSecurityAdmin {
}
Modified: trunk/client/src/main/java/com/metamatrix/admin/api/server/AdminRoles.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/server/AdminRoles.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/server/AdminRoles.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -73,5 +73,7 @@
public static final String ADMIN_PRODUCT = "Admin.ProductAdmin"; //$NON-NLS-1$
/** Read-only admin role name */
public static final String ADMIN_READONLY = "Admin.ReadOnlyAdmin"; //$NON-NLS-1$
+
+ public static final String ANONYMOUS = "Anonymous"; //$NON-NLS-1$
}
}
Modified: trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerAdmin.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerAdmin.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerAdmin.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -22,6 +22,7 @@
package com.metamatrix.admin.api.server;
+import com.metamatrix.admin.RolesAllowed;
import com.metamatrix.admin.api.objects.AdminObject;
/**
@@ -47,5 +48,6 @@
* Closes ServerAdmin connection to the server.
* @since 4.3
*/
+ @RolesAllowed(value=AdminRoles.RoleName.ANONYMOUS)
void close();
}
Modified: trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerMonitoringAdmin.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerMonitoringAdmin.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/server/ServerMonitoringAdmin.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -24,6 +24,7 @@
import java.util.Collection;
+import com.metamatrix.admin.RolesAllowed;
import com.metamatrix.admin.api.core.CoreMonitoringAdmin;
import com.metamatrix.admin.api.exception.AdminException;
@@ -59,6 +60,7 @@
* @throws AdminException if there's a system error.
* @since 4.3
*/
+ @RolesAllowed(value=AdminRoles.RoleName.ANONYMOUS)
Collection getProcesses(String processIdentifier) throws AdminException;
/**
Modified: trunk/client/src/main/java/com/metamatrix/client/ExceptionUtil.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/client/ExceptionUtil.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/client/src/main/java/com/metamatrix/client/ExceptionUtil.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -26,7 +26,9 @@
import com.metamatrix.admin.api.exception.AdminComponentException;
import com.metamatrix.admin.api.exception.AdminException;
+import com.metamatrix.admin.api.exception.AdminProcessingException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.core.MetaMatrixRuntimeException;
@@ -53,6 +55,9 @@
return new MetaMatrixComponentException(exception);
}
if (AdminException.class.isAssignableFrom(exceptionClasses[i])) {
+ if (exception instanceof MetaMatrixProcessingException) {
+ return new AdminProcessingException(exception);
+ }
return new AdminComponentException(exception);
}
canThrowXATransactionException |= XATransactionException.class.isAssignableFrom(exceptionClasses[i]);
Modified: trunk/client/src/main/resources/com/metamatrix/common/comm/platform/i18n.properties
===================================================================
--- trunk/client/src/main/resources/com/metamatrix/common/comm/platform/i18n.properties 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/client/src/main/resources/com/metamatrix/common/comm/platform/i18n.properties 2009-04-09 15:53:21 UTC (rev 734)
@@ -92,8 +92,8 @@
SocketServerInstancePool.No_valid_host_available=No valid host available. Attempted connections to: {0}
AdminAuthorizationInterceptor.Admin_Session_not_valid=Unable to perform the action [{0}]. Unable to validate session.
-AdminAuthorizationInterceptor.Admin_Audit_request=Administrator [{0}], session [{1}] requesting access which requires role [{2}] to method [{3}].
-AdminAuthorizationInterceptor.Admin_not_authorized=Administrator [{0}], session [{1}] does not have the required role [{2}] so is not authorized to perform the action [{3}].
+AdminAuthorizationInterceptor.Admin_Audit_request=Administrator [{0}], session [{1}] requesting access which requires role {2} to method [{3}].
+AdminAuthorizationInterceptor.Admin_not_authorized=Administrator [{0}], session [{1}] does not have any required role {2} so is not authorized to perform the action [{3}].
AdminAuthorizationInterceptor.Admin_granted=Administrator [{0}], session [{1}] granted access to method [{3}].
Modified: trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/ConfigurationAdminAPI.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/ConfigurationAdminAPI.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/ConfigurationAdminAPI.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -24,7 +24,6 @@
import java.util.Collection;
import java.util.List;
-import java.util.Properties;
import java.util.Set;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
@@ -284,23 +283,6 @@
throws ModificationException, ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
/**
- * Add a host to the Configuration
- *
- * @param hostName String name of Host to add to Configuration
- * @param properties
- * @return Host
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- * @throws InvalidSessionException if there is not a valid administrative session
- * @throws AuthorizationException if the administrator does not have privileges to use this method
- * @throws MetaMatrixComponentException if a general remote system problem occurred
- * @since 4.3
- */
- Host addHost(String hostName, Properties properties)
- throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
-
-
- /**
* Check whether the encrypted properties for the specified ComponentDefns can be decrypted.
* @param defns List<ComponentDefn>
* @return List<Boolean> in the same order as the paramater <code>defns</code>.
Modified: trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/ExtensionSourceAdminAPI.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/ExtensionSourceAdminAPI.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/ExtensionSourceAdminAPI.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -186,20 +186,6 @@
throws InvalidSessionException, AuthorizationException, ExtensionModuleNotFoundException, MetaMatrixComponentException;
/**
- * Retrieves an extension source in byte[] form
- * @param sourceName name (e.g. filename) of extension source
- * @return actual contents of source in byte[] array form
- * @throws InvalidSessionException if there is not a valid administrative session
- * @throws AuthorizationException if the administrator does not have privileges to use this method
- * @throws ExtensionSourceNotFoundException if no extension source with
- * name sourceName can be found
- * @throws MetaMatrixComponentException indicating a non-business-related
- * exception (such as a communication exception)
- */
- byte[] getSource(String sourceName)
- throws InvalidSessionException, AuthorizationException, ExtensionModuleNotFoundException, MetaMatrixComponentException;
-
- /**
* Updates the indicated extension source
* @param sourceName name (e.g. filename) of extension source
* @param source actual contents of source
Modified: trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/SubSystemAdminAPI.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/SubSystemAdminAPI.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/SubSystemAdminAPI.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -22,13 +22,12 @@
package com.metamatrix.platform.admin.api;
-import java.io.Serializable;
/**
* This is the base interface of all subsystem administrative API interfaces.
* @deprecated
*/
-public interface SubSystemAdminAPI extends Serializable {
+public interface SubSystemAdminAPI {
}
Modified: trunk/console/src/main/java/com/metamatrix/console/models/ExtensionSourceManager.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/models/ExtensionSourceManager.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/console/src/main/java/com/metamatrix/console/models/ExtensionSourceManager.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -26,6 +26,7 @@
import java.io.FileOutputStream;
import java.util.*;
+import com.metamatrix.admin.api.objects.ExtensionModule;
import com.metamatrix.common.extensionmodule.ExtensionModuleDescriptor;
import com.metamatrix.common.extensionmodule.exception.*;
import com.metamatrix.console.connections.ConnectionInfo;
@@ -117,12 +118,13 @@
public void exportToFile(String moduleName, File target) throws
ExtensionModuleNotFoundException, ExternalException {
- ExtensionSourceAdminAPI api = ModelManager.getExtensionSourceAPI(
- getConnection());
try {
- byte[] contents = api.getSource(moduleName);
+ Collection<ExtensionModule> modules = getConnection().getServerAdmin().getExtensionModules(moduleName);
+ if (modules.size() != 1) {
+ throw new ExtensionModuleNotFoundException(moduleName);
+ }
FileOutputStream stream = new FileOutputStream(target);
- stream.write(contents);
+ stream.write(modules.iterator().next().getFileContents());
stream.close();
} catch (ExtensionModuleNotFoundException ex) {
throw ex;
Modified: trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/AdminAuthorizationInterceptor.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/AdminAuthorizationInterceptor.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/AdminAuthorizationInterceptor.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -25,22 +25,24 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.Arrays;
import org.teiid.dqp.internal.process.DQPWorkContext;
+import com.metamatrix.admin.RolesAllowed;
import com.metamatrix.admin.api.exception.AdminProcessingException;
-import com.metamatrix.admin.api.server.ServerAdmin;
-import com.metamatrix.admin.util.AdminMethodRoleResolver;
-import com.metamatrix.api.exception.ComponentNotFoundException;
+import com.metamatrix.admin.api.server.AdminRoles;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.api.exception.security.AuthorizationException;
+import com.metamatrix.client.ExceptionUtil;
import com.metamatrix.common.comm.platform.CommPlatformPlugin;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.LogContextsUtil.PlatformAdminConstants;
+import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.platform.admin.apiimpl.IAdminHelper;
import com.metamatrix.platform.security.api.SessionToken;
+import com.metamatrix.platform.security.api.service.AuthorizationServiceInterface;
/**
* Call authorization service to make sure the current admin user has the
@@ -48,10 +50,10 @@
*/
public class AdminAuthorizationInterceptor implements InvocationHandler {
- private final IAdminHelper authorizationService;
- private final AdminMethodRoleResolver methodNames;
- private final ServerAdmin serverAdmin;
-
+ private final Object service;
+ private AuthorizationServiceInterface authAdmin;
+
+
/**
* Ctor.
* @param securityContextFactory
@@ -60,14 +62,10 @@
* @since 4.3
*/
public AdminAuthorizationInterceptor(
- IAdminHelper authorizationService,
- AdminMethodRoleResolver methodNames, ServerAdmin serverAdmin) {
-
+ AuthorizationServiceInterface authorizationService, Object service) {
ArgCheck.isNotNull(authorizationService);
- ArgCheck.isNotNull(methodNames);
- this.authorizationService = authorizationService;
- this.methodNames = methodNames;
- this.serverAdmin = serverAdmin;
+ this.authAdmin = authorizationService;
+ this.service = service;
}
/**
@@ -80,43 +78,56 @@
*/
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
- // Validate user's admin session is active
SessionToken adminToken = DQPWorkContext.getWorkContext().getSessionToken();
- // Verify that the admin user is authorized to perform the given operation
- String requiredRoleName = methodNames.getRoleNameForMethod(method.getName());
-
- if (!AdminMethodRoleResolver.ANONYMOUS_ROLE.equals(requiredRoleName)) {
-
- Object[] msgParts = null;
- boolean msgWillBeRecorded = LogManager.isMessageToBeRecorded(PlatformAdminConstants.CTX_AUDIT_ADMIN, MessageLevel.INFO);
- if (msgWillBeRecorded) {
- msgParts = buildAuditMessage(adminToken, requiredRoleName, method);
- LogManager.logInfo(PlatformAdminConstants.CTX_AUDIT_ADMIN,
- CommPlatformPlugin.Util.getString("AdminAuthorizationInterceptor.Admin_Audit_request", msgParts)); //$NON-NLS-1$
- }
+ Method serviceMethod = service.getClass().getMethod(method.getName(), method.getParameterTypes());
+ RolesAllowed allowed = serviceMethod.getAnnotation(RolesAllowed.class);
+ if (allowed == null) {
+ allowed = method.getAnnotation(RolesAllowed.class);
+ if (allowed == null) {
+ allowed = serviceMethod.getDeclaringClass().getAnnotation(RolesAllowed.class);
+ if (allowed == null) {
+ allowed = method.getDeclaringClass().getAnnotation(RolesAllowed.class);
+ }
+ }
+ }
+ if (allowed == null || allowed.value() == null) {
+ throw new MetaMatrixRuntimeException("Could not determine roles allowed for admin method"); //$NON-NLS-1$
+ }
- try {
- authorizationService.checkForRequiredRole(adminToken, requiredRoleName);
- LogManager.logInfo(PlatformAdminConstants.CTX_AUDIT_ADMIN, CommPlatformPlugin.Util.getString("AdminAuthorizationInterceptor.Admin_granted", msgParts)); //$NON-NLS-1$
- } catch (AuthorizationException err) {
- if ( msgParts == null ) {
- msgParts = buildAuditMessage(adminToken, requiredRoleName, method);
+ boolean authorized = false;
+ boolean msgWillBeRecorded = LogManager.isMessageToBeRecorded(PlatformAdminConstants.CTX_AUDIT_ADMIN, MessageLevel.INFO);
+ Object[] msgParts = null;
+ if (msgWillBeRecorded) {
+ msgParts = buildAuditMessage(adminToken, Arrays.toString(allowed.value()), method);
+ LogManager.logInfo(PlatformAdminConstants.CTX_AUDIT_ADMIN,
+ CommPlatformPlugin.Util.getString("AdminAuthorizationInterceptor.Admin_Audit_request", msgParts)); //$NON-NLS-1$
+ }
+
+ for (int i = 0; i < allowed.value().length; i++) {
+ String requiredRoleName = allowed.value()[i];
+ if (AdminRoles.RoleName.ANONYMOUS.equalsIgnoreCase(requiredRoleName)) {
+ authorized = true;
+ break;
+ }
+
+ if (authAdmin.isCallerInRole(adminToken, requiredRoleName)) {
+ authorized = true;
+ if (msgWillBeRecorded) {
+ LogManager.logInfo(PlatformAdminConstants.CTX_AUDIT_ADMIN, CommPlatformPlugin.Util.getString("AdminAuthorizationInterceptor.Admin_granted", msgParts)); //$NON-NLS-1$
}
- String errMsg = CommPlatformPlugin.Util.getString("AdminAuthorizationInterceptor.Admin_not_authorized", msgParts); //$NON-NLS-1$
- LogManager.logWarning(PlatformAdminConstants.CTX_AUDIT_ADMIN, errMsg);
- throw new AdminProcessingException(errMsg);
- } catch (ComponentNotFoundException err) {
- if ( msgParts == null ) {
- msgParts = buildAuditMessage(adminToken, requiredRoleName, method);
- }
- String errMsg = CommPlatformPlugin.Util.getString("AdminAuthorizationInterceptor.Admin_not_authorized", msgParts); //$NON-NLS-1$
- LogManager.logWarning(PlatformAdminConstants.CTX_AUDIT_ADMIN, errMsg);
- throw new AdminProcessingException(errMsg);
+ break;
}
}
+ if (!authorized) {
+ if (msgParts == null) {
+ msgParts = buildAuditMessage(adminToken, Arrays.toString(allowed.value()), method);
+ }
+ String errMsg = CommPlatformPlugin.Util.getString("AdminAuthorizationInterceptor.Admin_not_authorized", msgParts); //$NON-NLS-1$
+ throw ExceptionUtil.convertException(method, new AuthorizationException(errMsg));
+ }
try {
- return method.invoke(this.serverAdmin, args);
+ return method.invoke(service, args);
} catch (InvocationTargetException e) {
throw e.getTargetException();
}
Modified: trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/AdminAPIHelper.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/AdminAPIHelper.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/AdminAPIHelper.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -22,14 +22,10 @@
package com.metamatrix.platform.admin.apiimpl;
-import com.metamatrix.admin.AdminPlugin;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.api.exception.ComponentNotFoundException;
-import com.metamatrix.api.exception.security.AuthorizationException;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogContextsUtil.PlatformAdminConstants;
-import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
/**
@@ -39,70 +35,16 @@
*/
public class AdminAPIHelper {
- // The singleton
- private static AdminHelper adminHelper;
-
- // Get singleton init'ing as nessary
- private synchronized static AdminHelper getAdminHelper() {
-
- if ( adminHelper == null ) {
- initialize();
- }
- return adminHelper;
- }
-
- // Init singleton
- private synchronized static void initialize() {
- adminHelper = new AdminHelper();
- }
-
/**
- * Checks that user is in the necessary role, throws an exception if
- * not. Methods of this administrative API may require that a caller be
- * in one or more security roles.
- * @param adminToken a valid SessionToken object representing the session
- * of the caller attempting an administrative operation
- * @param roleName String name of role to be checked for caller membership
- * @param methodSignature the signature with arguments of the method this admin is attempting to call.
- * @throws AuthorizationException if caller is <i>not</i> in the role, and
- * therefore not authorized to make the operation
- * @throws ComponentNotFoundException if the authorization service could
- * not be communicated with due to a bad service instance or proxy
- */
- public static void checkForRequiredRole(SessionToken adminToken, String roleName, String methodSignature)
- throws AuthorizationException, ComponentNotFoundException {
- Object[] msgParts = null;
- boolean msgWillBeRecorded = LogManager.isMessageToBeRecorded(PlatformAdminConstants.CTX_AUDIT_ADMIN, MessageLevel.INFO);
- if (msgWillBeRecorded) {
- // Audit Admin attempt
- if (methodSignature != null) {
- methodSignature = methodSignature.split("\\(")[0]; //$NON-NLS-1$
- }
- msgParts = new Object[] {adminToken.getUsername(), adminToken.getSessionID().toString(),
- roleName, methodSignature};
- LogManager.logInfo(PlatformAdminConstants.CTX_AUDIT_ADMIN, AdminPlugin.Util.getString("Admin_Audit_request", msgParts)); //$NON-NLS-1$
- }
-
- getAdminHelper().checkForRequiredRole(adminToken, roleName);
-
- // Audit Admin granted
- if (msgWillBeRecorded) {
- LogManager.logInfo(PlatformAdminConstants.CTX_AUDIT_ADMIN,AdminPlugin.Util.getString("Admin_Audit_granted", msgParts)); //$NON-NLS-1$
- }
- }
-
- /**
* Get the <code>SessionToken</code> and validate that the session is active
* for the specified <code>MetaMatrixSessionID</code>.
- * @param sessionID the <code>MetaMatrixSessionID</code> for the session in
- * question.
* @return The <code>SessionToken</code> for the session in question.
* @throws InvalidSessionException If session has expired or doesn't exist
* @throws ComponentNotFoundException If couldn't find needed service component
*/
- public static SessionToken validateSession(MetaMatrixSessionID sessionID)
+ public static SessionToken validateSession()
throws InvalidSessionException, ComponentNotFoundException {
- return getAdminHelper().validateSession(sessionID);
+ return DQPWorkContext.getWorkContext().getSessionToken();
}
}
Deleted: trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/AdminHelper.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/AdminHelper.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/AdminHelper.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -1,153 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.admin.apiimpl;
-
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
-import com.metamatrix.admin.AdminMessages;
-import com.metamatrix.admin.AdminPlugin;
-import com.metamatrix.admin.api.exception.security.InvalidSessionException;
-import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
-import com.metamatrix.api.exception.ComponentNotFoundException;
-import com.metamatrix.api.exception.security.AuthorizationException;
-import com.metamatrix.api.exception.security.SessionServiceException;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.platform.admin.api.PlatformAdminLogConstants;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.SessionToken;
-import com.metamatrix.platform.security.api.service.AuthorizationServiceInterface;
-import com.metamatrix.platform.security.api.service.SessionServiceInterface;
-import com.metamatrix.platform.service.api.exception.ServiceException;
-import com.metamatrix.platform.util.PlatformProxyHelper;
-
-/**
- * This class is used by all <SubSystem>AdminAPIImpl to do general tasks such as
- * session vlidation and authorization role checking.
- */
-public class AdminHelper implements IAdminHelper {
-
- /**
- * Exception message sent to client if session service is down; indicates
- * that an session service was not available, client
- * privileges are unknown, and therefore a client's session id will not be
- * validated.
- * @see #validateSession(SessionID)
- */
- private static final String SESSION_SERVICE_DOWN_MSG = AdminPlugin.Util.getString(AdminMessages.ADMIN_0010);
-
- // Service Proxies
- private AuthorizationServiceInterface authAdmin;
- private SessionServiceInterface sessionAdmin;
-
-
- /**
- * ctor
- */
- public AdminHelper() {
- // Init authorization svc proxy
- authAdmin = PlatformProxyHelper.getAuthorizationServiceProxy(PlatformProxyHelper.ROUND_ROBIN_LOCAL);
-
- // Init session svc proxy
- sessionAdmin = PlatformProxyHelper.getSessionServiceProxy(PlatformProxyHelper.ROUND_ROBIN_LOCAL);
-
- }
-
- /**
- * Checks that user is in the necessary role, throws an exception if
- * not. Methods of this administrative API may require that a caller be
- * in one or more security roles.
- * @param adminToken a valid SessionToken object representing the session
- * of the caller attempting an administrative operation
- * @param roleName String name of role to be checked for caller membership
- * @throws AuthorizationException if caller is <i>not</i> in the role, and
- * therefore not authorized to make the operation
- * @throws ComponentNotFoundException if the authorization service could
- * not be communicated with due to a bad service instance or proxy
- */
- public void checkForRequiredRole(SessionToken adminToken, String roleName)
- throws AuthorizationException, ComponentNotFoundException {
- if (LogManager.isMessageToBeRecorded(PlatformAdminLogConstants.CTX_ADMIN_API, MessageLevel.TRACE)) {
- LogManager.logTrace(PlatformAdminLogConstants.CTX_ADMIN_API,
- "Checking owner of session token " + adminToken + " for membership in role: " + roleName); //$NON-NLS-1$
- }
- boolean isAuthorized = false;
- try{
- isAuthorized = authAdmin.isCallerInRole(adminToken, roleName);
- } catch (MetaMatrixSecurityException e){
- String msg = AdminPlugin.Util.getString(AdminMessages.ADMIN_0009, adminToken);
- throw new ComponentNotFoundException(e, AdminMessages.ADMIN_0009, msg);
- } catch (ServiceException e){
- String msg = AdminPlugin.Util.getString(AdminMessages.ADMIN_0009, adminToken);
- throw new ComponentNotFoundException(e, AdminMessages.ADMIN_0009, msg);
- } catch (Exception e){
- String msg = AdminPlugin.Util.getString(AdminMessages.ADMIN_0009, adminToken);
- throw new ComponentNotFoundException(e, AdminMessages.ADMIN_0009, msg);
- }
-
- if (!isAuthorized){
- String msg = AdminPlugin.Util.getString(AdminMessages.ADMIN_0008, adminToken, roleName.toString());
- throw new AuthorizationException(AdminMessages.ADMIN_0008, msg);
- }
- if (LogManager.isMessageToBeRecorded(PlatformAdminLogConstants.CTX_ADMIN_API, MessageLevel.TRACE)) {
- LogManager.logTrace(PlatformAdminLogConstants.CTX_ADMIN_API,
- "Verified owner of session token " + adminToken + " is in role: " + roleName); //$NON-NLS-1$
- }
- }
-
- /**
- * Get the <code>SessionToken</code> and validate that the session is active
- * for the specified <code>MetaMatrixSessionID</code>.
- * @param sessionID the <code>MetaMatrixSessionID</code> for the session in
- * question.
- * @return The <code>SessionToken</code> for the session in question.
- * @throws InvalidSessionException If session has expired or doesn't exist
- * @throws ComponentNotFoundException If couldn't find needed service component
- * @deprecated use {@link DQPWorkContext} instead
- */
- public SessionToken validateSession(MetaMatrixSessionID sessionID)
- throws InvalidSessionException, ComponentNotFoundException {
- if (LogManager.isMessageToBeRecorded(PlatformAdminLogConstants.CTX_ADMIN_API, MessageLevel.TRACE)) {
- LogManager.logTrace(PlatformAdminLogConstants.CTX_ADMIN_API,
- "Validating user session with session ID \"" + sessionID + "\""); //$NON-NLS-1$
- }
- SessionToken token = null;
- try {
- token = sessionAdmin.validateSession(sessionID).getSessionToken();
- } catch (InvalidSessionException e) {
- throw e;
- } catch (SessionServiceException e) {
- throw new ComponentNotFoundException(e,AdminMessages.ADMIN_0010, SESSION_SERVICE_DOWN_MSG);
- } catch (ServiceException e) {
- String msg = AdminPlugin.Util.getString(AdminMessages.ADMIN_0013);
- throw new ComponentNotFoundException(e,msg);
- }
-
- if (LogManager.isMessageToBeRecorded(PlatformAdminLogConstants.CTX_ADMIN_API, MessageLevel.TRACE)) {
- LogManager.logTrace(PlatformAdminLogConstants.CTX_ADMIN_API,
- "Validated user session with session ID \"" + sessionID + "\""); //$NON-NLS-1$
- }
- return token;
- }
-
-}
Modified: trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/AuthorizationAdminAPIImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/AuthorizationAdminAPIImpl.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/AuthorizationAdminAPIImpl.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -29,6 +29,7 @@
import java.util.Map;
import java.util.Set;
+import com.metamatrix.admin.RolesAllowed;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.admin.api.server.AdminRoles;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -50,7 +51,8 @@
import com.metamatrix.platform.service.api.exception.ServiceException;
import com.metamatrix.platform.util.PlatformProxyHelper;
-public class AuthorizationAdminAPIImpl extends SubSystemAdminAPIImpl implements AuthorizationAdminAPI {
+(a)RolesAllowed(value=AdminRoles.RoleName.ADMIN_READONLY)
+public class AuthorizationAdminAPIImpl implements AuthorizationAdminAPI {
AuthorizationRealm roleRealm = RolePermissionFactory.getRealm();
@@ -81,28 +83,23 @@
* submitted to the <code>AuthorizationService</code> for actual updates to occur.
* @return AuthorizationObjectEditor
*/
- public synchronized AuthorizationEditor createEditor()
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
+ public AuthorizationEditor createEditor()
throws InvalidSessionException, AuthorizationException, MetaMatrixComponentException {
- // Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "AuthorizationAdminAPIImpl.createEditor()"); //$NON-NLS-1$
return new AuthorizationObjectEditor(true);
}
- public synchronized Map getRoleDescriptions()
+ public Map getRoleDescriptions()
throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Any administrator may call this read-only method - no need to validate role
+ SessionToken token = AdminAPIHelper.validateSession();
return authAdmin.getRoleDescriptions(token);
}
- public synchronized Collection getPrincipalsForRole(String roleName)
+ public Collection getPrincipalsForRole(String roleName)
throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Any administrator may call this read-only method - no need to validate role
+ SessionToken token = AdminAPIHelper.validateSession();
return authAdmin.getPrincipalsForRole(token, roleName);
}
@@ -115,11 +112,10 @@
* @throws AuthorizationException if administrator does not have the authority to perform the requested operation.
* @throws MetaMatrixComponentException if this service has trouble communicating.
*/
- public synchronized Collection getRoleNamesForPrincipal(MetaMatrixPrincipalName principal)
+ public Collection getRoleNamesForPrincipal(MetaMatrixPrincipalName principal)
throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Any administrator may call this read-only method - no need to validate role
+ SessionToken token = AdminAPIHelper.validateSession();
return authAdmin.getRoleNamesForPrincipal(token, principal);
}
@@ -131,12 +127,11 @@
* @throws AuthorizationException if admninistrator does not have the authority to perform the requested operation.
* @throws MetaMatrixComponentException if this service has trouble communicating.
*/
- public synchronized void addPrincipalsToRole(Set principals, String roleName)
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
+ public void addPrincipalsToRole(Set principals, String roleName)
throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "AuthorizationAdminAPIImpl.addPrincipalsToRole(" + principals + ", " + roleName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ SessionToken token = AdminAPIHelper.validateSession();
AuthorizationPolicy role = authAdmin.getPolicy(token, new AuthorizationPolicyID(roleName, null, RolePermissionFactory.getRealm()));
@@ -154,12 +149,11 @@
* @throws AuthorizationException if admninistrator does not have the authority to perform the requested operation.
* @throws MetaMatrixComponentException if this service has trouble communicating.
*/
- public synchronized void removePrincipalsFromRole(Set principals, String roleName)
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
+ public void removePrincipalsFromRole(Set principals, String roleName)
throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "AuthorizationAdminAPIImpl.removePrincipalsFromRole(" + principals + ", " + roleName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ SessionToken token = AdminAPIHelper.validateSession();
AuthorizationPolicy role = authAdmin.getPolicy(token, new AuthorizationPolicyID(roleName, null, RolePermissionFactory.getRealm()));
@@ -173,11 +167,10 @@
/**
* Get all policyIDs in the system except those that we want to filter from the console.
*/
- public synchronized Collection findAllPolicyIDs()
+ public Collection findAllPolicyIDs()
throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Any administrator may call this read-only method - no need to validate role
+ SessionToken token = AdminAPIHelper.validateSession();
Collection allPolicyIDs = authAdmin.findAllPolicyIDs(token);
@@ -196,28 +189,26 @@
return filteredPolicyIDs;
}
- public synchronized Boolean containsPolicy(AuthorizationPolicyID policyID)
+ public Boolean containsPolicy(AuthorizationPolicyID policyID)
throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Any administrator may call this read-only method - no need to validate role
+ SessionToken token = AdminAPIHelper.validateSession();
return new Boolean(authAdmin.containsPolicy(token, policyID));
}
- public synchronized AuthorizationPolicy getPolicy(AuthorizationPolicyID policyID)
+ public AuthorizationPolicy getPolicy(AuthorizationPolicyID policyID)
throws AuthorizationException, AuthorizationMgmtException, InvalidSessionException, MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
+ SessionToken token = AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
return authAdmin.getPolicy(token, policyID);
}
- public synchronized Set executeTransaction(List actions)
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
+ public Set executeTransaction(List actions)
throws AuthorizationException, AuthorizationMgmtException, InvalidSessionException, MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "AuthorizationAdminAPIImpl.executeTransaction(" + actions + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ SessionToken token = AdminAPIHelper.validateSession();
return authAdmin.executeTransaction(token, actions);
}
@@ -237,11 +228,10 @@
* @throws AuthorizationMgmtException if an error occurs in the Authorization store.
* @throws MetaMatrixComponentException if this service has trouble communicating.
*/
- public synchronized Collection getPolicyIDsInRealm(AuthorizationRealm realm)
+ public Collection getPolicyIDsInRealm(AuthorizationRealm realm)
throws AuthorizationException, AuthorizationMgmtException, InvalidSessionException, MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Any administrator may call this read-only method - no need to validate role
+ SessionToken token = AdminAPIHelper.validateSession();
return authAdmin.getPolicyIDsInRealm(token, realm);
}
Modified: trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ConfigurationAdminAPIImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ConfigurationAdminAPIImpl.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ConfigurationAdminAPIImpl.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -24,12 +24,11 @@
import java.util.Collection;
import java.util.List;
-import java.util.Properties;
import java.util.Set;
+import com.metamatrix.admin.RolesAllowed;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.admin.api.server.AdminRoles;
-import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.security.AuthorizationException;
import com.metamatrix.common.actions.ActionDefinition;
@@ -45,15 +44,14 @@
import com.metamatrix.common.config.api.Host;
import com.metamatrix.common.config.api.HostID;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.platform.PlatformPlugin;
import com.metamatrix.platform.admin.api.ConfigurationAdminAPI;
import com.metamatrix.platform.config.api.service.ConfigurationServiceInterface;
import com.metamatrix.platform.registry.ClusteredRegistryState;
import com.metamatrix.platform.security.api.SessionToken;
-import com.metamatrix.platform.service.api.exception.ServiceException;
import com.metamatrix.platform.util.PlatformProxyHelper;
-public class ConfigurationAdminAPIImpl extends SubSystemAdminAPIImpl implements ConfigurationAdminAPI {
+(a)RolesAllowed(value=AdminRoles.RoleName.ADMIN_READONLY)
+public class ConfigurationAdminAPIImpl implements ConfigurationAdminAPI {
// Auth svc proxy
private ConfigurationServiceInterface configAdmin;
@@ -62,11 +60,11 @@
/**
* ctor
*/
- private ConfigurationAdminAPIImpl(ClusteredRegistryState registry) throws MetaMatrixComponentException {
+ private ConfigurationAdminAPIImpl(ClusteredRegistryState registry) {
configAdmin = PlatformProxyHelper.getConfigurationServiceProxy(PlatformProxyHelper.ROUND_ROBIN_LOCAL);
}
- public synchronized static ConfigurationAdminAPI getInstance(ClusteredRegistryState registry) throws MetaMatrixComponentException {
+ public synchronized static ConfigurationAdminAPI getInstance(ClusteredRegistryState registry) {
if (configAdminAPI == null) {
configAdminAPI = new ConfigurationAdminAPIImpl(registry);
}
@@ -83,10 +81,10 @@
*
* @return ConfigurationObjectEditor
*/
- public synchronized ConfigurationObjectEditor createEditor()
+ public ConfigurationObjectEditor createEditor()
throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
return configAdmin.createEditor();
}
@@ -107,12 +105,12 @@
* @throws MetaMatrixComponentException
* if a general remote system problem occurred
*/
- public synchronized ConfigurationID getNextStartupConfigurationID() throws ConfigurationException,
+ public ConfigurationID getNextStartupConfigurationID() throws ConfigurationException,
InvalidSessionException,
AuthorizationException,
MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
return configAdmin.getNextStartupConfigurationID();
}
@@ -127,12 +125,12 @@
* @throws ConfigurationException
* if an error occurred within or during communication with the Configuration Service.
*/
- public synchronized Configuration getCurrentConfiguration() throws ConfigurationException,
+ public Configuration getCurrentConfiguration() throws ConfigurationException,
InvalidSessionException,
AuthorizationException,
MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
return configAdmin.getCurrentConfiguration();
}
@@ -147,21 +145,21 @@
* @throws ConfigurationException
* if an error occurred within or during communication with the Configuration Service.
*/
- public synchronized Configuration getNextStartupConfiguration() throws ConfigurationException,
+ public Configuration getNextStartupConfiguration() throws ConfigurationException,
InvalidSessionException,
AuthorizationException,
MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
return configAdmin.getNextStartupConfiguration();
}
- public synchronized ConfigurationModelContainer getConfigurationModel(String configName) throws ConfigurationException,
+ public ConfigurationModelContainer getConfigurationModel(String configName) throws ConfigurationException,
InvalidSessionException,
AuthorizationException,
MetaMatrixComponentException {
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
return configAdmin.getConfigurationModel(configName);
}
@@ -219,13 +217,13 @@
* @throws MetaMatrixComponentException
* if a general remote system problem occurred
*/
- public synchronized Collection getConfigurationAndDependents(ConfigurationID configID) throws ConfigurationException,
+ public Collection getConfigurationAndDependents(ConfigurationID configID) throws ConfigurationException,
InvalidSessionException,
AuthorizationException,
MetaMatrixComponentException {
// Validate caller's session
// SessionToken token =
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
return configAdmin.getConfigurationAndDependents(configID);
}
@@ -239,13 +237,13 @@
* @return Collection of ComponentTypeDefns
* @see getDependentComponentTypeDefinitions(ComponentTypeID)
*/
- public synchronized Collection getComponentTypeDefinitions(ComponentTypeID componentTypeID) throws ConfigurationException,
+ public Collection getComponentTypeDefinitions(ComponentTypeID componentTypeID) throws ConfigurationException,
InvalidSessionException,
AuthorizationException,
MetaMatrixComponentException {
// Validate caller's session
// SessionToken token =
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
return configAdmin.getComponentTypeDefinitions(componentTypeID);
}
@@ -259,12 +257,12 @@
* @return Collection of ComponentTypeDefns
* @see getDependentComponentTypeDefinitions(ComponentTypeID)
*/
- public synchronized Collection getAllComponentTypeDefinitions(ComponentTypeID componentTypeID) throws ConfigurationException,
+ public Collection getAllComponentTypeDefinitions(ComponentTypeID componentTypeID) throws ConfigurationException,
InvalidSessionException,
AuthorizationException,
MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
return configAdmin.getAllComponentTypeDefinitions(componentTypeID);
}
@@ -278,12 +276,12 @@
* @throws ConfigurationException
* if an error occurred within or during communication with the Configuration Service.
*/
- public synchronized ComponentType getComponentType(ComponentTypeID id) throws ConfigurationException,
+ public ComponentType getComponentType(ComponentTypeID id) throws ConfigurationException,
InvalidSessionException,
AuthorizationException,
MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
return configAdmin.getComponentType(id);
}
@@ -299,13 +297,13 @@
* if an error occurred within or during communication with the Configuration Service.
* @see #ComponentType
*/
- public synchronized Collection getAllComponentTypes(boolean includeDeprecated) throws ConfigurationException,
+ public Collection getAllComponentTypes(boolean includeDeprecated) throws ConfigurationException,
InvalidSessionException,
AuthorizationException,
MetaMatrixComponentException {
// Validate caller's session
// SessionToken token =
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
return configAdmin.getAllComponentTypes(includeDeprecated);
}
@@ -318,24 +316,24 @@
* @throws ConfigurationException
* if an error occurred within or during communication with the Configuration Service.
*/
- public synchronized Host getHost(HostID hostID) throws ConfigurationException,
+ public Host getHost(HostID hostID) throws ConfigurationException,
InvalidSessionException,
AuthorizationException,
MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
return configAdmin.getHost(hostID);
}
- public synchronized ComponentDefn getComponentDefn(ConfigurationID configurationID,
+ public ComponentDefn getComponentDefn(ConfigurationID configurationID,
ComponentDefnID componentDefnID) throws ConfigurationException,
InvalidSessionException,
AuthorizationException,
MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
return configAdmin.getComponentDefn(configurationID, componentDefnID);
}
@@ -352,13 +350,13 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
- public synchronized Collection getResources() throws ConfigurationException,
+ public Collection getResources() throws ConfigurationException,
InvalidSessionException,
AuthorizationException,
MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
return configAdmin.getResources();
}
@@ -376,12 +374,12 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
- public synchronized void saveResources(Collection resourceDescriptors) throws ConfigurationException,
+ public void saveResources(Collection resourceDescriptors) throws ConfigurationException,
InvalidSessionException,
AuthorizationException,
MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
+ SessionToken token = AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
configAdmin.saveResources(resourceDescriptors, token.getUsername());
}
@@ -409,15 +407,14 @@
* @throws ConfigurationException
* if an error occurred within or during communication with the Metadata Service.
*/
- public synchronized Set executeTransaction(ActionDefinition action) throws ModificationException,
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
+ public Set executeTransaction(ActionDefinition action) throws ModificationException,
ConfigurationException,
InvalidSessionException,
AuthorizationException,
MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ConfigurationAdminAPIImpl.executeTransaction(" + action + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ SessionToken token = AdminAPIHelper.validateSession();
return configAdmin.executeTransaction(action, token.getUsername());
}
@@ -437,49 +434,28 @@
* @throws ConfigurationException
* if an error occurred within or during communication with the Metadata Service.
*/
- public synchronized Set executeTransaction(List actions) throws ModificationException,
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
+ public Set executeTransaction(List actions) throws ModificationException,
ConfigurationException,
InvalidSessionException,
AuthorizationException,
MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ConfigurationAdminAPIImpl.executeTransaction(" + actions + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ SessionToken token = AdminAPIHelper.validateSession();
return configAdmin.executeTransaction(actions, token.getUsername());
}
/**
- * @see com.metamatrix.platform.admin.apiimpl.ConfigurationAdminAPI#addHost(java.lang.String, java.util.Properties)
- * @since 4.3
- */
- public synchronized Host addHost(String hostName,
- Properties properties) throws ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- // Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ConfigurationAdminAPIImpl.addHost(" + hostName + ", " + properties + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- return configAdmin.addHost(hostName, token.getUsername(), properties);
- }
-
-
-
-
- /**
* @see com.metamatrix.platform.admin.api.ConfigurationAdminAPI#checkPropertiesDecryptable(java.util.List)
* @since 4.3
*/
- public synchronized List checkPropertiesDecryptable(List defns) throws ConfigurationException,
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
+ public List checkPropertiesDecryptable(List defns) throws ConfigurationException,
InvalidSessionException,
AuthorizationException,
MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ConfigurationAdminAPIImpl.checkPropertiesDecryptable(" + defns + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ SessionToken token = AdminAPIHelper.validateSession();
return configAdmin.checkPropertiesDecryptable(defns);
}
Modified: trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ExtensionSourceAdminAPIImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ExtensionSourceAdminAPIImpl.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ExtensionSourceAdminAPIImpl.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -25,6 +25,7 @@
import java.util.Collection;
import java.util.List;
+import com.metamatrix.admin.RolesAllowed;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.admin.api.server.AdminRoles;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -38,7 +39,8 @@
import com.metamatrix.platform.admin.api.ExtensionSourceAdminAPI;
import com.metamatrix.platform.security.api.SessionToken;
-public class ExtensionSourceAdminAPIImpl extends SubSystemAdminAPIImpl implements ExtensionSourceAdminAPI {
+(a)RolesAllowed(value=AdminRoles.RoleName.ADMIN_READONLY)
+public class ExtensionSourceAdminAPIImpl implements ExtensionSourceAdminAPI {
private ExtensionModuleManager extensionSourceManager;
private static ExtensionSourceAdminAPI extensionSourceAdminAPI;
@@ -46,11 +48,11 @@
/**
* ctor
*/
- private ExtensionSourceAdminAPIImpl() throws MetaMatrixComponentException {
+ private ExtensionSourceAdminAPIImpl() {
}
- public synchronized static ExtensionSourceAdminAPI getInstance() throws MetaMatrixComponentException {
+ public synchronized static ExtensionSourceAdminAPI getInstance() {
if (extensionSourceAdminAPI == null) {
extensionSourceAdminAPI = new ExtensionSourceAdminAPIImpl();
}
@@ -92,10 +94,10 @@
* @throws MetaMatrixComponentException indicating a non-business-related
* exception (such as a communication exception)
*/
- public synchronized ExtensionModuleDescriptor addSource(String type, String sourceName, byte[] source, String description, boolean enabled)
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
+ public ExtensionModuleDescriptor addSource(String type, String sourceName, byte[] source, String description, boolean enabled)
throws InvalidSessionException, AuthorizationException, DuplicateExtensionModuleException, InvalidExtensionModuleTypeException, MetaMatrixComponentException{
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ExtensionSourceAdminAPIImpl.addSource(" + type + ", " + sourceName + ", " + source + ", " + description + ", " + enabled + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ SessionToken token = AdminAPIHelper.validateSession();
return getExtensionSourceManager().addSource(token.getUsername(), type, sourceName, source, description, enabled);
}
@@ -109,10 +111,10 @@
* @throws MetaMatrixComponentException indicating a non-business-related
* exception (such as a communication exception)
*/
- public synchronized void removeSource(String sourceName)
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
+ public void removeSource(String sourceName)
throws InvalidSessionException, AuthorizationException, ExtensionModuleNotFoundException, MetaMatrixComponentException{
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ExtensionSourceAdminAPIImpl.removeSource(" + sourceName + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ SessionToken token = AdminAPIHelper.validateSession();
getExtensionSourceManager().removeSource(token.getUsername(), sourceName);
}
@@ -126,10 +128,8 @@
* @throws MetaMatrixComponentException indicating a non-business-related
* exception (such as a communication exception)
*/
- public synchronized Collection getSourceTypes()
+ public Collection getSourceTypes()
throws InvalidSessionException, AuthorizationException, MetaMatrixComponentException{
-// SessionToken token =
- AdminAPIHelper.validateSession(getSessionID());
return getExtensionSourceManager().getSourceTypes();
}
@@ -143,10 +143,8 @@
* @throws MetaMatrixComponentException indicating a non-business-related
* exception (such as a communication exception)
*/
- public synchronized List getSourceNames()
+ public List getSourceNames()
throws InvalidSessionException, AuthorizationException, MetaMatrixComponentException{
-// SessionToken token =
- AdminAPIHelper.validateSession(getSessionID());
return getExtensionSourceManager().getSourceNames();
}
@@ -160,10 +158,8 @@
* @throws MetaMatrixComponentException indicating a non-business-related
* exception (such as a communication exception)
*/
- public synchronized List getSourceDescriptors()
+ public List getSourceDescriptors()
throws InvalidSessionException, AuthorizationException, MetaMatrixComponentException{
-// SessionToken token =
- AdminAPIHelper.validateSession(getSessionID());
return getExtensionSourceManager().getSourceDescriptors();
}
@@ -180,10 +176,10 @@
* @throws MetaMatrixComponentException indicating a non-business-related
* exception (such as a communication exception)
*/
- public synchronized ExtensionModuleDescriptor getSourceDescriptor(String sourceName)
+ public ExtensionModuleDescriptor getSourceDescriptor(String sourceName)
throws InvalidSessionException, AuthorizationException, ExtensionModuleNotFoundException, MetaMatrixComponentException{
// SessionToken token =
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
return getExtensionSourceManager().getSourceDescriptor(sourceName);
}
@@ -204,10 +200,10 @@
* @throws MetaMatrixComponentException indicating a non-business-related
* exception (such as a communication exception)
*/
- public synchronized List setSearchOrder(List sourceNames)
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
+ public List setSearchOrder(List sourceNames)
throws InvalidSessionException, AuthorizationException, ExtensionModuleOrderingException, MetaMatrixComponentException{
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ExtensionSourceAdminAPIImpl.setSearchOrder(" + sourceNames + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ SessionToken token = AdminAPIHelper.validateSession();
return getExtensionSourceManager().setSearchOrder(token.getUsername(), sourceNames);
}
@@ -228,32 +224,14 @@
* @throws MetaMatrixComponentException indicating a non-business-related
* exception (such as a communication exception)
*/
- public synchronized List setEnabled(Collection sourceNames, boolean enabled)
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
+ public List setEnabled(Collection sourceNames, boolean enabled)
throws InvalidSessionException, AuthorizationException, ExtensionModuleNotFoundException, MetaMatrixComponentException{
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ExtensionSourceAdminAPIImpl.setEnabled(" + sourceNames + ", " + enabled + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ SessionToken token = AdminAPIHelper.validateSession();
return getExtensionSourceManager().setEnabled(token.getUsername(), sourceNames, enabled);
}
/**
- * Retrieves an extension source in byte[] form
- * @param sourceName name (e.g. filename) of extension source
- * @return actual contents of source in byte[] array form
- * @throws InvalidSessionException if there is not a valid administrative session
- * @throws AuthorizationException if the administrator does not have privileges to use this method
- * @throws ExtensionSourceNotFoundException if no extension source with
- * name sourceName can be found
- * @throws MetaMatrixComponentException indicating a non-business-related
- * exception (such as a communication exception)
- */
- public synchronized byte[] getSource(String sourceName)
- throws InvalidSessionException, AuthorizationException, ExtensionModuleNotFoundException, MetaMatrixComponentException{
-// SessionToken token =
- AdminAPIHelper.validateSession(getSessionID());
- return getExtensionSourceManager().getSource(sourceName);
- }
-
- /**
* Updates the indicated extension source
* @param sourceName name (e.g. filename) of extension source
* @param source actual contents of source
@@ -266,10 +244,10 @@
* @throws MetaMatrixComponentException indicating a non-business-related
* exception (such as a communication exception)
*/
- public synchronized ExtensionModuleDescriptor setSource(String sourceName, byte[] source)
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
+ public ExtensionModuleDescriptor setSource(String sourceName, byte[] source)
throws InvalidSessionException, AuthorizationException, ExtensionModuleNotFoundException, MetaMatrixComponentException{
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ExtensionSourceAdminAPIImpl.setSource(" + sourceName + ", " + source + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ SessionToken token = AdminAPIHelper.validateSession();
return getExtensionSourceManager().setSource(token.getUsername(), sourceName, source);
}
@@ -284,10 +262,10 @@
* @throws MetaMatrixComponentException indicating a non-business-related
* exception (such as a communication exception)
*/
- public synchronized ExtensionModuleDescriptor setSourceName(String sourceName, String newName)
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
+ public ExtensionModuleDescriptor setSourceName(String sourceName, String newName)
throws InvalidSessionException, AuthorizationException, ExtensionModuleNotFoundException, MetaMatrixComponentException{
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ExtensionSourceAdminAPIImpl.setSourceName(" + sourceName + ", " + newName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ SessionToken token = AdminAPIHelper.validateSession();
return getExtensionSourceManager().setSourceName(token.getUsername(), sourceName, newName);
}
@@ -303,10 +281,10 @@
* @throws MetaMatrixComponentException indicating a non-business-related
* exception (such as a communication exception)
*/
- public synchronized ExtensionModuleDescriptor setSourceDescription(String sourceName, String description)
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_SYSTEM)
+ public ExtensionModuleDescriptor setSourceDescription(String sourceName, String description)
throws InvalidSessionException, AuthorizationException, ExtensionModuleNotFoundException, MetaMatrixComponentException{
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ExtensionSourceAdminAPIImpl.setSourceDescription(" + sourceName + ", " + description + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ SessionToken token = AdminAPIHelper.validateSession();
return getExtensionSourceManager().setSourceDescription(token.getUsername(), sourceName, description);
}
Deleted: trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/IAdminHelper.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/IAdminHelper.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/IAdminHelper.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -1,62 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.admin.apiimpl;
-
-import com.metamatrix.admin.api.exception.security.InvalidSessionException;
-import com.metamatrix.api.exception.ComponentNotFoundException;
-import com.metamatrix.api.exception.security.AuthorizationException;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.SessionToken;
-
-/**
- * @since 4.3
- */
-public interface IAdminHelper {
-
- /**
- * Checks that user is in the necessary role, throws an exception if
- * not. Methods of this administrative API may require that a caller be
- * in one or more security roles.
- * @param adminToken a valid SessionToken object representing the session
- * of the caller attempting an administrative operation
- * @param roleName String name of role to be checked for caller membership
- * @throws AuthorizationException if caller is <i>not</i> in the role, and
- * therefore not authorized to make the operation
- * @throws ComponentNotFoundException if the authorization service could
- * not be communicated with due to a bad service instance or proxy
- */
- void checkForRequiredRole(SessionToken adminToken, String roleName)
- throws AuthorizationException, ComponentNotFoundException;
-
- /**
- * Get the <code>SessionToken</code> and validate that the session is active
- * for the specified <code>MetaMatrixSessionID</code>.
- * @param sessionID the <code>MetaMatrixSessionID</code> for the session in
- * question.
- * @return The <code>SessionToken</code> for the session in question.
- * @throws InvalidSessionException If session has expired or doesn't exist
- * @throws ComponentNotFoundException If couldn't find needed service component
- */
- SessionToken validateSession(MetaMatrixSessionID sessionID)
- throws InvalidSessionException, ComponentNotFoundException;
-}
\ No newline at end of file
Modified: trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIHelper.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIHelper.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIHelper.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -113,7 +113,7 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
- public synchronized SystemState getSystemState() throws MetaMatrixComponentException {
+ public SystemState getSystemState() throws MetaMatrixComponentException {
try {
SystemStateBuilder ssm = new SystemStateBuilder(this.registry, this.hostManagement);
return ssm.getSystemState();
@@ -263,7 +263,7 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
- public synchronized void shutdownServer() throws MetaMatrixComponentException {
+ public void shutdownServer() throws MetaMatrixComponentException {
this.hostManagement.killAllServersInCluster();
}
@@ -274,7 +274,7 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
- public synchronized void bounceServer() throws MetaMatrixComponentException {
+ public void bounceServer() throws MetaMatrixComponentException {
this.hostManagement.bounceAllServersInCluster();
}
@@ -287,7 +287,7 @@
* @throws a MultipleException if an error occurs
*/
- public synchronized void synchronizeServer() throws MetaMatrixComponentException,MultipleException {
+ public void synchronizeServer() throws MetaMatrixComponentException,MultipleException {
List exceptions = new ArrayList();
StringBuffer errorMsg = new StringBuffer();
Modified: trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIImpl.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIImpl.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -25,11 +25,10 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Set;
+import com.metamatrix.admin.RolesAllowed;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.admin.api.server.AdminRoles;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -69,10 +68,9 @@
import com.metamatrix.platform.vm.controller.ProcessStatistics;
import com.metamatrix.server.HostManagement;
-public class RuntimeStateAdminAPIImpl extends SubSystemAdminAPIImpl implements RuntimeStateAdminAPI {
+(a)RolesAllowed(value=AdminRoles.RoleName.ADMIN_READONLY)
+public class RuntimeStateAdminAPIImpl implements RuntimeStateAdminAPI {
- protected Set listeners = new HashSet();
-
private RuntimeStateAdminAPIHelper helper;
private LogReader logReader;
@@ -86,12 +84,12 @@
/**
* ctor
*/
- private RuntimeStateAdminAPIImpl(ClusteredRegistryState registry, HostManagement hostManagement) throws MetaMatrixComponentException {
+ private RuntimeStateAdminAPIImpl(ClusteredRegistryState registry, HostManagement hostManagement) {
this.registry = registry;
helper = RuntimeStateAdminAPIHelper.getInstance(registry, hostManagement);
}
- public synchronized static RuntimeStateAdminAPIImpl getInstance(ClusteredRegistryState registry, HostManagement hostManagement) throws MetaMatrixComponentException {
+ public synchronized static RuntimeStateAdminAPIImpl getInstance(ClusteredRegistryState registry, HostManagement hostManagement) {
if (runtimeStateAdminAPI == null) {
runtimeStateAdminAPI = new RuntimeStateAdminAPIImpl(registry, hostManagement);
}
@@ -137,7 +135,7 @@
MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
return helper.getServices();
}
@@ -155,17 +153,15 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
public synchronized void stopService(ServiceID serviceID) throws AuthorizationException,
InvalidSessionException,
MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
+ SessionToken token = AdminAPIHelper.validateSession();
LogManager.logInfo(LogPlatformConstants.CTX_RUNTIME_ADMIN, ServicePlugin.Util.getString(LogMessageKeys.ADMIN_0003, new Object[] {serviceID, token.getUsername()}));
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeStateAdminAPIImpl.stopService(" + serviceID + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-
helper.stopService(serviceID, false);
}
@@ -181,17 +177,15 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
public synchronized void stopServiceNow(ServiceID serviceID) throws AuthorizationException,
InvalidSessionException,
MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
+ SessionToken token = AdminAPIHelper.validateSession();
LogManager.logInfo(LogPlatformConstants.CTX_RUNTIME_ADMIN, ServicePlugin.Util.getString(LogMessageKeys.ADMIN_0004, new Object[] {serviceID, token.getUsername()}));
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeStateAdminAPIImpl.stopServiceNow(" + serviceID + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-
helper.stopService(serviceID, true);
}
@@ -207,18 +201,15 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
- public synchronized void stopHost(String host) throws AuthorizationException,
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public void stopHost(String host) throws AuthorizationException,
InvalidSessionException,
MetaMatrixComponentException,
MultipleException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
+ SessionToken token = AdminAPIHelper.validateSession();
LogManager.logInfo(LogPlatformConstants.CTX_RUNTIME_ADMIN, ServicePlugin.Util.getString(LogMessageKeys.ADMIN_0005, new Object[] {host, token.getUsername()}));
-
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeStateAdminAPIImpl.stopHost(" + host + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-
helper.stopHost(host, false);
}
@@ -234,18 +225,15 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
- public synchronized void stopHostNow(String host) throws AuthorizationException,
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public void stopHostNow(String host) throws AuthorizationException,
InvalidSessionException,
MetaMatrixComponentException,
MultipleException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
+ SessionToken token = AdminAPIHelper.validateSession();
LogManager.logInfo(LogPlatformConstants.CTX_RUNTIME_ADMIN, ServicePlugin.Util.getString(LogMessageKeys.ADMIN_0006, new Object[] {host, token.getUsername()}));
-
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeStateAdminAPIImpl.stopHostNow(" + host + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-
helper.stopHost(host, true);
}
@@ -262,16 +250,13 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
- public synchronized void stopProcess(String hostName, String processName, boolean now)
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public void stopProcess(String hostName, String processName, boolean now)
throws AuthorizationException,InvalidSessionException, MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
+ SessionToken token = AdminAPIHelper.validateSession();
LogManager.logInfo(LogPlatformConstants.CTX_RUNTIME_ADMIN, ServicePlugin.Util.getString(LogMessageKeys.ADMIN_0009, new Object[] {hostName+"."+processName, token.getUsername()})); //$NON-NLS-1$
-
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeStateAdminAPIImpl.stopProcess(" + hostName+","+ processName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
helper.stopProcess(hostName, processName, now);
}
@@ -286,17 +271,14 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
- public synchronized void shutdownServer() throws AuthorizationException,
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public void shutdownServer() throws AuthorizationException,
InvalidSessionException,
MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
+ SessionToken token = AdminAPIHelper.validateSession();
LogManager.logInfo(LogPlatformConstants.CTX_RUNTIME_ADMIN, ServicePlugin.Util.getString(LogMessageKeys.ADMIN_0015, new Object[] {token.getUsername()}));
-
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeStateAdminAPIImpl.shutdownServer()"); //$NON-NLS-1$
-
helper.shutdownServer();
}
@@ -313,18 +295,15 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
- public synchronized void restartService(ServiceID serviceID) throws AuthorizationException,
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public void restartService(ServiceID serviceID) throws AuthorizationException,
InvalidSessionException,
MetaMatrixComponentException {
LogManager.logInfo(LogPlatformConstants.CTX_RUNTIME_ADMIN, ServicePlugin.Util.getString(LogMessageKeys.ADMIN_0019, new Object[] {serviceID}));
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeStateAdminAPIImpl.restartService(" + serviceID + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-
-
+ SessionToken token = AdminAPIHelper.validateSession();
helper.restartService(serviceID);
}
@@ -340,16 +319,14 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
- public synchronized void startHost(String host) throws AuthorizationException,
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public void startHost(String host) throws AuthorizationException,
InvalidSessionException,
MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
+ SessionToken token = AdminAPIHelper.validateSession();
LogManager.logInfo(LogPlatformConstants.CTX_RUNTIME_ADMIN, ServicePlugin.Util.getString(LogMessageKeys.ADMIN_0020, new Object[] {host, token.getUsername()}));
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeStateAdminAPIImpl.startHost(" + host + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-
helper.startHost(host);
}
@@ -367,17 +344,14 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
- public synchronized void startProcess(String host, String process) throws AuthorizationException,
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public void startProcess(String host, String process) throws AuthorizationException,
InvalidSessionException,
MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
+ SessionToken token = AdminAPIHelper.validateSession();
LogManager.logInfo(LogPlatformConstants.CTX_RUNTIME_ADMIN, ServicePlugin.Util.getString(LogMessageKeys.ADMIN_0021, new Object[] {process, token.getUsername()}));
-
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeStateAdminAPIImpl.startProcess(" + host + ", " + process + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
helper.startProcess(host, process);
}
@@ -393,17 +367,15 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
- public synchronized void startPSC(PscID pscID) throws AuthorizationException,
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public void startPSC(PscID pscID) throws AuthorizationException,
InvalidSessionException,
MetaMatrixComponentException,
MultipleException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
+ SessionToken token = AdminAPIHelper.validateSession();
LogManager.logInfo(LogPlatformConstants.CTX_RUNTIME_ADMIN, ServicePlugin.Util.getString(LogMessageKeys.ADMIN_0022, new Object[] {pscID, token.getUsername()}));
-
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeStateAdminAPIImpl.startPSC(" + pscID + ")"); //$NON-NLS-1$ //$NON-NLS-2$
SystemState state = helper.getSystemState();
Iterator hosts = state.getHosts().iterator();
@@ -487,17 +459,20 @@
* @see com.metamatrix.platform.admin.api.RuntimeStateAdminAPI#stopPSC(com.metamatrix.platform.admin.api.runtime.PscID)
* @since 4.3
*/
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
public void stopPSCNow(PscID pscID) throws AuthorizationException,
InvalidSessionException,
MetaMatrixComponentException,
MultipleException {
+ stopPSC(pscID, true);
}
/**
* @see com.metamatrix.platform.admin.api.RuntimeStateAdminAPI#stopPSCNow(com.metamatrix.platform.admin.api.runtime.PscID)
* @since 4.3
*/
- public synchronized void stopPSC(PscID pscID) throws AuthorizationException,
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public void stopPSC(PscID pscID) throws AuthorizationException,
InvalidSessionException,
MetaMatrixComponentException,
MultipleException {
@@ -506,19 +481,16 @@
- private synchronized void stopPSC(PscID pscID,
+ private void stopPSC(PscID pscID,
boolean now) throws AuthorizationException,
InvalidSessionException,
MetaMatrixComponentException,
MultipleException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
+ SessionToken token = AdminAPIHelper.validateSession();
LogManager.logInfo(LogPlatformConstants.CTX_RUNTIME_ADMIN, ServicePlugin.Util.getString(LogMessageKeys.ADMIN_0023, new Object[] {pscID, token.getUsername()}));
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeStateAdminAPIImpl.stopPSC(" + pscID + ", " + now + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
SystemState state = getSystemState();
Iterator hosts = state.getHosts().iterator();
while (hosts.hasNext()) {
@@ -597,20 +569,17 @@
* @throws a
* MultipleException if an error occurs
*/
- public synchronized void synchronizeServer() throws AuthorizationException,
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public void synchronizeServer() throws AuthorizationException,
InvalidSessionException,
MetaMatrixComponentException,
MultipleException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
+ SessionToken token = AdminAPIHelper.validateSession();
LogManager.logInfo(LogPlatformConstants.CTX_RUNTIME_ADMIN, ServicePlugin.Util.getString(LogMessageKeys.ADMIN_0026, new Object[] {token.getUsername()}));
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeStateAdminAPIImpl.synchronizeServer()"); //$NON-NLS-1$
-
helper.synchronizeServer();
-
}
/**
@@ -624,7 +593,7 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
- public synchronized Date getServerStartTime() throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException {
+ public Date getServerStartTime() throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException {
return this.helper.getEldestProcessStartTime();
}
@@ -646,7 +615,8 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
- public synchronized void setLoggingConfiguration(Configuration config,
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public void setLoggingConfiguration(Configuration config,
LogConfiguration logConfig,
List actions) throws AuthorizationException,
InvalidSessionException,
@@ -654,10 +624,7 @@
LogManager.logInfo(LogPlatformConstants.CTX_RUNTIME_ADMIN, CorePlugin.Util.getString(LogMessageKeys.ADMIN_0027));
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeStateAdminAPIImpl.setLoggingConfiguration(" + config + ", " + logConfig + ", " + actions + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
+ SessionToken token = AdminAPIHelper.validateSession();
helper.setLogConfiguration(config, logConfig, actions, token.getUsername());
}
@@ -667,34 +634,6 @@
}
/**
- * Sets the <code>LogConfiguration</code> on the <code>LogManager</code> running in the given VM. If
- * <code>null>/code> is passed in for vmID, set log config on the
- * App Server VM - the MetaMatrix registry does not have a handle for that VM.
- * @param logConfig The log configuration with which to affect the log properties.
- * @param vmID The ID of the VM for which to set log configuration
- * used to affect the configuration database. If <code>null</code>, set the
- * App Server VM's log config.
- * @throws AuthorizationException if caller is not authorized to perform this method.
- * @throws InvalidSessionException if the <code>callerSessionID</code> is not valid or is expired.
- * @throws MetaMatrixComponentException if an error occurred in communicating with a component.
- */
- public synchronized void setLoggingConfiguration(LogConfiguration logConfig, String hostName, String processName)
- throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException {
-
- LogManager.logInfo(LogPlatformConstants.CTX_RUNTIME_ADMIN, CorePlugin.Util.getString(LogMessageKeys.ADMIN_0029, new Object[] {buildProcessId(hostName, processName)}));
-
- // Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
-
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeStateAdminAPIImpl.setLoggingConfiguration(" + logConfig + ", " + buildProcessId(hostName, processName) + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- // Set logging config for given VM
- ProcessManagement vm = helper.getVMControllerInterface(hostName, processName);
- vm.setCurrentLogConfiguration(logConfig);
- }
-
- /**
* Return Collection of QueueStats for service.
*
* @param serviceID
@@ -707,16 +646,12 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
- public synchronized Collection getServiceQueueStatistics(ServiceID serviceID) throws AuthorizationException,
+ public Collection getServiceQueueStatistics(ServiceID serviceID) throws AuthorizationException,
InvalidSessionException,
MetaMatrixComponentException {
LogManager.logDetail(LogPlatformConstants.CTX_RUNTIME_ADMIN, "Getting queue statistics for: " + serviceID); //$NON-NLS-1$
- // Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
- // Any administrator may call this read-only method - no need to validate role
-
return helper.getServiceQueueStatistics(helper.getServiceBinding(serviceID));
}
@@ -735,7 +670,7 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
- public synchronized WorkerPoolStats getServiceQueueStatistics(ServiceID serviceID,
+ public WorkerPoolStats getServiceQueueStatistics(ServiceID serviceID,
String queueName) throws AuthorizationException,
InvalidSessionException,
MetaMatrixComponentException {
@@ -743,7 +678,7 @@
LogManager.logDetail(LogPlatformConstants.CTX_RUNTIME_ADMIN, "Getting queue statistics for " + queueName + " for service: " + serviceID); //$NON-NLS-1$ //$NON-NLS-2$
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
ServiceInterface service = helper.getServiceBinding(serviceID).getService();
@@ -763,13 +698,13 @@
* @throws MetaMatrixComponentException
* if an error occurred in communicating with a component.
*/
- public synchronized ProcessStatistics getProcessStatistics(String hostName, String processName)
+ public ProcessStatistics getProcessStatistics(String hostName, String processName)
throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException {
LogManager.logDetail(LogPlatformConstants.CTX_RUNTIME_ADMIN, "Getting vm statistics for " + buildProcessId(hostName, processName)); //$NON-NLS-1$
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
return helper.getVMStatistics(hostName, processName);
@@ -785,7 +720,7 @@
String serviceName) throws AuthorizationException,
InvalidSessionException,
MetaMatrixComponentException {
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
ServiceID result = null;
@@ -824,7 +759,7 @@
AuthorizationException,
InvalidSessionException,
MetaMatrixComponentException {
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
PscID result = null;
Iterator vmIter = registry.getVMs(hostName).iterator();
@@ -857,7 +792,7 @@
public List<ProcessRegistryBinding> getVMControllerBindings() throws InvalidSessionException,
AuthorizationException,
MetaMatrixComponentException {
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
return registry.getVMs(null);
}
@@ -873,7 +808,7 @@
int maxRows) throws AuthorizationException,
InvalidSessionException,
MetaMatrixComponentException {
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
return getLogReader().getLogEntries(startTime, endTime, levels, contexts, maxRows);
}
@@ -892,7 +827,7 @@
public SystemState getSystemState() throws AuthorizationException,
InvalidSessionException, MetaMatrixComponentException {
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
return helper.getSystemState();
}
Deleted: trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/SubSystemAdminAPIImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/SubSystemAdminAPIImpl.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/SubSystemAdminAPIImpl.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.admin.apiimpl;
-
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
-import com.metamatrix.platform.admin.api.SubSystemAdminAPI;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-
-/**
- * Base class for subsystem administrative API implementations.
- */
-public abstract class SubSystemAdminAPIImpl implements SubSystemAdminAPI {
-
- /**
- * Get The <code>MetaMatrixSessionID</code> for this Connection
- * @return this Session ID
- */
- protected MetaMatrixSessionID getSessionID() {
- return DQPWorkContext.getWorkContext().getSessionId();
- }
-}
-
Modified: trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -39,7 +39,6 @@
import com.metamatrix.admin.api.exception.AdminException;
import com.metamatrix.admin.api.server.ServerAdmin;
import com.metamatrix.admin.server.ServerAdminImpl;
-import com.metamatrix.admin.util.AdminMethodRoleResolver;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MultipleException;
import com.metamatrix.common.classloader.URLFilteringClassLoader;
@@ -84,7 +83,6 @@
import com.metamatrix.platform.admin.api.ConfigurationAdminAPI;
import com.metamatrix.platform.admin.api.ExtensionSourceAdminAPI;
import com.metamatrix.platform.admin.api.RuntimeStateAdminAPI;
-import com.metamatrix.platform.admin.apiimpl.AdminHelper;
import com.metamatrix.platform.admin.apiimpl.AuthorizationAdminAPIImpl;
import com.metamatrix.platform.admin.apiimpl.ConfigurationAdminAPIImpl;
import com.metamatrix.platform.admin.apiimpl.ExtensionSourceAdminAPIImpl;
@@ -204,14 +202,13 @@
* @throws MetaMatrixComponentException
*/
private void registerSubSystemAdminAPIs(HostManagement hostManagement) throws MetaMatrixComponentException {
- this.clientServices.registerClientService(ConfigurationAdminAPI.class, ConfigurationAdminAPIImpl.getInstance(this.registry), PlatformAdminConstants.CTX_CONFIGURATION_ADMIN_API);
- this.clientServices.registerClientService(RuntimeStateAdminAPI.class, RuntimeStateAdminAPIImpl.getInstance(this.registry, hostManagement), PlatformAdminConstants.CTX_RUNTIME_STATE_ADMIN_API);
- this.clientServices.registerClientService(AuthorizationAdminAPI.class, AuthorizationAdminAPIImpl.getInstance(), PlatformAdminConstants.CTX_AUTHORIZATION_ADMIN_API);
- this.clientServices.registerClientService(ExtensionSourceAdminAPI.class, ExtensionSourceAdminAPIImpl.getInstance(), PlatformAdminConstants.CTX_ADMIN_API);
- this.clientServices.registerClientService(RuntimeMetadataAdminAPI.class, RuntimeMetadataAdminAPIImpl.getInstance(), PlatformAdminConstants.CTX_RUNTIME_METADATA_ADMIN_API);
+ this.clientServices.registerClientService(ConfigurationAdminAPI.class, wrapAdminService(ConfigurationAdminAPI.class, ConfigurationAdminAPIImpl.getInstance(this.registry)), PlatformAdminConstants.CTX_CONFIGURATION_ADMIN_API);
+ this.clientServices.registerClientService(RuntimeStateAdminAPI.class, wrapAdminService(RuntimeStateAdminAPI.class, RuntimeStateAdminAPIImpl.getInstance(this.registry, hostManagement)), PlatformAdminConstants.CTX_RUNTIME_STATE_ADMIN_API);
+ this.clientServices.registerClientService(AuthorizationAdminAPI.class, wrapAdminService(AuthorizationAdminAPI.class, AuthorizationAdminAPIImpl.getInstance()), PlatformAdminConstants.CTX_AUTHORIZATION_ADMIN_API);
+ this.clientServices.registerClientService(ExtensionSourceAdminAPI.class, wrapAdminService(ExtensionSourceAdminAPI.class, ExtensionSourceAdminAPIImpl.getInstance()), PlatformAdminConstants.CTX_ADMIN_API);
+ this.clientServices.registerClientService(RuntimeMetadataAdminAPI.class, wrapAdminService(RuntimeMetadataAdminAPI.class, RuntimeMetadataAdminAPIImpl.getInstance()), PlatformAdminConstants.CTX_RUNTIME_METADATA_ADMIN_API);
}
-
/**
* Register a ServiceInterceptor for the new Admin API, so that the client can access it via messaging.
* @throws AdminException
@@ -220,11 +217,15 @@
*/
private void registerAdmin(HostManagement hostManagement) throws AdminException {
ServerAdminImpl serverAdminImpl = new ServerAdminImpl(this.registry, hostManagement);
- AdminMethodRoleResolver adminMethodRoleResolver = new AdminMethodRoleResolver();
- adminMethodRoleResolver.init();
- ServerAdmin roleCheckedServerAdmin = (ServerAdmin)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {ServerAdmin.class}, new AdminAuthorizationInterceptor(new AdminHelper(), adminMethodRoleResolver, serverAdminImpl));
+ ServerAdmin roleCheckedServerAdmin = wrapAdminService(ServerAdmin.class, serverAdminImpl);
this.clientServices.registerClientService(ServerAdmin.class, roleCheckedServerAdmin, PlatformAdminConstants.CTX_ADMIN);
}
+
+
+ @SuppressWarnings("unchecked")
+ private <T> T wrapAdminService(Class<T> iface, T impl) {
+ return (T)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {iface}, new AdminAuthorizationInterceptor(PlatformProxyHelper.getAuthorizationServiceProxy(PlatformProxyHelper.ROUND_ROBIN_LOCAL), impl));
+ }
/**
* Register ILogonAPI's ServiceInterceptor
Modified: trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataAdminAPIImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataAdminAPIImpl.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/RuntimeMetadataAdminAPIImpl.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -34,6 +34,7 @@
import java.util.Properties;
import java.util.Set;
+import com.metamatrix.admin.RolesAllowed;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.admin.api.server.AdminRoles;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -64,7 +65,6 @@
import com.metamatrix.platform.admin.api.PermissionDataNode;
import com.metamatrix.platform.admin.apiimpl.AdminAPIHelper;
import com.metamatrix.platform.admin.apiimpl.PermissionDataNodeImpl;
-import com.metamatrix.platform.admin.apiimpl.SubSystemAdminAPIImpl;
import com.metamatrix.platform.security.api.AuthorizationPolicyID;
import com.metamatrix.platform.security.api.AuthorizationRealm;
import com.metamatrix.platform.security.api.SessionToken;
@@ -74,7 +74,8 @@
import com.metamatrix.server.admin.api.RuntimeMetadataAdminAPI;
import com.metamatrix.server.admin.api.ServerAdminLogConstants;
-public class RuntimeMetadataAdminAPIImpl extends SubSystemAdminAPIImpl implements RuntimeMetadataAdminAPI {
+(a)RolesAllowed(value=AdminRoles.RoleName.ADMIN_READONLY)
+public class RuntimeMetadataAdminAPIImpl implements RuntimeMetadataAdminAPI {
@@ -84,11 +85,11 @@
* ctor
* Only defined here so that it doesn't get generated.
*/
- private RuntimeMetadataAdminAPIImpl() throws MetaMatrixComponentException {
+ private RuntimeMetadataAdminAPIImpl() {
}
- public synchronized static RuntimeMetadataAdminAPI getInstance() throws MetaMatrixComponentException {
+ public synchronized static RuntimeMetadataAdminAPI getInstance() {
if (runtimeMetadataAdminAPI == null) {
runtimeMetadataAdminAPI = new RuntimeMetadataAdminAPIImpl();
}
@@ -106,14 +107,12 @@
* @throws VirtualDatabaseException if an error occurs while setting the state.
* @throws MetaMatrixComponentException if an error occurs in communicating with a component.
*/
- public synchronized void updateVirtualDatabase(VirtualDatabase vdb)
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public void updateVirtualDatabase(VirtualDatabase vdb)
throws AuthorizationException, InvalidSessionException, VirtualDatabaseException, MetaMatrixComponentException {
// Validate caller's session
- SessionToken callerToken = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(callerToken, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeMetadataAdminAPIImpl.updateVirtualDatabase(" + vdb.getID() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-
+ SessionToken callerToken = AdminAPIHelper.validateSession();
RuntimeMetadataCatalog.getInstance().updateVirtualDatabase(vdb, callerToken.getUsername());
}
@@ -128,13 +127,12 @@
* @throws VirtualDatabaseException if an error occurs while updating vdb.
* @throws MetaMatrixComponentException if an error occurs in communicating with a component.
*/
- public synchronized void markVDBForDelete(VirtualDatabaseID vdbID)
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public void markVDBForDelete(VirtualDatabaseID vdbID)
throws AuthorizationException, InvalidSessionException, VirtualDatabaseException, MetaMatrixComponentException {
// Validate caller's session
- SessionToken callerToken = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(callerToken, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeMetadataAdminAPIImpl.markVDBForDelete(" + vdbID + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ SessionToken callerToken = AdminAPIHelper.validateSession();
// Get VDB's current state
VirtualDatabase theVDB = RuntimeMetadataCatalog.getInstance().getVirtualDatabase(vdbID);
@@ -175,11 +173,11 @@
* @throws VirtualDatabaseException if an error occurs while setting the state.
* @throws MetaMatrixComponentException if an error occurs in communicating with a component.
*/
- public synchronized Map migrateConnectorBindingNames(VirtualDatabase sourceVDB, VDBDefn vdb)
+ public Map migrateConnectorBindingNames(VirtualDatabase sourceVDB, VDBDefn vdb)
throws AuthorizationException, InvalidSessionException, VirtualDatabaseException, MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
Map modelNameToRoutingIDs = new HashMap();
@@ -243,14 +241,13 @@
* @throws VirtualDatabaseException if an error occurs while setting the state.
* @throws MetaMatrixComponentException if an error occurs in communicating with a component.
*/
- public synchronized void setConnectorBindingNames(VirtualDatabaseID vdbID,
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public void setConnectorBindingNames(VirtualDatabaseID vdbID,
Map modelAndCBNames)
throws AuthorizationException, InvalidSessionException, VirtualDatabaseException, MetaMatrixComponentException {
// Validate caller's session
- SessionToken callerToken = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(callerToken, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeMetadataAdminAPIImpl.setConnectorBindingNames(" + vdbID + ", " + modelAndCBNames + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ SessionToken callerToken = AdminAPIHelper.validateSession();
RuntimeMetadataCatalog.getInstance().setConnectorBindingNames(vdbID, modelAndCBNames, callerToken.getUsername());
}
@@ -265,10 +262,10 @@
* @throws VirtualDatabaseException if an error occurs while setting the state.
* @throws MetaMatrixComponentException if an error occurs in communicating with a component.
*/
- public synchronized Collection getVDBsForConnectorBinding(String routingID)
+ public Collection getVDBsForConnectorBinding(String routingID)
throws AuthorizationException, InvalidSessionException, VirtualDatabaseException, MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
Collection VDBs = new HashSet();
@@ -307,11 +304,11 @@
* @throws VirtualDatabaseException if an error occurs while setting the state.
* @throws MetaMatrixComponentException if an error occurs in communicating with a component.
*/
- public synchronized VirtualDatabase getVirtualDatabase(VirtualDatabaseID vdbID)
+ public VirtualDatabase getVirtualDatabase(VirtualDatabaseID vdbID)
throws AuthorizationException, InvalidSessionException, VirtualDatabaseException, MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
return RuntimeMetadataCatalog.getInstance().getVirtualDatabase(vdbID);
@@ -328,11 +325,11 @@
* @throws VirtualDatabaseException if an error occurs during retrieval process.
* @throws MetaMatrixComponentException if an error occurs in communicating with a component.
*/
- public synchronized VirtualDatabase getLatestVirtualDatabase(String vdbName)
+ public VirtualDatabase getLatestVirtualDatabase(String vdbName)
throws AuthorizationException, InvalidSessionException, VirtualDatabaseException, MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
VirtualDatabaseID vdbId = RuntimeMetadataCatalog.getInstance().getVirtualDatabaseID(vdbName, null);
@@ -351,11 +348,11 @@
* @throws VirtualDatabaseException if an error occurs while setting the state.
* @throws MetaMatrixComponentException if an error occurs in communicating with a component.
*/
- public synchronized Collection getVirtualDatabases()
+ public Collection getVirtualDatabases()
throws AuthorizationException, InvalidSessionException, VirtualDatabaseException, MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
return RuntimeMetadataCatalog.getInstance().getVirtualDatabases();
@@ -374,11 +371,11 @@
* @throws AuthorizationException if caller is not authorized to perform this method.
* @throws MetaMatrixComponentException if an error occurs in communicating with a component.
*/
- public synchronized Collection getVDBModels(VirtualDatabaseID vdbID)
+ public Collection getVDBModels(VirtualDatabaseID vdbID)
throws AuthorizationException, InvalidSessionException, VirtualDatabaseException, MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
ArrayList models = new ArrayList(RuntimeMetadataCatalog.getInstance().getModels(vdbID));
@@ -432,13 +429,12 @@
* @throws VirtualDatabaseException if an error occurs while setting the state.
* @throws MetaMatrixComponentException if an error occurs in communicating with a component.
*/
- public synchronized void setVDBState(VirtualDatabaseID vdbID, short state)
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public void setVDBState(VirtualDatabaseID vdbID, short state)
throws AuthorizationException, InvalidSessionException, VirtualDatabaseException, MetaMatrixComponentException {
// Validate caller's session
- SessionToken callerToken = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(callerToken, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeMetadataAdminAPIImpl.setVDBState(" + vdbID + ", " + state + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ SessionToken callerToken = AdminAPIHelper.validateSession();
// Get VDB's current state
VirtualDatabase theVDB = RuntimeMetadataCatalog.getInstance().getVirtualDatabase(vdbID);
@@ -527,13 +523,12 @@
* @throws AuthorizationException if admninistrator does not have the authority to perform the requested operation.
* @throws MetaMatrixComponentException if this service has trouble communicating.
*/
- public synchronized EntitlementMigrationReport migrateEntitlements(VirtualDatabase sourceVDB,
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public EntitlementMigrationReport migrateEntitlements(VirtualDatabase sourceVDB,
VirtualDatabase targetVDB)
throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
-
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeMetadataAdminAPIImpl.migrateEntitlements(" + sourceVDB.getID() + ", " + targetVDB.getID() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ SessionToken token = AdminAPIHelper.validateSession();
return RuntimeMetadataHelper.migrateEntitlements(sourceVDB, targetVDB, token);
}
@@ -548,14 +543,13 @@
* @throws AuthorizationException if admninistrator does not have the authority to perform the requested operation.
* @throws MetaMatrixComponentException if this service has trouble communicating.
*/
- public synchronized EntitlementMigrationReport migrateEntitlements(VirtualDatabase targetVDB,
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public EntitlementMigrationReport migrateEntitlements(VirtualDatabase targetVDB,
char[] dataRoleContents, boolean overwriteExisting)
throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException {
// Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
+ SessionToken token = AdminAPIHelper.validateSession();
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "RuntimeMetadataAdminAPIImpl.migrateEntitlements(" + targetVDB.getID() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-
return RuntimeMetadataHelper.migrateEntitlements(targetVDB.getVirtualDatabaseID(), dataRoleContents, overwriteExisting, token);
}
@@ -569,12 +563,12 @@
* @throws AuthorizationException if admninistrator does not have the authority to perform the requested operation.
* @throws MetaMatrixComponentException if this service has trouble communicating.
*/
- public synchronized PermissionDataNode getEntitlementTree(String vDBName,
+ public PermissionDataNode getEntitlementTree(String vDBName,
String vDBVersion,
AuthorizationPolicyID policyID)
throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
LogManager.logDetail(
@@ -598,10 +592,10 @@
* @throws AuthorizationException if admninistrator does not have the authority to perform the requested operation.
* @throws MetaMatrixComponentException if this service has trouble communicating.
*/
- public synchronized PermissionDataNode getDataNodes(String vDBName, String vDBVersion)
+ public PermissionDataNode getDataNodes(String vDBName, String vDBVersion)
throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
LogManager.logDetail(
@@ -620,10 +614,10 @@
* @param vdbVersion The version for the VDB.
* @return All element paths in the given VDB version.
*/
- public synchronized Set getAllDataNodeNames(String vdbName, String vdbVersion)
+ public Set getAllDataNodeNames(String vdbName, String vdbVersion)
throws InvalidSessionException, MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
return new HashSet(RuntimeMetadataHelper.getAllDataNodeNames(vdbName, vdbVersion, new HashMap()));
}
@@ -640,14 +634,10 @@
* @throws VirtualDatabaseException if an error occurs while setting the state.
* @throws MetaMatrixComponentException if an error occurs in communicating with a component.
*/
- public synchronized byte[] getVDB(VirtualDatabaseID vdbID)
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public byte[] getVDB(VirtualDatabaseID vdbID)
throws AuthorizationException, InvalidSessionException,VirtualDatabaseException,MetaMatrixComponentException {
- // Validate caller's session
- SessionToken callerToken = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(callerToken, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeMetadataAdminAPIImpl.getVDBDefn(" + vdbID + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-
VDBArchive vdbArchive = null;
try {
vdbArchive = VDBDefnFactory.createVDBArchive(vdbID.getName(), vdbID.getVersion());
@@ -672,14 +662,13 @@
}
}
}
-
- public synchronized VirtualDatabase importVDB(byte[] vdbStream)
+
+ @RolesAllowed(value=AdminRoles.RoleName.ADMIN_PRODUCT)
+ public VirtualDatabase importVDB(byte[] vdbStream)
throws AuthorizationException, InvalidSessionException, VirtualDatabaseException, MetaMatrixComponentException {
// Validate caller's session
- SessionToken callerToken = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(callerToken, AdminRoles.RoleName.ADMIN_PRODUCT, "RuntimeMetadataAdminAPIImpl.importVDB(vdbStream)"); //$NON-NLS-1$
+ SessionToken callerToken = AdminAPIHelper.validateSession();
VDBArchive vdbArchive = null;
try {
@@ -721,11 +710,11 @@
* @throws VirtualDatabaseException if an error occurs while setting the state.
* @throws MetaMatrixComponentException if an error occurs in communicating with a component.
*/
- public synchronized Map getModelVisibilityLevels(VirtualDatabaseID vdbID)
+ public Map getModelVisibilityLevels(VirtualDatabaseID vdbID)
throws AuthorizationException, InvalidSessionException, VirtualDatabaseException, MetaMatrixComponentException {
// Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
+ AdminAPIHelper.validateSession();
// Any administrator may call this read-only method - no need to validate role
Collection models = RuntimeMetadataCatalog.getInstance().getModels(vdbID);
@@ -747,7 +736,7 @@
* @return a Collection of all <code>VirtualDatabase</code>s in the system.
* @throws VirtualDatabaseException if an error occurs while setting the state.
*/
-// private synchronized static Collection filterVirtualDatabases(Set vdbsToFilter) throws VirtualDatabaseException {
+// private static Collection filterVirtualDatabases(Set vdbsToFilter) throws VirtualDatabaseException {
//
// Collection vdbs = RuntimeMetadataCatalog.getVirtualDatabases();
//
Deleted: trunk/server/src/test/java/com/metamatrix/common/comm/platform/FakeAdminHelper.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/common/comm/platform/FakeAdminHelper.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/server/src/test/java/com/metamatrix/common/comm/platform/FakeAdminHelper.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -1,93 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.comm.platform;
-
-import java.util.Iterator;
-import java.util.Set;
-
-import com.metamatrix.admin.api.exception.security.InvalidSessionException;
-import com.metamatrix.api.exception.ComponentNotFoundException;
-import com.metamatrix.api.exception.security.AuthorizationException;
-import com.metamatrix.platform.admin.apiimpl.IAdminHelper;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.SessionToken;
-
-
-/**
- * @since 4.3
- */
-public class FakeAdminHelper implements
- IAdminHelper {
- private String userName;
- private Set userRoleNames;
-
- /**
- *
- * @since 4.3
- */
- public FakeAdminHelper(String userName, Set userRoleNames) {
- this.userName = userName;
- this.userRoleNames = userRoleNames;
- }
-
- /**
- * @see com.metamatrix.platform.admin.apiimpl.IAdminHelper#checkForRequiredRole(com.metamatrix.platform.security.api.SessionToken, java.lang.String)
- * @since 4.3
- */
- public void checkForRequiredRole(SessionToken adminToken,
- String roleName) throws AuthorizationException, ComponentNotFoundException {
- if ( adminToken.getUsername().equals(userName) ) {
- Iterator iter = userRoleNames.iterator();
- while ( iter.hasNext() ) {
- String userRole = (String)iter.next();
- if ( userRole.equals(roleName) ) {
- return;
- }
- }
- throw new AuthorizationException("User does not have required role [" + roleName + "]."); //$NON-NLS-1$ //$NON-NLS-2$
- }
- throw new AuthorizationException("User names are not equal. Incoming [" + adminToken.getUsername() + //$NON-NLS-1$
- "] Expected [" + userName + "]"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * @see com.metamatrix.platform.admin.apiimpl.IAdminHelper#checkForRequiredRole(com.metamatrix.platform.security.api.SessionToken, java.util.Set)
- * @since 4.3
- */
- public void checkForRequiredRole(SessionToken adminToken,
- Set roleNames) throws AuthorizationException, ComponentNotFoundException {
- Iterator roles = roleNames.iterator();
- while ( roles.hasNext() ) {
- this.checkForRequiredRole(adminToken, (String) roles.next());
- }
- }
-
- /**
- * @see com.metamatrix.platform.admin.apiimpl.IAdminHelper#validateSession(com.metamatrix.platform.security.api.MetaMatrixSessionID)
- * @since 4.3
- */
- public SessionToken validateSession(MetaMatrixSessionID sessionID) throws InvalidSessionException, ComponentNotFoundException {
- return new SessionToken(sessionID, "fake"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-}
Modified: trunk/server/src/test/java/com/metamatrix/common/comm/platform/server/TestAdminAuthInterceptor.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/common/comm/platform/server/TestAdminAuthInterceptor.java 2009-04-08 23:00:01 UTC (rev 733)
+++ trunk/server/src/test/java/com/metamatrix/common/comm/platform/server/TestAdminAuthInterceptor.java 2009-04-09 15:53:21 UTC (rev 734)
@@ -26,85 +26,96 @@
import java.util.HashSet;
import java.util.Set;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
import org.teiid.dqp.internal.process.DQPWorkContext;
-import junit.framework.TestCase;
-
import com.metamatrix.admin.api.exception.AdminException;
+import com.metamatrix.admin.api.exception.AdminProcessingException;
import com.metamatrix.admin.api.server.AdminRoles;
import com.metamatrix.admin.api.server.ServerAdmin;
-import com.metamatrix.admin.util.AdminMethodRoleResolver;
-import com.metamatrix.common.comm.platform.FakeAdminHelper;
+import com.metamatrix.api.exception.security.AuthorizationException;
+import com.metamatrix.api.exception.security.AuthorizationMgmtException;
import com.metamatrix.common.comm.platform.socket.server.AdminAuthorizationInterceptor;
import com.metamatrix.core.util.SimpleMock;
-import com.metamatrix.platform.admin.apiimpl.IAdminHelper;
+import com.metamatrix.platform.admin.api.ExtensionSourceAdminAPI;
+import com.metamatrix.platform.admin.apiimpl.ExtensionSourceAdminAPIImpl;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
+import com.metamatrix.platform.security.api.service.AuthorizationServiceInterface;
/**
* @since 4.3
*/
-public class TestAdminAuthInterceptor extends TestCase {
+public class TestAdminAuthInterceptor {
- /**
- * Constructor for TestAdminMethodRoleResolver.
- * @param name
- */
- public TestAdminAuthInterceptor(String name) {
- super(name);
+ @Before public void setUp() throws Exception {
+ DQPWorkContext.getWorkContext().setSessionToken(new SessionToken(new MetaMatrixSessionID(1), "gojo")); //$NON-NLS-1$
}
- @Override
- protected void setUp() throws Exception {
- DQPWorkContext.getWorkContext().setSessionToken(new SessionToken(new MetaMatrixSessionID(1), "gojo")); //$NON-NLS-1$ //$NON-NLS-2$
+ @After public void tearDown() throws Exception {
+ DQPWorkContext.setWorkContext(new DQPWorkContext());
}
- @Override
- protected void tearDown() throws Exception {
- DQPWorkContext.setWorkContext(new DQPWorkContext());
+ @Test(expected=AdminProcessingException.class) public void testAddUserUDF_fail() throws AdminException {
+ Set<String> userRoles = new HashSet<String>();
+ ServerAdmin serverAdmin = getTestServerAdmin(userRoles, ServerAdmin.class);
+ serverAdmin.addUDF(null, null);
}
- public void testAddUserUDF_fail() throws AdminException {
- Set userRoles = new HashSet();
- ServerAdmin serverAdmin = getTestServerAdmin(userRoles);
- try {
- serverAdmin.addUDF(null, null);
- } catch (AdminException err) {
-
- }
- }
+ private <T> T getTestServerAdmin(final Set<String> userRoles, Class<T> iface) {
+ return getTestServerAdmin(userRoles, iface, SimpleMock.createSimpleMock(iface));
+ }
- private ServerAdmin getTestServerAdmin(Set userRoles) throws AdminException {
- IAdminHelper authHelper = new FakeAdminHelper("gojo", userRoles); //$NON-NLS-1$
- AdminMethodRoleResolver roleResolver = new AdminMethodRoleResolver();
- roleResolver.init();
- AdminAuthorizationInterceptor authInterceptor = new AdminAuthorizationInterceptor(authHelper, roleResolver, SimpleMock.createSimpleMock(ServerAdmin.class));
- ServerAdmin serverAdmin = (ServerAdmin)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {ServerAdmin.class}, authInterceptor);
- return serverAdmin;
+ private <T> T getTestServerAdmin(final Set<String> userRoles, Class<T> iface, T impl) {
+ AuthorizationServiceInterface service = Mockito.mock(AuthorizationServiceInterface.class);
+ try {
+ Mockito.stub(service.isCallerInRole((SessionToken)Mockito.anyObject(), Mockito.argThat(new BaseMatcher<String>() {
+ @Override
+ public boolean matches(Object arg0) {
+ return userRoles.contains(arg0);
+ }
+
+ @Override
+ public void describeTo(Description arg0) {
+
+ }
+ }))).toReturn(Boolean.TRUE);
+ } catch (AuthorizationMgmtException e) {
+ throw new RuntimeException(e);
+ }
+ AdminAuthorizationInterceptor authInterceptor = new AdminAuthorizationInterceptor(service, impl);
+ return (T)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {iface}, authInterceptor);
}
- public void testAddUDF_succeed() throws Exception {
- Set userRoles = new HashSet();
+ @Test public void testAddUDF_succeed() throws Exception {
+ Set<String> userRoles = new HashSet<String>();
userRoles.add(AdminRoles.RoleName.ADMIN_SYSTEM);
- ServerAdmin serverAdmin = getTestServerAdmin(userRoles);
+ ServerAdmin serverAdmin = getTestServerAdmin(userRoles, ServerAdmin.class);
serverAdmin.addUDF(null, null);
}
- public void testGetVDBs() throws Exception {
- Set userRoles = new HashSet();
- ServerAdmin serverAdmin = getTestServerAdmin(userRoles);
+ @Test public void testGetVDBs() throws Exception {
+ Set<String> userRoles = new HashSet<String>();
+ ServerAdmin serverAdmin = getTestServerAdmin(userRoles, ServerAdmin.class);
serverAdmin.getVDBs("*"); //$NON-NLS-1$
}
- public void testReadOnlyFails() throws Exception {
- Set userRoles = new HashSet();
- ServerAdmin serverAdmin = getTestServerAdmin(userRoles);
- try {
- serverAdmin.getSessions("*"); //$NON-NLS-1$
- } catch (AdminException e) {
-
- }
+ @Test(expected=AdminProcessingException.class) public void testReadOnlyFails() throws Exception {
+ Set<String> userRoles = new HashSet<String>();
+ ServerAdmin serverAdmin = getTestServerAdmin(userRoles, ServerAdmin.class);
+ serverAdmin.getSessions("*"); //$NON-NLS-1$
}
+ @Test(expected=AuthorizationException.class) public void testSubsystemReadOnlyFails() throws Exception {
+ Set<String> userRoles = new HashSet<String>();
+ ExtensionSourceAdminAPI serverAdmin = getTestServerAdmin(userRoles, ExtensionSourceAdminAPI.class, ExtensionSourceAdminAPIImpl.getInstance());
+ serverAdmin.getSourceDescriptors();
+ }
+
}
15 years, 8 months
teiid SVN: r733 - in trunk/engine/src: test/java/org/teiid/dqp/internal/pooling/connector and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-08 19:00:01 -0400 (Wed, 08 Apr 2009)
New Revision: 733
Added:
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPooledConnector.java
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/PooledConnector.java
Log:
TEIID-481 fix for npe on pooled xa connections
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/PooledConnector.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/PooledConnector.java 2009-04-08 20:38:18 UTC (rev 732)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/PooledConnector.java 2009-04-08 23:00:01 UTC (rev 733)
@@ -100,6 +100,7 @@
@Override
public void start(ConnectorEnvironment environment)
throws ConnectorException {
+ this.environment = environment;
pool.initialize(environment);
if (xaPool != null) {
xaPool.initialize(environment);
Added: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPooledConnector.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPooledConnector.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPooledConnector.java 2009-04-08 23:00:01 UTC (rev 733)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.pooling.connector;
+
+import java.util.Properties;
+
+import javax.transaction.Transaction;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.connector.api.ConnectorLogger;
+import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.xa.api.TransactionContext;
+import org.teiid.connector.xa.api.XAConnection;
+import org.teiid.connector.xa.api.XAConnector;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorEnvironmentImpl;
+
+import com.metamatrix.common.application.ApplicationEnvironment;
+
+public class TestPooledConnector {
+
+ @Test public void testGetXAConnection() throws Exception {
+ XAConnector connector = Mockito.mock(XAConnector.class);
+ PooledConnector pc = new PooledConnector(connector);
+ pc.start(new ConnectorEnvironmentImpl(new Properties(), Mockito.mock(ConnectorLogger.class), new ApplicationEnvironment()));
+ TransactionContext tc = Mockito.mock(TransactionContext.class);
+ Mockito.stub(tc.getTransaction()).toReturn(Mockito.mock(Transaction.class));
+ Mockito.stub(tc.getTxnID()).toReturn("1"); //$NON-NLS-1$
+ XAConnection conn = pc.getXAConnection(Mockito.mock(ExecutionContext.class), tc);
+ conn.close();
+ XAConnection conn1 = pc.getXAConnection(Mockito.mock(ExecutionContext.class), tc);
+ assertSame(conn, conn1);
+ pc.stop();
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPooledConnector.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 8 months
teiid SVN: r732 - in trunk/server/src: main/java/com/metamatrix/platform/security/membership/service and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-08 16:38:18 -0400 (Wed, 08 Apr 2009)
New Revision: 732
Modified:
trunk/server/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java
trunk/server/src/main/java/com/metamatrix/platform/security/membership/service/MembershipServiceImpl.java
trunk/server/src/main/resources/com/metamatrix/platform/i18n.properties
trunk/server/src/test/java/com/metamatrix/platform/security/membership/service/TestMembershipServiceImpl.java
Log:
TEIID-476 adding a property to restrict root logons
Modified: trunk/server/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java 2009-04-08 15:36:10 UTC (rev 731)
+++ trunk/server/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java 2009-04-08 20:38:18 UTC (rev 732)
@@ -64,6 +64,7 @@
public static final String ADMIN_PASSWORD = ConfigurationPropertyNames.MEMBERSHIP_ADMIN_PASSWORD;
public static final String ADMIN_USERNAME = ConfigurationPropertyNames.MEMBERSHIP_ADMIN_USERNAME;
public static final String DOMAIN_ACTIVE = "activate"; //$NON-NLS-1$
+ public static final String ADMIN_HOSTS = "metamatrix.security.admin.allowedHosts"; //$NON-NLS-1$
public static final String SECURITY_ENABLED = ConfigurationPropertyNames.MEMBERSHIP_SECURITY_ENABLED;
public static final String DOMAIN_PROPERTIES = "propertiesFile"; //$NON-NLS-1$
Modified: trunk/server/src/main/java/com/metamatrix/platform/security/membership/service/MembershipServiceImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/security/membership/service/MembershipServiceImpl.java 2009-04-08 15:36:10 UTC (rev 731)
+++ trunk/server/src/main/java/com/metamatrix/platform/security/membership/service/MembershipServiceImpl.java 2009-04-08 20:38:18 UTC (rev 732)
@@ -38,7 +38,10 @@
import java.util.List;
import java.util.Properties;
import java.util.Set;
+import java.util.regex.Pattern;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
import com.metamatrix.api.exception.security.InvalidPrincipalException;
import com.metamatrix.api.exception.security.InvalidUserException;
@@ -111,6 +114,8 @@
private String adminUsername = DEFAULT_ADMIN_USERNAME;
private String adminCredentials;
+ private Pattern allowedAddresses;
+
private boolean isSecurityEnabled = true;
public MembershipServiceImpl() {
@@ -137,6 +142,11 @@
throw new ServiceException(PlatformPlugin.Util.getString("MembershipServiceImpl.Root_password_required")); //$NON-NLS-1$
}
+ String property = env.getProperty(ADMIN_HOSTS);
+ if (property != null && property.length() > 0) {
+ this.allowedAddresses = Pattern.compile(property);
+ }
+
isSecurityEnabled = Boolean.valueOf(env.getProperty(SECURITY_ENABLED)).booleanValue();
LogManager.logDetail(LogSecurityConstants.CTX_MEMBERSHIP, "Security Enabled: " + isSecurityEnabled); //$NON-NLS-1$
@@ -266,6 +276,14 @@
protected void killService() {
this.shutdownDomains();
}
+
+ void setAllowedAddresses(Pattern allowedAddresses) {
+ this.allowedAddresses = allowedAddresses;
+ }
+
+ void setAdminCredentials(String adminCredentials) {
+ this.adminCredentials = adminCredentials;
+ }
/**
* Authenticate a user with the specified username and credential
@@ -306,6 +324,17 @@
}
if (isSuperUser(username)) {
+ if (isSecurityEnabled && allowedAddresses != null) {
+ String address = DQPWorkContext.getWorkContext().getClientAddress();
+ if (address == null) {
+ LogManager.logWarning(LogSecurityConstants.CTX_MEMBERSHIP, PlatformPlugin.Util.getString("MembershipServiceImpl.unknown_host")); //$NON-NLS-1$
+ return new FailedAuthenticationToken();
+ }
+ if (!allowedAddresses.matcher(address).matches() || address.equals(CurrentConfiguration.getInstance().getHostAddress().getHostAddress())) {
+ LogManager.logWarning(LogSecurityConstants.CTX_MEMBERSHIP, PlatformPlugin.Util.getString("MembershipServiceImpl.invalid_host", address, allowedAddresses.pattern())); //$NON-NLS-1$
+ return new FailedAuthenticationToken();
+ }
+ }
// decrypt admin password for comparison
if ((credential != null && adminCredentials.equals(String.valueOf(credential.getCredentialsAsCharArray())))) {
return new SuccessfulAuthenticationToken(trustedPayload, username);
Modified: trunk/server/src/main/resources/com/metamatrix/platform/i18n.properties
===================================================================
--- trunk/server/src/main/resources/com/metamatrix/platform/i18n.properties 2009-04-08 15:36:10 UTC (rev 731)
+++ trunk/server/src/main/resources/com/metamatrix/platform/i18n.properties 2009-04-08 20:38:18 UTC (rev 732)
@@ -1267,6 +1267,8 @@
MembershipServiceImpl.Decrypt_failed=Could not decrypt the encrypted password for user ''{0}''
MembershipServiceImpl.source_exception=Membership Domain ''{0}'' failed to perform the desired operation, please check the settings for this domain
MembershipServiceImpl.load_error=Could not load file ''{0}'' from the classpath, the file system, or as a URL.
+MembershipServiceImpl.unknown_host=Did not allow root user authentication attempt, since root logons are restricted and could not determine the remote host.
+MembershipServiceImpl.invalid_host=Could not authenticate root user, since the client address {0} is not in the allowed values {1}
LDAPMembershipDomain.No_annonymous=Annonymous user authentications are not allowed in domain {0}
LDAPMembershipDomain.Required_property=Required property {0} was missing.
Modified: trunk/server/src/test/java/com/metamatrix/platform/security/membership/service/TestMembershipServiceImpl.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/platform/security/membership/service/TestMembershipServiceImpl.java 2009-04-08 15:36:10 UTC (rev 731)
+++ trunk/server/src/test/java/com/metamatrix/platform/security/membership/service/TestMembershipServiceImpl.java 2009-04-08 20:38:18 UTC (rev 732)
@@ -23,9 +23,12 @@
package com.metamatrix.platform.security.membership.service;
import java.util.Properties;
+import java.util.regex.Pattern;
import junit.framework.TestCase;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.metamatrix.api.exception.security.InvalidPrincipalException;
import com.metamatrix.common.util.crypto.CryptoUtil;
import com.metamatrix.platform.security.api.Credentials;
@@ -86,6 +89,26 @@
return membershipService;
}
+ public void testSuperAuthenticate() throws Exception {
+ MembershipServiceImpl membershipService = createMembershipService();
+ membershipService.setAllowedAddresses(Pattern.compile("192[.]168[.]0[.]2")); //$NON-NLS-1$
+ membershipService.setAdminCredentials("pass1"); //$NON-NLS-1$
+
+ AuthenticationToken at = membershipService.authenticateUser(MembershipServiceImpl.DEFAULT_ADMIN_USERNAME, new Credentials("pass1".toCharArray()), null, null); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertFalse(at.isAuthenticated());
+ DQPWorkContext.getWorkContext().setClientAddress("192.168.0.1"); //$NON-NLS-1$
+ at = membershipService.authenticateUser(MembershipServiceImpl.DEFAULT_ADMIN_USERNAME, new Credentials("pass1".toCharArray()), null, null); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertFalse(at.isAuthenticated());
+ DQPWorkContext.getWorkContext().setClientAddress("192.168.0.2"); //$NON-NLS-1$
+ at = membershipService.authenticateUser(MembershipServiceImpl.DEFAULT_ADMIN_USERNAME, new Credentials("pass1".toCharArray()), null, null); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertTrue(at.isAuthenticated());
+ }
+
+
+
public void testGetPrincipal() throws Exception {
MembershipServiceImpl membershipService = createMembershipService();
15 years, 8 months
teiid SVN: r730 - in trunk: client/src/main/java/com/metamatrix/admin/api/objects and 29 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-08 11:36:06 -0400 (Wed, 08 Apr 2009)
New Revision: 730
Added:
trunk/client/src/main/java/com/metamatrix/admin/api/objects/Transaction.java
trunk/client/src/main/java/com/metamatrix/admin/objects/TransactionImpl.java
Removed:
trunk/common-internal/src/main/java/com/metamatrix/common/xa/TransactionID.java
trunk/common-internal/src/main/java/com/metamatrix/server/admin/api/TransactionAdminAPI.java
trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/TransactionAdminAPIImpl.java
Modified:
trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreMonitoringAdmin.java
trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreRuntimeStateAdmin.java
trunk/client/src/main/java/com/metamatrix/admin/api/objects/Request.java
trunk/client/src/main/java/com/metamatrix/admin/objects/MMAdminObject.java
trunk/client/src/main/resources/com/metamatrix/admin/i18n.properties
trunk/common-core/src/test/java/com/metamatrix/core/util/SimpleMock.java
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/AuthorizationAdminAPI.java
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/SubSystemAdminAPI.java
trunk/common-internal/src/main/resources/com/metamatrix/common/properties/text.properties
trunk/connector-api/src/main/java/org/teiid/connector/xa/api/TransactionContext.java
trunk/console/src/main/java/com/metamatrix/console/models/ModelManager.java
trunk/console/src/main/java/com/metamatrix/console/models/TransactionManager.java
trunk/console/src/main/java/com/metamatrix/console/ui/layout/PanelsTreeModel.java
trunk/console/src/main/java/com/metamatrix/console/ui/layout/WorkspaceController.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/transactions/TransactionTableModel.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/transactions/TransactionsPanel.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTransactionService.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnection.java
trunk/engine/src/main/java/com/metamatrix/common/application/Application.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/DQPServiceNames.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionContextImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java
trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java
trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java
trunk/server/src/main/java/com/metamatrix/admin/server/ServerAdminImpl.java
trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java
trunk/server/src/main/java/com/metamatrix/admin/server/ServerRuntimeStateAdminImpl.java
trunk/server/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java
trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformTransactionService.java
trunk/server/src/main/java/com/metamatrix/server/query/service/QueryService.java
trunk/server/src/main/java/com/metamatrix/server/query/service/QueryServiceInterface.java
trunk/server/src/main/resources/com/metamatrix/admin/util/methodroles.properties
trunk/server/src/test/java/com/metamatrix/admin/server/FakeQueryService.java
Log:
TEIID-129 exposing the ability to administer transactions. reviewed by RR.
Modified: trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreMonitoringAdmin.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreMonitoringAdmin.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreMonitoringAdmin.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -34,6 +34,7 @@
import com.metamatrix.admin.api.objects.Request;
import com.metamatrix.admin.api.objects.Session;
import com.metamatrix.admin.api.objects.SystemObject;
+import com.metamatrix.admin.api.objects.Transaction;
import com.metamatrix.admin.api.objects.VDB;
@@ -228,5 +229,13 @@
*/
Collection getPropertyDefinitions(String identifier,
String className) throws AdminException;
+
+
+ /**
+ * Get all transaction matching the identifier.
+ * @return
+ * @throws AdminException
+ */
+ Collection<Transaction> getTransactions() throws AdminException;
}
Modified: trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreRuntimeStateAdmin.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreRuntimeStateAdmin.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/core/CoreRuntimeStateAdmin.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -22,6 +22,8 @@
package com.metamatrix.admin.api.core;
+import javax.transaction.xa.Xid;
+
import com.metamatrix.admin.api.exception.AdminException;
@@ -116,5 +118,21 @@
*/
public void changeVDBStatus(String name, String version, int status)
throws AdminException;
+
+ /**
+ * Mark the given global transaction as rollback only.
+ * @param transactionId
+ * @throws AdminException
+ */
+ void terminateTransaction(Xid transactionId) throws AdminException;
+
+ /**
+ * Mark the given transaction as rollback only.
+ * @param identifier
+ * The exact identifier of the transaction. Wild card is not supported.
+ * @param the session the transaction is associated with.
+ * @throws AdminException
+ */
+ void terminateTransaction(String transactionId, String sessionId) throws AdminException;
}
Modified: trunk/client/src/main/java/com/metamatrix/admin/api/objects/Request.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/objects/Request.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/objects/Request.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -31,8 +31,8 @@
* requests (the requests that are being processed on the physical data sources) as part
* of original request.
*
- * <p>A request is identified by a numbers separated by "." (dots). usually in they are arranged
- * in the pattern [session].[request] or [session].[request].[source request] </p>
+ * <p>A request is identified by a numbers separated by '|'. usually in they are arranged
+ * in the pattern [session]|[request] or [session]|[request]|[source request] </p>
* @since 4.3
*/
public interface Request extends AdminObject {
Added: trunk/client/src/main/java/com/metamatrix/admin/api/objects/Transaction.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/objects/Transaction.java (rev 0)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/objects/Transaction.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.admin.api.objects;
+
+import java.util.Date;
+
+import javax.transaction.xa.Xid;
+
+public interface Transaction extends AdminObject {
+
+ /**
+ * Get the session associated with the this transaction.
+ * May be null for an unassociated Global transaction.
+ * @return
+ */
+ String getAssociatedSession();
+
+ /**
+ * Get the scope for the transaction. Will be one of GLOBAL, LOCAL, or REQUEST
+ * @return
+ */
+ String getScope();
+
+ /**
+ * Return the Xid of the Global transaction. Will be null for non-Global transactions.
+ * @return
+ */
+ Xid getXid();
+
+ /**
+ * Get the current status. See {@link javax.transaction.Status} for
+ * possible values.
+ * @return
+ */
+ String getStatus();
+
+ /**
+ * Get the date the transaction was created.
+ * @return
+ */
+ Date getCreated();
+
+}
Property changes on: trunk/client/src/main/java/com/metamatrix/admin/api/objects/Transaction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/client/src/main/java/com/metamatrix/admin/objects/MMAdminObject.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/objects/MMAdminObject.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/client/src/main/java/com/metamatrix/admin/objects/MMAdminObject.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -32,6 +32,7 @@
import com.metamatrix.admin.api.exception.AdminException;
import com.metamatrix.admin.api.exception.AdminProcessingException;
import com.metamatrix.admin.api.objects.AdminObject;
+import com.metamatrix.admin.api.objects.Transaction;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.util.StringUtil;
@@ -82,14 +83,14 @@
public static final int OBJECT_TYPE_ROLE = 16;
/**Object type code for Session*/
public static final int OBJECT_TYPE_SESSION = 17;
- /**Object type code for SourceRequest*/
- public static final int OBJECT_TYPE_SOURCE_REQUEST = 18;
/**Object type code for SystemObject*/
public static final int OBJECT_TYPE_SYSTEM_OBJECT = 19;
/**Object type code for User*/
public static final int OBJECT_TYPE_USER = 20;
/**Object type code for VDB*/
public static final int OBJECT_TYPE_VDB = 21;
+ /**Object type code for TRANSACTION*/
+ public static final int OBJECT_TYPE_TRANSACTION = 22;
@@ -118,7 +119,7 @@
objectTypeMap.put(com.metamatrix.admin.api.objects.SystemObject.class.getName(), new Integer(OBJECT_TYPE_SYSTEM_OBJECT));
objectTypeMap.put(com.metamatrix.admin.api.objects.User.class.getName(), new Integer(OBJECT_TYPE_USER));
objectTypeMap.put(com.metamatrix.admin.api.objects.VDB.class.getName(), new Integer(OBJECT_TYPE_VDB));
-
+ objectTypeMap.put(Transaction.class.getName(), Integer.valueOf(OBJECT_TYPE_TRANSACTION));
}
@@ -164,7 +165,7 @@
* @param identifierParts Parts of the fully-qualified identifier of the MetaMatrix Object
* @since 4.3
*/
- public MMAdminObject(String[] identifierParts) {
+ public MMAdminObject(String ... identifierParts) {
if (identifierParts == null) {
throw new IllegalArgumentException(AdminPlugin.Util.getString("AbstractAdminObject.0")); //$NON-NLS-1$
}
Added: trunk/client/src/main/java/com/metamatrix/admin/objects/TransactionImpl.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/objects/TransactionImpl.java (rev 0)
+++ trunk/client/src/main/java/com/metamatrix/admin/objects/TransactionImpl.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.admin.objects;
+
+import javax.transaction.xa.Xid;
+
+import com.metamatrix.admin.AdminPlugin;
+import com.metamatrix.admin.api.objects.Transaction;
+import com.metamatrix.common.xa.MMXid;
+
+public class TransactionImpl extends MMAdminObject implements Transaction {
+
+ private String associatedSession;
+ private String scope;
+ private MMXid xid;
+ private String status;
+
+ public TransactionImpl(String ... id) {
+ super(id);
+ }
+
+ public String getAssociatedSession() {
+ return associatedSession;
+ }
+
+ public void setAssociatedSession(String associatedSession) {
+ this.associatedSession = associatedSession;
+ }
+
+ public String getScope() {
+ return scope;
+ }
+
+ public void setScope(String scope) {
+ this.scope = scope;
+ }
+
+ public Xid getXid() {
+ return xid;
+ }
+
+ public void setXid(MMXid xid) {
+ this.xid = xid;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append(AdminPlugin.Util.getString("TransactionImpl.identifier")).append(getIdentifier()); //$NON-NLS-1$
+ result.append(AdminPlugin.Util.getString("TransactionImpl.associatedSession")).append(associatedSession); //$NON-NLS-1$
+ result.append(AdminPlugin.Util.getString("TransactionImpl.scope")).append(scope); //$NON-NLS-1$
+ result.append(AdminPlugin.Util.getString("TransactionImpl.status")).append(status); //$NON-NLS-1$
+ result.append(AdminPlugin.Util.getString("TransactionImpl.xid")).append(xid); //$NON-NLS-1$
+ return result.toString();
+ }
+
+}
Property changes on: trunk/client/src/main/java/com/metamatrix/admin/objects/TransactionImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/client/src/main/resources/com/metamatrix/admin/i18n.properties
===================================================================
--- trunk/client/src/main/resources/com/metamatrix/admin/i18n.properties 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/client/src/main/resources/com/metamatrix/admin/i18n.properties 2009-04-08 15:36:06 UTC (rev 730)
@@ -238,8 +238,12 @@
MMVDB.versionedBy=\n\ Versioned By:\
MMVDB.properties=\n\ properties:\
+TransactionImpl.identifier=Transaction:\n Identifier:\
+TransactionImpl.associatedSession=\n\ Associated Session:\
+TransactionImpl.scope=\n\ Scope:\
+TransactionImpl.status=\n\ Status:\
+TransactionImpl.xid=\n\ Xid:\
-
AdminStatus.CODE_UNKNOWN=Unknown.
AdminStatus.CODE_SUCCESS=Success.
AdminStatus.CODE_DECRYPTION_FAILED=Warning: The following connector bindings have NOT been imported because the passwords could not be decrypted: {0}. The bindings may have been exported from a system with a different keystore. You must either import with AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR then manually re-enter the passwords by setting the properties on the Connector binding via the Admin API, or via the Console ''Properties'' tab, or convert the file with the ''convertpasswords'' utility and re-import.
Modified: trunk/common-core/src/test/java/com/metamatrix/core/util/SimpleMock.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/core/util/SimpleMock.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/common-core/src/test/java/com/metamatrix/core/util/SimpleMock.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -43,7 +43,7 @@
}
if (clazz.isPrimitive()) {
- return null;
+ return 0;
}
if (!clazz.isInterface()) {
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/xa/TransactionID.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/xa/TransactionID.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/xa/TransactionID.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -1,86 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- * Date: Jan 2, 2003
- * Time: 3:27:45 PM
- */
-package com.metamatrix.common.xa;
-
-import java.io.Serializable;
-
-public class TransactionID implements Serializable {
-
- private String ID;
-
- /**
- * Create a new instance of TranscationID
- *
- * @param id uniqueID
- */
- public TransactionID(String id) {
- this.ID = id;
- }
-
- /**
- * Returns the ID value.
- * @return String ID value
- */
- public String getID() {
- return ID;
- }
-
- /**
- * Get hash code for object
- * @return Hash code
- */
- public int hashCode() {
- return this.ID.hashCode();
- }
-
- /**
- * Returns <code>true</code> if this object is equal to the other object.
- * Equality is based on the ID value.
- *
- * @param obj Object to compare with
- * @return boolean indicating if objects are equal
- */
- public boolean equals(Object obj) {
- if ( this == obj ) {
- return true;
- }
- if (!(obj instanceof TransactionID)) {
- return false;
- }
-
- return ((TransactionID) obj).ID.equals(ID);
- }
-
- /**
- * Returns a string representation of an instance of this class.
- * @return String representation of this instance.
- */
- public String toString() {
- return this.ID;
- }
-
-}
Modified: trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/AuthorizationAdminAPI.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/AuthorizationAdminAPI.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/AuthorizationAdminAPI.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -36,7 +36,6 @@
import com.metamatrix.platform.security.api.AuthorizationPolicyID;
import com.metamatrix.platform.security.api.AuthorizationRealm;
import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
-import com.metamatrix.platform.security.api.SessionToken;
public interface AuthorizationAdminAPI extends SubSystemAdminAPI {
Modified: trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/SubSystemAdminAPI.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/SubSystemAdminAPI.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/SubSystemAdminAPI.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -26,6 +26,7 @@
/**
* This is the base interface of all subsystem administrative API interfaces.
+ * @deprecated
*/
public interface SubSystemAdminAPI extends Serializable {
Deleted: trunk/common-internal/src/main/java/com/metamatrix/server/admin/api/TransactionAdminAPI.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/server/admin/api/TransactionAdminAPI.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/common-internal/src/main/java/com/metamatrix/server/admin/api/TransactionAdminAPI.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.server.admin.api;
-
-import java.util.Collection;
-
-import com.metamatrix.admin.api.exception.security.InvalidSessionException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MultipleException;
-import com.metamatrix.api.exception.security.AuthorizationException;
-import com.metamatrix.common.xa.TransactionID;
-import com.metamatrix.common.xa.XATransactionException;
-import com.metamatrix.platform.admin.api.SubSystemAdminAPI;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-
-public interface TransactionAdminAPI extends SubSystemAdminAPI {
-
- /**
- * Return all transactions that are in the system.
- *
- * @return a collection of <code>ServerTransaction</code> objects.
- * @throws AuthorizationException if caller is not authorized to perform this method.
- * @throws InvalidSessionException if the <code>callerSessionID</code> is not valid or is expired.
- * @throws MetaMatrixComponentException if an error occurred in communicating with a component.
- */
- Collection getAllTransactions()
- throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException;
-
- /**
- * Terminate a transaction.
- * If status == STATUS_ACTIVE or STATUS_MARKED_ROLLBACK, rollback transaction.
- * Else, set status to STATUS_ROLLEDBACK.
- *
- * @param transactionID ID of the transaction to be rolledback.
- * @throws AuthorizationException if caller is not authorized to perform this method.
- * @throws InvalidSessionException if the <code>callerSessionID</code> is not valid or is expired.
- * @throws com.metamatrix.common.xa.InvalidTransactionIDException if the Transaction does not exist.
- * @throws MetaMatrixComponentException if an error occurred in communicating with a component.
- */
- void terminateTransaction(TransactionID transactionID)
- throws AuthorizationException, InvalidSessionException, XATransactionException, MetaMatrixComponentException ;
-
- /**
- * Terminate all transactions for the user session.
- * If status == STATUS_ACTIVE or STATUS_MARKED_ROLLBACK, rollback transaction.
- * Else, set status to STATUS_ROLLEDBACK.
- *
- * @param userSessionID the primary identifier for the user account.
- * @throws AuthorizationException if caller is not authorized to perform this method.
- * @throws InvalidSessionException if the <code>callerSessionID</code> is not valid or is expired.
- * @throws MetaMatrixComponentException if an error occurred in communicating with a component.
- */
- void terminateAllTransactions(MetaMatrixSessionID userSessionID)
- throws AuthorizationException, InvalidSessionException, MultipleException, MetaMatrixComponentException ;
-
-}
-
Modified: trunk/common-internal/src/main/resources/com/metamatrix/common/properties/text.properties
===================================================================
--- trunk/common-internal/src/main/resources/com/metamatrix/common/properties/text.properties 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/common-internal/src/main/resources/com/metamatrix/common/properties/text.properties 2009-04-08 15:36:06 UTC (rev 730)
@@ -37,7 +37,7 @@
//# SplashPanel #
//################################################################################################################################
-SplashPanel.copyright = � {0}. All rights reserved.
+SplashPanel.copyright = {0}. All rights reserved.
SplashPanel.trademark = MetaMatrix, the MetaMatrix logo, MetaMatrix Enterprise Server, MetaMatrix Enterprise Designer, MetaMatrix Enterprise Console and MetaMatrix Enterprise Catalog are trademarks of MetaMatrix, Inc.
SplashPanel.penaltyNotice = This program is protected by copyright laws and international treaties. Unauthorized reproduction or distribution of this program, or any portion thereof, may result in serious civil and criminal penalties.
SplashPanel.applicationName = Application Name
Modified: trunk/connector-api/src/main/java/org/teiid/connector/xa/api/TransactionContext.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/xa/api/TransactionContext.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/connector-api/src/main/java/org/teiid/connector/xa/api/TransactionContext.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -30,11 +30,11 @@
public interface TransactionContext {
public enum Scope {
- TRANSACTION_BLOCK,
- TRANSACTION_GLOBAL,
- TRANSACTION_LOCAL,
- TRANSACTION_NONE,
- TRANSACTION_REQUEST
+ BLOCK,
+ GLOBAL,
+ LOCAL,
+ NONE,
+ REQUEST
}
public boolean isInTransaction();
Modified: trunk/console/src/main/java/com/metamatrix/console/models/ModelManager.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/models/ModelManager.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/console/src/main/java/com/metamatrix/console/models/ModelManager.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -44,7 +44,6 @@
import com.metamatrix.platform.admin.api.SubSystemAdminAPI;
import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
import com.metamatrix.server.admin.api.RuntimeMetadataAdminAPI;
-import com.metamatrix.server.admin.api.TransactionAdminAPI;
public class ModelManager {
@@ -329,11 +328,6 @@
return (RuntimeMetadataAdminAPI) getSubSystemAdminAPI(RuntimeMetadataAdminAPI.class, conn);
}
- public static TransactionAdminAPI getTransactionAPI(ConnectionInfo conn) {
-
- return (TransactionAdminAPI) getSubSystemAdminAPI(TransactionAdminAPI.class, conn);
- }
-
public static ExtensionSourceAdminAPI getExtensionSourceAPI(ConnectionInfo conn) {
return (ExtensionSourceAdminAPI) getSubSystemAdminAPI(ExtensionSourceAdminAPI.class, conn);
Modified: trunk/console/src/main/java/com/metamatrix/console/models/TransactionManager.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/models/TransactionManager.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/console/src/main/java/com/metamatrix/console/models/TransactionManager.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -24,23 +24,16 @@
import java.util.Collection;
-import com.metamatrix.api.exception.ComponentNotFoundException;
-
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.xa.TransactionID;
+import com.metamatrix.admin.api.objects.Transaction;
import com.metamatrix.console.connections.ConnectionInfo;
import com.metamatrix.console.ui.views.transactions.TransactionTableModel;
-import com.metamatrix.console.util.LogContexts;
import com.metamatrix.console.util.RuntimeExternalException;
-import com.metamatrix.server.admin.api.TransactionAdminAPI;
-
/**
* Extension of TimedManager to manage the Transactions tab. It creates and
* maintains the tab's table model, but has no reference to the tab itself.
*/
public class TransactionManager extends TimedManager {
- private TransactionAdminAPI transAPI;
private TransactionTableModel tableModel;
// Constructors and initialization methods
@@ -48,7 +41,6 @@
public TransactionManager(ConnectionInfo connection) {
super(connection);
super.init();
- transAPI = ModelManager.getTransactionAPI(getConnection());
//Create the table model, initially empty.
tableModel = new TransactionTableModel();
}
@@ -71,28 +63,15 @@
public void refreshTableModel() {
super.refresh(false);
//Make API call to get all transactions
- Collection /*<ServerTransaction>*/ tx = null;
+ Collection<Transaction> tx = null;
try {
- tx = transAPI.getAllTransactions();
- } catch (ComponentNotFoundException ex) {
- //Exception should not occur. Throw to caller as a
- //RuntimeExternalException.
- LogManager.logError(LogContexts.TRANSACTIONS, ex,
- "Error retrieving list of transactions. Transaction Service may not be running."); //$NON-NLS-1$
- throw new RuntimeExternalException(ex);
+ tx = getConnection().getServerAdmin().getTransactions();
} catch (Exception ex) {
- //Exception should not occur. Throw to caller as a
- //RuntimeExternalException.
- LogManager.logError(LogContexts.TRANSACTIONS, ex,
- "Error retrieving list of transactions."); //$NON-NLS-1$
throw new RuntimeExternalException(ex);
}
//Repopulate the table model from the list of transactions returned.
tableModel.resetFromTransactionsList(tx);
}
- public TransactionID transactionIDForTransactionNum(Long transactionNum) {
- return tableModel.transactionIDForTransactionNum(transactionNum);
- }
}
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/layout/PanelsTreeModel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/layout/PanelsTreeModel.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/layout/PanelsTreeModel.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -54,9 +54,9 @@
public static final String QUERIES = "Queries"; //$NON-NLS-1$
public static final Class QUERIES_PANEL_CLASS =
com.metamatrix.console.ui.views.queries.QueryPanel.class;
-// public static final String TRANSACTIONS = "Transactions";
-// public static final Class TRANSACTIONS_PANEL_CLASS =
-// com.metamatrix.console.ui.views.transactions.TransactionsPanel.class;
+ public static final String TRANSACTIONS = "Transactions";
+ public static final Class TRANSACTIONS_PANEL_CLASS =
+ com.metamatrix.console.ui.views.transactions.TransactionsPanel.class;
public static final String CONFIGURATION = "Configuration"; //$NON-NLS-1$
public static final String SYS_PROPS = "System Properties"; //$NON-NLS-1$
public static final Class SYSTEM_PROPERTIES_PANEL_CLASS =
@@ -221,12 +221,12 @@
runtimeMMServer.add(queries);
// transactions panel node
-// PanelsTreeNode transactions = new PanelsTreeNode(TRANSACTIONS,
-// TRANSACTIONS_PANEL_CLASS, connection, false);
-// transactions.setToolTipText(
-// "View and manage transactions that are currently being executed "
-// + "in the MetaMatrix Server");
-// runtimeMMServer.add(transactions);
+ PanelsTreeNode transactions = new PanelsTreeNode(TRANSACTIONS,
+ TRANSACTIONS_PANEL_CLASS, connection, false);
+ transactions.setToolTipText(
+ "View and manage transactions that are currently being executed "
+ + "in the MetaMatrix Server");
+ runtimeMMServer.add(transactions);
// --------------------------------------------------------------------------------
// setup Configuration header node
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/layout/WorkspaceController.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/layout/WorkspaceController.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/layout/WorkspaceController.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -45,6 +45,7 @@
import com.metamatrix.console.models.ModelManager;
import com.metamatrix.console.models.ResourceManager;
import com.metamatrix.console.models.ServerLogManager;
+import com.metamatrix.console.models.TransactionManager;
import com.metamatrix.console.notification.RuntimeUpdateNotification;
import com.metamatrix.console.security.UserCapabilities;
import com.metamatrix.console.ui.NotifyOnExitConsole;
@@ -63,6 +64,7 @@
import com.metamatrix.console.ui.views.sessions.SessionPanel;
import com.metamatrix.console.ui.views.summary.SummaryPanel;
import com.metamatrix.console.ui.views.syslog.SysLogPanel;
+import com.metamatrix.console.ui.views.transactions.TransactionsPanel;
import com.metamatrix.console.ui.views.users.AdminRolesMain;
import com.metamatrix.console.ui.views.vdb.VdbMainPanel;
import com.metamatrix.console.util.AutoRefreshable;
@@ -364,6 +366,8 @@
panel = createSystemLogSetupPanel(connection);
} else if (cls == ResourcesMainPanel.class) {
panel = createResourcesPanel(connection);
+ } else if (cls == TransactionsPanel.class) {
+ panel = createTransactionsPanel(connection);
}
if (panel instanceof AutoRefreshable) {
addToAutoRefreshableXref(panel);
@@ -489,6 +493,17 @@
}
return entPanel;
}
+
+ private TransactionsPanel createTransactionsPanel(ConnectionInfo connection) {
+ try {
+ UserCapabilities cap = UserCapabilities.getInstance();
+ boolean canModify = cap.isProductAdmin(connection);
+ return new TransactionsPanel(new TransactionManager(connection), canModify, connection);
+ } catch (Exception ex) {
+ ExceptionUtility.showMessage("Create Transactions panel", ex); //$NON-NLS-1$
+ }
+ return null;
+ }
private WorkspacePanel createResourcesPanel(ConnectionInfo connection) {
ResourcesMainPanel rp = null;
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/transactions/TransactionTableModel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/transactions/TransactionTableModel.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/transactions/TransactionTableModel.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -22,49 +22,42 @@
package com.metamatrix.console.ui.views.transactions;
-import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
-import java.util.HashMap;
import java.util.Iterator;
-import java.util.Map;
-import com.metamatrix.common.xa.TransactionID;
-import com.metamatrix.console.util.StaticUtilities;
+import com.metamatrix.admin.api.objects.Transaction;
+import com.metamatrix.common.xa.MMXid;
import com.metamatrix.toolbox.ui.widget.table.DefaultTableModel;
/**
* Extension to DefaultSortableTableModel to model the Transactions tab table.
*/
public class TransactionTableModel extends DefaultTableModel {
+
+ public static final int TXN_ID_INDEX = 0;
+ public static final int SESSION_ID_INDEX = 1;
+ public static final int XID_INDEX = 3;
//
// Static column information
//
- public final static int NUM_COLUMNS = 9;
- public final static int TRANSACTION_ID_COL = 0;
- public final static int SESSION_ID_COL = 1;
- public final static int STATUS_COL = 2;
- public final static int START_TIME_COL = 3;
- public final static int END_TIME_COL = 4;
- public final static int CONNECTOR_ID_COL = 5;
- public final static int PROCESSOR_ID_COL = 6;
- public final static int DATABASE_COL = 7;
- public final static int REQUEST_ID_COL = 8;
- public final static String TRANSACTION_ID_HDR = "Transaction ID";
- public final static String SESSION_ID_HDR = "Session ID";
- public final static String STATUS_HDR = "Status";
- public final static String START_TIME_HDR = "Start Time";
- public final static String END_TIME_HDR = "End Time";
- public final static String CONNECTOR_ID_HDR = "Connector ID";
- public final static String PROCESSOR_ID_HDR = "Processor ID";
- public final static String DATABASE_HDR = "Model";
- public final static String REQUEST_ID_HDR = "Request ID";
-
- private Map /*<Long (transaction num.) to TransactionID>*/ transMap;
- //Transaction-number-to-transaction-ID map of the model's current
- //contents. This map is accurate only if the model is populated
- //exclusively through use of the resetFromTransactionsList() method.
- private String[] colHdrs;
-
+ public final static Class<?>[] COLUMN_CLASS = new Class[]{
+ String.class,
+ String.class,
+ String.class,
+ Object.class,
+ String.class,
+ Date.class
+
+ };
+ public final static String[] COLUMN_HEADERS = new String[]{
+ "Transaction ID",
+ "Session ID",
+ "Scope",
+ "Xid",
+ "Status",
+ "Start Time",
+ };
+
//
// Constructors
//
@@ -72,17 +65,7 @@
super();
// Set columns for model
- colHdrs = new String[NUM_COLUMNS];
- colHdrs[TRANSACTION_ID_COL] = TRANSACTION_ID_HDR;
- colHdrs[SESSION_ID_COL] = SESSION_ID_HDR;
- colHdrs[STATUS_COL] = STATUS_HDR;
- colHdrs[START_TIME_COL] = START_TIME_HDR;
- colHdrs[END_TIME_COL] = END_TIME_HDR;
- colHdrs[CONNECTOR_ID_COL] = CONNECTOR_ID_HDR;
- colHdrs[PROCESSOR_ID_COL] = PROCESSOR_ID_HDR;
- colHdrs[DATABASE_COL] = DATABASE_HDR;
- colHdrs[REQUEST_ID_COL] = REQUEST_ID_HDR;
- super.setColumnIdentifiers(colHdrs);
+ super.setColumnIdentifiers(COLUMN_HEADERS);
// Set to 0 rows
super.setNumRows(0);
@@ -92,18 +75,7 @@
// Overridden methods
//
public Class getColumnClass(int columnIndex) {
- // Return appropriate column class based on the column index
- Class cls;
- if ((columnIndex == SESSION_ID_COL) || (columnIndex == PROCESSOR_ID_COL)
- || (columnIndex == REQUEST_ID_COL) || (columnIndex ==
- TRANSACTION_ID_COL)) {
- cls = Long.class;
- } else if ((columnIndex == START_TIME_COL) || (columnIndex == END_TIME_COL)) {
- cls = Date.class;
- } else {
- cls = String.class;
- }
- return cls;
+ return COLUMN_CLASS[columnIndex];
}
//
@@ -113,70 +85,28 @@
* Method to repopulate the table model based on a Collection of
* ServerTransaction objects.
*/
- public void resetFromTransactionsList(Collection /*<ServerTransaction>*/ tx) {
- transMap = new HashMap();
- int numRows = tx.size();
- String NA = "N/A"; //$NON-NLS-1$
+ public void resetFromTransactionsList(Collection<Transaction> txs) {
+ int numRows = txs.size();
// This panel needs to be removed, any transaction information provided
// should be on the queries panel.
//Store list's contents in a matrix-- one row per transaction.
- SimpleDateFormat formatter = StaticUtilities.getDefaultDateFormat();
- Object[][] data = new Object[numRows][NUM_COLUMNS];
- Iterator it = tx.iterator();
+ Object[][] data = new Object[numRows][COLUMN_HEADERS.length];
+ Iterator<Transaction> it = txs.iterator();
for (int row = 0; it.hasNext(); row++) {
-
- //getDisplayString() for TransactionID is guaranteed to return a
- //numeric string.
- data[row][TRANSACTION_ID_COL] = 0L;
- transMap.put(data[row][TRANSACTION_ID_COL], NA);
- data[row][SESSION_ID_COL] = NA;
- data[row][STATUS_COL] = NA;
-
- //Form new Date objects for begin and end time, rather than using
- //the objects returned by ServerTransaction. This is so we can
- //ensure that we have objects whose toString() method displays both
- //date and time. toString() for java.sql.Date displays date only.
- Date beginTime = new Date();
- if (beginTime == null) {
- data[row][START_TIME_COL] = null;
- } else {
- data[row][START_TIME_COL] = formatter.format(new Date(beginTime.getTime()));
- }
- Date endTime = new Date();
- if (endTime == null) {
- data[row][END_TIME_COL] = null;
- } else {
- data[row][END_TIME_COL] = formatter.format(new Date(endTime.getTime()));
- }
- data[row][CONNECTOR_ID_COL] = null;
- data[row][PROCESSOR_ID_COL] = null;
- data[row][DATABASE_COL] = NA;
-// if (st.getRequestID() == null) {
-// data[row][REQUEST_ID_COL] = null;
-// } else {
- data[row][REQUEST_ID_COL] = new Long(0);
-// }
+ Transaction txn = it.next();
+ data[row][0] = txn.getIdentifier();
+ data[row][1] = txn.getAssociatedSession();
+ data[row][2] = txn.getScope();
+ data[row][3] = txn.getXid() != null?new MMXid(txn.getXid()):null;
+ data[row][4] = txn.getStatus();
+ data[row][5] = txn.getCreated();
}
//Set model's data to this matrix.
- this.setNumRows(0);
- this.setDataVector(data, colHdrs);
+ this.setRowCount(numRows);
+ this.setDataVector(data, COLUMN_HEADERS);
+ this.setEditable(false);
}
- /**
- * Method to return a TransactionID contained within the model, given its
- * transaction number. This method is accurate only if the model has been
- * populated exclusively through use of the resetFromTransactionsList()
- * method.
- */
- public TransactionID transactionIDForTransactionNum(Long transactionNum) {
- //transMap is a transaction-number-to-transaction-ID map for the model's
- //current contents. See if it contains the given transaction number.
- TransactionID id = null;
- if (transMap != null) {
- id = (TransactionID)transMap.get(transactionNum);
- }
- return id;
- }
}
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/transactions/TransactionsPanel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/transactions/TransactionsPanel.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/transactions/TransactionsPanel.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -22,22 +22,39 @@
package com.metamatrix.console.ui.views.transactions;
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
import java.util.ArrayList;
-import javax.swing.*;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
+import javax.swing.SwingUtilities;
+import javax.transaction.xa.Xid;
import com.metamatrix.console.connections.ConnectionInfo;
-import com.metamatrix.console.models.*;
+import com.metamatrix.console.models.ManagerListener;
+import com.metamatrix.console.models.ModelChangedEvent;
+import com.metamatrix.console.models.TransactionManager;
import com.metamatrix.console.notification.RuntimeUpdateNotification;
-import com.metamatrix.console.ui.layout.*;
+import com.metamatrix.console.ui.layout.BasePanel;
+import com.metamatrix.console.ui.layout.ConsoleMenuBar;
+import com.metamatrix.console.ui.layout.MenuEntry;
+import com.metamatrix.console.ui.layout.WorkspacePanel;
import com.metamatrix.console.ui.util.AbstractPanelAction;
-import com.metamatrix.console.util.*;
-import com.metamatrix.server.admin.api.TransactionAdminAPI;
+import com.metamatrix.console.util.AutoRefreshable;
+import com.metamatrix.console.util.AutoRefresher;
+import com.metamatrix.console.util.DialogUtility;
+import com.metamatrix.console.util.ExceptionUtility;
+import com.metamatrix.console.util.StaticProperties;
+import com.metamatrix.console.util.StaticUtilities;
import com.metamatrix.toolbox.ui.widget.TableWidget;
import com.metamatrix.toolbox.ui.widget.table.DefaultTableColumnModel;
-import com.metamatrix.common.xa.XATransactionException;
public class TransactionsPanel extends BasePanel
implements ManagerListener,
@@ -74,10 +91,7 @@
new Insets(5, 5, 5, 5), 0, 0));
if (canTerminateTransactions) {
table.addMouseListener(new MouseAdapter() {
- //public void mousePressed(MouseEvent ev) {
- // checkMouseClick(ev);
- //}
- public void mouseReleased(MouseEvent ev) {
+ public void mousePressed(MouseEvent ev) {
checkMouseClick(ev);
}
});
@@ -91,23 +105,39 @@
}
private void checkMouseClick(MouseEvent ev) {
- if (ev.isPopupTrigger()) {
- int[] selectedRows = table.getSelectedRows();
- if (selectedRows.length == 1) {
- int row = selectedRows[0];
- //Was the mouse click over the selected row?
- int clickRow = table.rowAtPoint(ev.getPoint());
- if (row == clickRow) {
- //Yes. Put up popup menu with single action of terminate transaction
- Long transactionNum = (Long)table.getModel().getValueAt(row,
- TransactionTableModel.TRANSACTION_ID_COL);
- JPopupMenu popupMenu = new JPopupMenu();
- Action terminateAction = new TerminateAction(transactionNum, this);
- popupMenu.add(terminateAction);
- popupMenu.show(table, ev.getX() + 10, ev.getY());
- }
- }
+ if (!SwingUtilities.isRightMouseButton(ev)) {
+ return;
}
+ int[] selectedRows = table.getSelectedRows();
+ if (selectedRows.length != 1) {
+ return;
+ }
+ int row = selectedRows[0];
+ //Was the mouse click over the selected row?
+ int clickRow = table.rowAtPoint(ev.getPoint());
+ if (row != clickRow) {
+ return;
+ }
+ //Yes. Put up popup menu with single action of terminate transaction
+ final String transactionNum = (String)table.getModel().getValueAt(row, TransactionTableModel.TXN_ID_INDEX);
+ final String sessionId = (String)table.getModel().getValueAt(row, TransactionTableModel.SESSION_ID_INDEX);
+ final Xid xid = (Xid)table.getModel().getValueAt(row, TransactionTableModel.XID_INDEX);
+
+ JPopupMenu popupMenu = new JPopupMenu();
+ Action terminateAction = new AbstractAction("Terminate transaction") {
+
+ public void actionPerformed(ActionEvent ev) {
+ boolean confirmed = DialogUtility.yesNoDialog(null,
+ "Terminate transaction " + transactionNum.toString() + "?",
+ "Confirm Termination");
+ if (confirmed) {
+ doTermination(transactionNum, sessionId, xid);
+ }
+ }
+ };
+
+ popupMenu.add(terminateAction);
+ popupMenu.show(table, ev.getX() + 10, ev.getY());
}
public void start() {
@@ -121,6 +151,7 @@
}
public java.util.List /*<Action>*/ resume() {
+ refresh();
AbstractPanelAction refreshAction = new AbstractPanelAction(0){
public void actionImpl(final ActionEvent e){
TransactionsPanel.this.refresh();
@@ -181,15 +212,13 @@
}
}
- public void doTermination(Long transactionNum) {
+ public void doTermination(String transactionNum, String sessionId, Xid xid) {
try {
- TransactionAdminAPI api = ModelManager.getTransactionAPI(connection);
- api.terminateTransaction(manager.transactionIDForTransactionNum(transactionNum));
- } catch (XATransactionException ex) {
- StaticUtilities.displayModalDialogWithOK("Not Terminated",
- "Transaction " + transactionNum +
- " was not terminated. The transaction may have already " +
- "completed.");
+ if (xid != null) {
+ getConnection().getServerAdmin().terminateTransaction(xid);
+ } else {
+ getConnection().getServerAdmin().terminateTransaction(transactionNum, sessionId);
+ }
} catch (Exception e) {
ExceptionUtility.showMessage("Terminate Transaction", e);
}
@@ -242,22 +271,3 @@
}//end TransactionsPanel
-class TerminateAction extends AbstractAction {
- private Long transactionNum;
- private TransactionsPanel panel;
-
- public TerminateAction(Long trans, TransactionsPanel pnl) {
- super("Terminate transaction");
- transactionNum = trans;
- panel = pnl;
- }
-
- public void actionPerformed(ActionEvent ev) {
- boolean confirmed = DialogUtility.yesNoDialog(null,
- "Terminate transaction " + transactionNum.toString() + "?",
- "Confirm Termination");
- if (confirmed) {
- panel.doTermination(transactionNum);
- }
- }
-}//end TerminateAction
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -65,6 +65,7 @@
import com.metamatrix.dqp.service.ConfigurationService;
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.service.DataService;
+import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.dqp.service.VDBService;
import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
import com.metamatrix.platform.util.ProductInfoConstants;
@@ -146,6 +147,10 @@
return (DataService)getManager().findService(DQPServiceNames.DATA_SERVICE);
}
+ TransactionService getTransactionService() {
+ return (TransactionService)getManager().findService(DQPServiceNames.TRANSACTION_SERVICE);
+ }
+
ConfigurationService getConfigurationService() {
return (ConfigurationService)getManager().findService(DQPServiceNames.CONFIGURATION_SERVICE);
}
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -39,12 +39,14 @@
import com.metamatrix.admin.api.objects.AdminObject;
import com.metamatrix.admin.api.objects.ConnectorBinding;
import com.metamatrix.admin.api.objects.SystemObject;
+import com.metamatrix.admin.api.objects.Transaction;
import com.metamatrix.admin.objects.MMAdminObject;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.comm.api.ServerConnection;
import com.metamatrix.common.config.api.ComponentType;
import com.metamatrix.common.vdb.api.VDBArchive;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
import com.metamatrix.server.serverapi.RequestInfo;
@@ -355,8 +357,14 @@
}
}
+ @Override
+ public Collection<Transaction> getTransactions()
+ throws AdminException {
+ TransactionService ts = getTransactionService();
+ if (ts == null) {
+ return Collections.emptyList();
+ }
+ return ts.getTransactions();
+ }
-
-
-
}
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -28,6 +28,8 @@
import java.util.Iterator;
import java.util.Set;
+import javax.transaction.xa.Xid;
+
import com.metamatrix.admin.api.embedded.EmbeddedLogger;
import com.metamatrix.admin.api.embedded.EmbeddedRuntimeStateAdmin;
import com.metamatrix.admin.api.exception.AdminComponentException;
@@ -44,6 +46,7 @@
import com.metamatrix.common.log.LogManager;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
@@ -326,4 +329,22 @@
throw new AdminProcessingException("Admin_invalid_log_listener"); //$NON-NLS-1$
}
}
+
+ @Override
+ public void terminateTransaction(String transactionId, String sessionId)
+ throws AdminException {
+ TransactionService ts = getTransactionService();
+ if (ts != null) {
+ ts.terminateTransaction(transactionId, sessionId);
+ }
+ }
+
+ @Override
+ public void terminateTransaction(Xid transactionId) throws AdminException {
+ TransactionService ts = getTransactionService();
+ if (ts != null) {
+ ts.terminateTransaction(transactionId);
+ }
+ }
+
}
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTransactionService.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTransactionService.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTransactionService.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -26,71 +26,28 @@
import org.teiid.dqp.internal.transaction.TransactionServerImpl;
-import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogCommonConstants;
import com.metamatrix.common.xa.XATransactionException;
-import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.transaction.TransactionServer;
-import com.metamatrix.dqp.transaction.XAServer;
import com.metamatrix.xa.arjuna.ArjunaTransactionProvider;
-public class EmbeddedTransactionService extends EmbeddedBaseDQPService implements TransactionService {
+public class EmbeddedTransactionService extends TransactionServerImpl {
public static final String TRANSACTIONS_ENABLED = "metamatrix.xatxnmgr.enabled"; //$NON-NLS-1$
- private TransactionServerImpl arjunaTs = new TransactionServerImpl();
- private TransactionServer ts;
- /**
- * @param props
- * @throws ApplicationInitializationException
- */
- public void initializeService(Properties props) throws ApplicationInitializationException {
+ @Override
+ public void initialize(Properties props)
+ throws ApplicationInitializationException {
try {
props = new Properties(props);
props.put(TransactionService.HOSTNAME, "dqp"); //$NON-NLS-1$
props.put(TransactionService.VMNAME, props.getProperty(DQPEmbeddedProperties.DQP_IDENTITY));
- arjunaTs.init(ArjunaTransactionProvider.getInstance(props));
-
- final Class[] interfaces = new Class[] {TransactionServer.class, XAServer.class};
-
- ts = (TransactionServer)LogManager.createLoggingProxy(LogCommonConstants.CTX_XA_TXN, arjunaTs, interfaces, MessageLevel.DETAIL);
+ this.setTransactionProvider(ArjunaTransactionProvider.getInstance(props));
} catch (XATransactionException e) {
throw new ApplicationInitializationException(e);
}
}
-
- /*
- * @see com.metamatrix.common.application.ApplicationService#start(com.metamatrix.common.application.ApplicationEnvironment)
- */
- public void startService(ApplicationEnvironment environment) throws ApplicationLifecycleException {
-
- }
-
- /*
- * @see com.metamatrix.common.application.ApplicationService#stop()
- */
- public void stopService() throws ApplicationLifecycleException {
- arjunaTs.shutdown(true);
- }
-
- /**
- * @see com.metamatrix.dqp.service.TransactionService#getTransactionServer()
- */
- public TransactionServer getTransactionServer() {
- return ts;
- }
-
- /**
- * @see com.metamatrix.dqp.service.TransactionService#getXAServer()
- */
- public XAServer getXAServer() {
- return (XAServer)ts;
- }
}
Modified: trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnection.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnection.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnection.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -23,7 +23,6 @@
package com.metamatrix.jdbc;
import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.sql.SQLException;
@@ -31,10 +30,9 @@
import com.metamatrix.admin.api.core.Admin;
import com.metamatrix.admin.api.embedded.EmbeddedAdmin;
-import com.metamatrix.admin.api.exception.AdminComponentException;
-import com.metamatrix.admin.api.exception.AdminException;
import com.metamatrix.admin.api.exception.AdminProcessingException;
import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.core.util.MixinProxy;
import com.metamatrix.dqp.embedded.admin.DQPConfigAdminImpl;
import com.metamatrix.dqp.embedded.admin.DQPMonitoringAdminImpl;
import com.metamatrix.dqp.embedded.admin.DQPRuntimeStateAdminImpl;
@@ -80,17 +78,14 @@
*/
public Admin getAdminAPI() throws SQLException {
- InvocationHandler handler = new InvocationHandler() {
- Object[] implementors = {
- new DQPConfigAdminImpl(manager),
- new DQPMonitoringAdminImpl(manager),
- new DQPRuntimeStateAdminImpl(manager),
- new DQPSecurityAdminImpl(manager)
- };
+ InvocationHandler handler = new MixinProxy(new Object[] {
+ new DQPConfigAdminImpl(manager),
+ new DQPMonitoringAdminImpl(manager),
+ new DQPRuntimeStateAdminImpl(manager),
+ new DQPSecurityAdminImpl(manager)
+ }) {
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- Exception ex = null;
-
// We we perform any DQP functions check if the DQP is still alive
if (!manager.isAlive()) {
throw new AdminProcessingException(JDBCPlugin.Util.getString("EmbeddedConnection.DQP_shutDown")); //$NON-NLS-1$
@@ -105,28 +100,7 @@
try {
// Set the class loader to current class classloader so that the this classe's class loader gets used
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
-
- for (int i = 0; i < implementors.length; i++) {
- try {
- return method.invoke(implementors[i], args);
- } catch (IllegalArgumentException e) {
- ex = e; // try all classes
- } catch (IllegalAccessException e) {
- throw e;
- } catch (InvocationTargetException e) {
- // Since we know all the admin methods throw the Admin Exceptions
- // no need to wrap with undeclared exception.
- Throwable target = e.getTargetException();
- if (target instanceof AdminException) {
- throw target;
- }
- throw new AdminComponentException(e);
- }
- }
- if (ex != null) {
- throw ex;
- }
- return null;
+ return super.invoke(proxy, method, args);
}
finally {
Thread.currentThread().setContextClassLoader(callingClassLoader);
Modified: trunk/engine/src/main/java/com/metamatrix/common/application/Application.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/application/Application.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/engine/src/main/java/com/metamatrix/common/application/Application.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -32,6 +32,7 @@
import com.metamatrix.common.application.exception.ApplicationInitializationException;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.util.LogConstants;
@@ -59,6 +60,10 @@
LogManager.logWarning(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPLauncher.InstallService_ServiceIsNull", serviceName)); //$NON-NLS-1$
}else{
ApplicationService appService = injector.getInstance(type);
+ String loggingContext = DQPServiceNames.SERVICE_LOGGING_CONTEXT[i];
+ if (loggingContext != null) {
+ appService = (ApplicationService)LogManager.createLoggingProxy(loggingContext, appService, new Class[] {type}, MessageLevel.DETAIL);
+ }
appService.initialize(configSource.getProperties());
installService(serviceName, appService);
LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPLauncher.InstallService_ServiceInstalled", serviceName)); //$NON-NLS-1$
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/DQPServiceNames.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/DQPServiceNames.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/DQPServiceNames.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -22,7 +22,9 @@
package com.metamatrix.dqp.service;
+import com.metamatrix.common.util.LogCommonConstants;
+
/**
* Defines constants used for naming DQP services.
*/
@@ -78,4 +80,15 @@
MetadataService.class,
DataService.class,
};
+
+ public static final String[] SERVICE_LOGGING_CONTEXT = new String[] {
+ null,
+ null,
+ null,
+ null,
+ LogCommonConstants.CTX_TXN_LOG,
+ null,
+ null,
+ null,
+ };
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -24,9 +24,21 @@
*/
package com.metamatrix.dqp.service;
+import java.util.Collection;
+
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.SystemException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import org.teiid.connector.xa.api.TransactionContext;
+import org.teiid.dqp.internal.transaction.TransactionProvider.XAConnectionSource;
+
+import com.metamatrix.admin.api.exception.AdminException;
+import com.metamatrix.admin.api.objects.Transaction;
import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.dqp.transaction.TransactionServer;
-import com.metamatrix.dqp.transaction.XAServer;
+import com.metamatrix.common.xa.MMXid;
+import com.metamatrix.common.xa.XATransactionException;
/**
*/
@@ -52,7 +64,65 @@
public static final String DEFAULT_TXN_STORE_DIR = System.getProperty("metamatrix.xatxnmgr.txnstore_dir", System.getProperty("user.dir")); //$NON-NLS-1$ //$NON-NLS-2$
public static final String DEFAULT_TXN_STATUS_PORT = "0"; //$NON-NLS-1$
- TransactionServer getTransactionServer();
+ // processor level methods
+ TransactionContext start(TransactionContext context) throws XATransactionException, SystemException;
+
+ TransactionContext commit(TransactionContext context) throws XATransactionException, SystemException;
+
+ TransactionContext rollback(TransactionContext context) throws XATransactionException, SystemException;
+
+ TransactionContext getOrCreateTransactionContext(String threadId);
+
+ // local transaction
+ TransactionContext begin(String threadId) throws XATransactionException, SystemException;
+
+ void commit(String threadId) throws XATransactionException, SystemException;
+
+ void rollback(String threadId) throws XATransactionException, SystemException;
+
+ // connector worker
+ TransactionContext delist(TransactionContext context,
+ XAResource resource,
+ int flags) throws XATransactionException;
+
+ TransactionContext enlist(TransactionContext context,
+ XAResource resource) throws XATransactionException;
- XAServer getXAServer();
+ void cancelTransactions(String threadId, boolean requestOnly) throws InvalidTransactionException, SystemException;
+
+
+ // recovery
+ void registerRecoverySource(String name, XAConnectionSource resource);
+
+ void removeRecoverySource(String name);
+
+ int prepare(final String threadId,
+ MMXid xid) throws XATransactionException;
+
+ void commit(final String threadId,
+ MMXid xid,
+ boolean onePhase) throws XATransactionException;
+
+ void rollback(final String threadId,
+ MMXid xid) throws XATransactionException;
+
+ Xid[] recover(int flag) throws XATransactionException;
+
+ void forget(final String threadId,
+ MMXid xid) throws XATransactionException;
+
+ void start(final String threadId,
+ MMXid xid,
+ int flags,
+ int timeout) throws XATransactionException;
+
+ void end(final String threadId,
+ MMXid xid,
+ int flags) throws XATransactionException;
+
+ Collection<Transaction> getTransactions();
+
+ void terminateTransaction(Xid transactionId) throws AdminException;
+
+ void terminateTransaction(String transactionId, String sessionId) throws AdminException;
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -83,7 +83,6 @@
import com.metamatrix.dqp.service.TrackingService;
import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.dqp.spi.TrackerLogConstants;
-import com.metamatrix.dqp.transaction.TransactionServer;
import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
@@ -398,7 +397,7 @@
if (this.isXa) {
if (this.connector.supportsSingleIdentity()) {
// add this connector as the recovery source
- TransactionServer ts = this.getTransactionService().getTransactionServer();
+ TransactionService ts = this.getTransactionService();
ts.registerRecoverySource(connectorName, new TransactionProvider.XAConnectionSource() {
XAConnection conn = null;
@@ -501,7 +500,7 @@
if(this.isXa){
if (this.getTransactionService() != null) {
- TransactionServer ts = this.getTransactionService().getTransactionServer();
+ TransactionService ts = this.getTransactionService();
ts.removeRecoverySource(connectorName);
}
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -38,7 +38,7 @@
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
-import com.metamatrix.dqp.transaction.TransactionServer;
+import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.dqp.util.LogConstants;
public class SynchConnectorWorkItem extends ConnectorWorkItem {
@@ -167,8 +167,8 @@
this.lock = null;
}
- private TransactionServer getTransactionServer() {
- return manager.getTransactionService().getTransactionServer();
+ private TransactionService getTransactionServer() {
+ return manager.getTransactionService();
}
@Override
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -57,6 +57,7 @@
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.common.xa.MMXid;
import com.metamatrix.common.xa.XATransactionException;
+import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.LRUCache;
import com.metamatrix.dqp.DQPPlugin;
@@ -422,7 +423,7 @@
if (transactionService != null) {
try {
- transactionService.getTransactionServer().cancelTransactions(sessionId, false);
+ transactionService.cancelTransactions(sessionId, false);
} catch (InvalidTransactionException err) {
LogManager.logWarning(LogConstants.CTX_DQP, "rollback failed for requestID=" + sessionId); //$NON-NLS-1$
} catch (SystemException err) {
@@ -543,9 +544,16 @@
return tracker;
}
- TransactionService getTransactionService() {
+ public TransactionService getTransactionService() {
+ if (transactionService == null) {
+ throw new MetaMatrixRuntimeException("Transactions are not enabled"); //$NON-NLS-1$
+ }
return transactionService;
}
+
+ public TransactionService getTransactionServiceDirect() {
+ return transactionService;
+ }
ResultSetCache getRsCache() {
return rsCache;
@@ -645,7 +653,7 @@
public void begin() throws XATransactionException {
String threadId = DQPWorkContext.getWorkContext().getConnectionID();
try {
- this.transactionService.getTransactionServer().begin(threadId);
+ this.getTransactionService().begin(threadId);
} catch (SystemException e) {
throw new XATransactionException(e);
}
@@ -654,7 +662,7 @@
public void commit() throws XATransactionException {
String threadId = DQPWorkContext.getWorkContext().getConnectionID();
try {
- this.transactionService.getTransactionServer().commit(threadId);
+ this.getTransactionService().commit(threadId);
} catch (SystemException e) {
throw new XATransactionException(e);
}
@@ -662,7 +670,7 @@
public void rollback() throws XATransactionException {
try {
- this.transactionService.getTransactionServer().rollback(
+ this.getTransactionService().rollback(
DQPWorkContext.getWorkContext().getConnectionID());
} catch (SystemException e) {
throw new XATransactionException(e);
@@ -672,31 +680,31 @@
public void commit(MMXid xid, boolean onePhase)
throws XATransactionException {
String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- this.transactionService.getXAServer().commit(threadId, xid, onePhase);
+ this.getTransactionService().commit(threadId, xid, onePhase);
}
public void end(MMXid xid, int flags) throws XATransactionException {
String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- this.transactionService.getXAServer().end(threadId, xid, flags);
+ this.getTransactionService().end(threadId, xid, flags);
}
public void forget(MMXid xid) throws XATransactionException {
String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- this.transactionService.getXAServer().forget(threadId, xid);
+ this.getTransactionService().forget(threadId, xid);
}
public int prepare(MMXid xid) throws XATransactionException {
- return this.transactionService.getXAServer().prepare(
+ return this.getTransactionService().prepare(
DQPWorkContext.getWorkContext().getConnectionID(),
xid);
}
public Xid[] recover(int flag) throws XATransactionException {
- return this.transactionService.getXAServer().recover(flag);
+ return this.getTransactionService().recover(flag);
}
public void rollback(MMXid xid) throws XATransactionException {
- this.transactionService.getXAServer().rollback(
+ this.getTransactionService().rollback(
DQPWorkContext.getWorkContext().getConnectionID(),
xid);
}
@@ -704,7 +712,7 @@
public void start(MMXid xid, int flags, int timeout)
throws XATransactionException {
String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- this.transactionService.getXAServer().start(threadId, xid, flags, timeout);
+ this.getTransactionService().start(threadId, xid, flags, timeout);
}
public MetadataResult getMetadata(long requestID)
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -434,11 +434,11 @@
TransactionContext tc = null;
if (transactionService != null) {
- tc = transactionService.getTransactionServer().getOrCreateTransactionContext(workContext.getConnectionID());
+ tc = transactionService.getOrCreateTransactionContext(workContext.getConnectionID());
}
if (tc != null){
- Assertion.assertTrue(tc.getTransactionType() != TransactionContext.Scope.TRANSACTION_REQUEST, "Transaction already associated with request."); //$NON-NLS-1$
+ Assertion.assertTrue(tc.getTransactionType() != TransactionContext.Scope.REQUEST, "Transaction already associated with request."); //$NON-NLS-1$
}
if (tc == null || !tc.isInTransaction()) {
@@ -467,7 +467,7 @@
throw new MetaMatrixComponentException(DQPPlugin.Util.getString("Request.transaction_not_supported")); //$NON-NLS-1$
}
try {
- tc = transactionService.getTransactionServer().start(tc);
+ tc = transactionService.start(tc);
} catch (XATransactionException err) {
throw new MetaMatrixComponentException(err);
} catch (SystemException err) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -175,7 +175,7 @@
if (this.rsCache != null) {
this.cid = ResultSetCacheUtil.createCacheID(requestMsg, rsCache);
}
- this.transactionService = dqpCore.getTransactionService();
+ this.transactionService = dqpCore.getTransactionServiceDirect();
this.dqpCore = dqpCore;
this.request = request;
this.resultsReceiver = receiver;
@@ -283,8 +283,8 @@
this.transactionState = TransactionState.END;
}
}
- if (this.transactionState == TransactionState.END && transactionContext.getTransactionType() == TransactionContext.Scope.TRANSACTION_REQUEST) {
- this.transactionService.getTransactionServer().commit(transactionContext);
+ if (this.transactionState == TransactionState.END && transactionContext.getTransactionType() == TransactionContext.Scope.REQUEST) {
+ this.transactionService.commit(transactionContext);
this.transactionState = TransactionState.DONE;
}
sendResultsIfNeeded(null);
@@ -343,10 +343,10 @@
this.transactionState = TransactionState.END;
}
- if (this.transactionState == TransactionState.END && transactionContext.getTransactionType() == TransactionContext.Scope.TRANSACTION_REQUEST) {
+ if (this.transactionState == TransactionState.END && transactionContext.getTransactionType() == TransactionContext.Scope.REQUEST) {
this.transactionState = TransactionState.DONE;
try {
- this.transactionService.getTransactionServer().rollback(transactionContext);
+ this.transactionService.rollback(transactionContext);
} catch (XATransactionException e1) {
LogManager.logWarning(LogConstants.CTX_DQP, e1, DQPPlugin.Util.getString("ProcessWorker.failed_rollback")); //$NON-NLS-1$
} catch (SystemException err) {
@@ -590,7 +590,7 @@
try {
if (transactionService != null) {
try {
- transactionService.getTransactionServer().cancelTransactions(requestID.getConnectionID(), true);
+ transactionService.cancelTransactions(requestID.getConnectionID(), true);
} catch (InvalidTransactionException err) {
LogManager.logWarning(LogConstants.CTX_DQP, "rollback failed for requestID=" + requestID.getConnectionID()); //$NON-NLS-1$
} catch (SystemException err) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionContextImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionContextImpl.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionContextImpl.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -46,10 +46,11 @@
private MMXid xid;
private String txnID;
private Transaction transaction;
- private Scope transactionType = Scope.TRANSACTION_NONE;
- private Set suspendedBy = Collections.newSetFromMap(new ConcurrentHashMap());
+ private Scope transactionType = Scope.NONE;
+ private Set<String> suspendedBy = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
private int transactionTimeout = -1;
- private Set xaResources = Collections.newSetFromMap(new ConcurrentHashMap());
+ private Set<XAResource> xaResources = Collections.newSetFromMap(new ConcurrentHashMap<XAResource, Boolean>());
+ private long creationTime;
public TransactionContextImpl() {}
@@ -64,8 +65,13 @@
void setTransaction(Transaction transaction, String id) {
this.transaction = transaction;
this.txnID = id;
+ this.creationTime = System.currentTimeMillis();
}
-
+
+ long getCreationTime() {
+ return creationTime;
+ }
+
/**
* @return Returns the transaction.
*/
@@ -117,7 +123,7 @@
this.xid = xid;
}
- Set getSuspendedBy() {
+ Set<String> getSuspendedBy() {
return this.suspendedBy;
}
@@ -136,7 +142,7 @@
this.xaResources.add(resource);
}
- Set getXAResources() {
+ Set<XAResource> getXAResources() {
return xaResources;
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -22,15 +22,22 @@
package org.teiid.dqp.internal.transaction;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
-import java.util.Iterator;
+import java.util.IdentityHashMap;
import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.InvalidTransactionException;
import javax.transaction.NotSupportedException;
import javax.transaction.RollbackException;
+import javax.transaction.Status;
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
@@ -42,25 +49,31 @@
import org.teiid.connector.xa.api.TransactionContext;
import org.teiid.dqp.internal.transaction.TransactionProvider.XAConnectionSource;
+import com.metamatrix.admin.api.exception.AdminComponentException;
+import com.metamatrix.admin.api.exception.AdminException;
+import com.metamatrix.admin.api.exception.AdminProcessingException;
+import com.metamatrix.admin.objects.MMAdminObject;
+import com.metamatrix.admin.objects.TransactionImpl;
+import com.metamatrix.common.application.ApplicationEnvironment;
+import com.metamatrix.common.application.exception.ApplicationInitializationException;
+import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.xa.MMXid;
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.transaction.TransactionServer;
-import com.metamatrix.dqp.transaction.XAServer;
+import com.metamatrix.dqp.service.TransactionService;
-public class TransactionServerImpl implements
- TransactionServer, XAServer {
+public class TransactionServerImpl implements TransactionService {
private static class TransactionMapping {
// (connection -> transaction for global and local)
- private Map threadToTransactionContext = new HashMap();
+ private Map<String, TransactionContextImpl> threadToTransactionContext = new HashMap<String, TransactionContextImpl>();
// (MMXid -> global transactions keyed)
- private Map xidToTransactionContext = new HashMap();
-
+ private Map<MMXid, TransactionContextImpl> xidToTransactionContext = new HashMap<MMXid, TransactionContextImpl>();
+
public synchronized TransactionContextImpl getOrCreateTransactionContext(String threadId) {
- TransactionContextImpl tc = (TransactionContextImpl)threadToTransactionContext.get(threadId);
+ TransactionContextImpl tc = threadToTransactionContext.get(threadId);
if (tc == null) {
tc = new TransactionContextImpl();
@@ -72,15 +85,15 @@
}
public synchronized TransactionContextImpl getTransactionContext(String threadId) {
- return (TransactionContextImpl)threadToTransactionContext.get(threadId);
+ return threadToTransactionContext.get(threadId);
}
public synchronized TransactionContextImpl getTransactionContext(MMXid xid) {
- return (TransactionContextImpl)xidToTransactionContext.get(xid);
+ return xidToTransactionContext.get(xid);
}
public synchronized TransactionContextImpl removeTransactionContext(String threadId) {
- return (TransactionContextImpl)threadToTransactionContext.remove(threadId);
+ return threadToTransactionContext.remove(threadId);
}
public synchronized void removeTransactionContext(TransactionContextImpl tc) {
@@ -109,18 +122,19 @@
private TransactionMapping transactions = new TransactionMapping();
private TransactionProvider provider;
+ private String processName = "embedded"; //$NON-NLS-1$
public TransactionServerImpl() {
}
- public void init(TransactionProvider theProvider) throws XATransactionException {
+ public void setProcessName(String processName) {
+ this.processName = processName;
+ }
+
+ public void setTransactionProvider(TransactionProvider theProvider) {
this.provider = theProvider;
}
- public synchronized void shutdown(boolean force) {
- this.provider.shutdown();
- }
-
@SuppressWarnings("finally")
public int prepare(final String threadId,
MMXid xid) throws XATransactionException {
@@ -155,8 +169,7 @@
private void endAssociations(TransactionContextImpl impl) throws XATransactionException, SystemException {
Transaction tx = getTransactionManager().getTransaction();
Assertion.isNotNull(tx);
- for (Iterator i = impl.getXAResources().iterator(); i.hasNext();) {
- XAResource resource = (XAResource)i.next();
+ for (XAResource resource : impl.getXAResources()) {
if (!tx.delistResource(resource, XAResource.TMSUCCESS)) {
throw new XATransactionException(DQPPlugin.Util.getString("TransactionServer.failed_to_delist")); //$NON-NLS-1$
}
@@ -228,7 +241,7 @@
case XAResource.TMNOFLAGS: {
checkXAState(threadId, xid, false, false);
tc = transactions.getOrCreateTransactionContext(threadId);
- if (tc.getTransactionType() != TransactionContext.Scope.TRANSACTION_NONE) {
+ if (tc.getTransactionType() != TransactionContext.Scope.NONE) {
throw new XATransactionException(XAException.XAER_PROTO, DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
}
Transaction tx;
@@ -255,14 +268,14 @@
tc.setTransaction(tx, provider.getTransactionID(tx));
tc.setTransactionTimeout(timeout);
tc.setXid(xid);
- tc.setTransactionType(TransactionContext.Scope.TRANSACTION_GLOBAL);
+ tc.setTransactionType(TransactionContext.Scope.GLOBAL);
break;
}
case XAResource.TMJOIN:
case XAResource.TMRESUME: {
tc = checkXAState(threadId, xid, true, false);
TransactionContextImpl threadContext = transactions.getOrCreateTransactionContext(threadId);
- if (threadContext.getTransactionType() != TransactionContext.Scope.TRANSACTION_NONE) {
+ if (threadContext.getTransactionType() != TransactionContext.Scope.NONE) {
throw new XATransactionException(XAException.XAER_PROTO, DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
}
@@ -323,7 +336,7 @@
}
if (!threadBound) {
tc = transactions.getOrCreateTransactionContext(threadId);
- if (tc.getTransactionType() != TransactionContext.Scope.TRANSACTION_NONE) {
+ if (tc.getTransactionType() != TransactionContext.Scope.NONE) {
throw new XATransactionException(XAException.XAER_PROTO, DQPPlugin.Util.getString("TransactionServer.existing_transaction", new Object[] {xid, threadId})); //$NON-NLS-1$
}
}
@@ -350,8 +363,8 @@
final TransactionManager tm = getTransactionManager();
- if (tc.getTransactionType() != TransactionContext.Scope.TRANSACTION_NONE) {
- if (tc.getTransactionType() != TransactionContext.Scope.TRANSACTION_LOCAL) {
+ if (tc.getTransactionType() != TransactionContext.Scope.NONE) {
+ if (tc.getTransactionType() != TransactionContext.Scope.LOCAL) {
throw new NotSupportedException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
}
if (!transactionExpected) {
@@ -372,7 +385,7 @@
tm.begin();
Transaction tx = tm.suspend();
tc.setTransaction(tx, provider.getTransactionID(tx));
- tc.setTransactionType(TransactionContext.Scope.TRANSACTION_LOCAL);
+ tc.setTransactionType(TransactionContext.Scope.LOCAL);
return tc;
} catch (InvalidTransactionException err) {
throw new XATransactionException(err);
@@ -446,14 +459,14 @@
TransactionContextImpl tc = (TransactionContextImpl)context;
try {
- if (tc.getTransactionType() != TransactionContext.Scope.TRANSACTION_NONE) {
+ if (tc.getTransactionType() != TransactionContext.Scope.NONE) {
throw new XATransactionException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
}
tm.begin();
Transaction tx = tm.suspend();
tc.setTransaction(tx, provider.getTransactionID(tx));
- tc.setTransactionType(TransactionContext.Scope.TRANSACTION_REQUEST);
+ tc.setTransactionType(TransactionContext.Scope.REQUEST);
return tc;
} catch (NotSupportedException e) {
throw new XATransactionException(e);
@@ -461,13 +474,13 @@
}
public TransactionContext commit(TransactionContext context) throws XATransactionException, SystemException {
- Assertion.assertTrue(context.getTransactionType() == TransactionContext.Scope.TRANSACTION_REQUEST);
+ Assertion.assertTrue(context.getTransactionType() == TransactionContext.Scope.REQUEST);
TransactionContextImpl tc = (TransactionContextImpl)context;
//commit may be called multiple times by the processworker, if this is a subsequent call, then the current
//context will not be active
TransactionContextImpl currentContext = transactions.getTransactionContext(tc.getThreadId());
- if (currentContext == null || currentContext.getTransactionType() == TransactionContext.Scope.TRANSACTION_NONE) {
+ if (currentContext == null || currentContext.getTransactionType() == TransactionContext.Scope.NONE) {
return currentContext;
}
TransactionManager tm = getTransactionManager();
@@ -494,7 +507,7 @@
}
public TransactionContext rollback(TransactionContext context) throws XATransactionException, SystemException {
- Assertion.assertTrue(context.getTransactionType() == TransactionContext.Scope.TRANSACTION_REQUEST);
+ Assertion.assertTrue(context.getTransactionType() == TransactionContext.Scope.REQUEST);
TransactionManager tm = getTransactionManager();
try {
tm.resume(context.getTransaction());
@@ -584,24 +597,29 @@
public void cancelTransactions(String threadId, boolean requestOnly) throws InvalidTransactionException, SystemException {
TransactionContextImpl tc = transactions.getTransactionContext(threadId);
- if (tc == null || tc.getTransactionType() == TransactionContext.Scope.TRANSACTION_NONE) {
+ if (tc == null || tc.getTransactionType() == TransactionContext.Scope.NONE) {
return;
}
- if (requestOnly && tc.getTransactionType() != TransactionContext.Scope.TRANSACTION_REQUEST) {
+ if (requestOnly && tc.getTransactionType() != TransactionContext.Scope.REQUEST) {
return;
}
- TransactionManager tm = getTransactionManager();
+ cancelTransaction(tc);
+ }
+
+ private void cancelTransaction(TransactionContextImpl tc)
+ throws InvalidTransactionException, SystemException {
+ TransactionManager tm = getTransactionManager();
try {
tm.resume(tc.getTransaction());
tm.setRollbackOnly();
} finally {
tm.suspend();
- transactions.removeTransactionContext(tc);
+ //transactions.removeTransactionContext(tc);
}
- }
+ }
public synchronized void registerRecoverySource(String name, XAConnectionSource resource) {
this.provider.registerRecoverySource(name, resource);
@@ -609,6 +627,111 @@
public synchronized void removeRecoverySource(String name) {
this.provider.removeRecoverySource(name);
- }
+ }
+
+ @Override
+ public Collection<com.metamatrix.admin.api.objects.Transaction> getTransactions() {
+ Set<TransactionContextImpl> txnSet = Collections.newSetFromMap(new IdentityHashMap<TransactionContextImpl, Boolean>());
+ synchronized (this.transactions) {
+ txnSet.addAll(this.transactions.threadToTransactionContext.values());
+ txnSet.addAll(this.transactions.xidToTransactionContext.values());
+ }
+ Collection<com.metamatrix.admin.api.objects.Transaction> result = new ArrayList<com.metamatrix.admin.api.objects.Transaction>(txnSet.size());
+ for (TransactionContextImpl transactionContextImpl : txnSet) {
+ if (transactionContextImpl.getTxnID() == null) {
+ continue;
+ }
+ TransactionImpl txnImpl = new TransactionImpl(processName, transactionContextImpl.getTxnID());
+ txnImpl.setAssociatedSession(transactionContextImpl.getThreadId());
+ txnImpl.setCreated(new Date(transactionContextImpl.getCreationTime()));
+ txnImpl.setScope(transactionContextImpl.getTransactionType().toString());
+ try {
+ txnImpl.setStatus(getStatusString(transactionContextImpl.getTransaction().getStatus()));
+ } catch (SystemException e) {
+ txnImpl.setStatus(getStatusString(Status.STATUS_UNKNOWN));
+ }
+ txnImpl.setXid(transactionContextImpl.getXid());
+ result.add(txnImpl);
+ }
+ return result;
+ }
+
+ public static String getStatusString(int status) {
+ switch (status) {
+ case Status.STATUS_ACTIVE:
+ return "ACTIVE"; //$NON-NLS-1$
+ case Status.STATUS_COMMITTED:
+ return "COMMITTED"; //$NON-NLS-1$
+ case Status.STATUS_COMMITTING:
+ return "COMMITTING"; //$NON-NLS-1$
+ case Status.STATUS_MARKED_ROLLBACK:
+ return "MARKED_ROLLBACK"; //$NON-NLS-1$
+ case Status.STATUS_NO_TRANSACTION:
+ return "NO_TRANSACTION"; //$NON-NLS-1$
+ case Status.STATUS_PREPARED:
+ return "PREPARED"; //$NON-NLS-1$
+ case Status.STATUS_PREPARING:
+ return "PREPARING"; //$NON-NLS-1$
+ case Status.STATUS_ROLLEDBACK:
+ return "ROLLEDBACK"; //$NON-NLS-1$
+ case Status.STATUS_ROLLING_BACK:
+ return "ROLLING_BACK"; //$NON-NLS-1$
+ }
+ return "UNKNOWN"; //$NON-NLS-1$
+ }
+
+ @Override
+ public void terminateTransaction(Xid transactionId) throws AdminException {
+ if (transactionId == null) {
+ return;
+ }
+ TransactionContextImpl context = this.transactions.getTransactionContext(new MMXid(transactionId));
+ if (context != null) {
+ try {
+ cancelTransaction(context);
+ } catch (InvalidTransactionException e) {
+ throw new AdminProcessingException(e);
+ } catch (SystemException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+ }
+
+ @Override
+ public void terminateTransaction(String transactionId, String sessionId) throws AdminException {
+ if (transactionId == null) {
+ return;
+ }
+ String[] id = MMAdminObject.buildIdentifierArray(transactionId);
+ if (!this.processName.equalsIgnoreCase(id[0]) || id.length != 2) {
+ return;
+ }
+ TransactionContextImpl context = this.transactions.getTransactionContext(sessionId);
+ if (context != null && id[1].equalsIgnoreCase(context.getTxnID())) {
+ try {
+ cancelTransaction(context);
+ } catch (InvalidTransactionException e) {
+ throw new AdminProcessingException(e);
+ } catch (SystemException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+ }
+
+ @Override
+ public void initialize(Properties props)
+ throws ApplicationInitializationException {
+ }
+
+ @Override
+ public void start(ApplicationEnvironment environment)
+ throws ApplicationLifecycleException {
+
+ }
+
+ @Override
+ public synchronized void stop() throws ApplicationLifecycleException {
+ this.provider.shutdown();
+ }
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -22,49 +22,15 @@
package org.teiid.dqp.internal.datamgr.impl;
-import java.util.Properties;
-
import org.teiid.dqp.internal.transaction.TransactionProvider;
import org.teiid.dqp.internal.transaction.TransactionServerImpl;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.core.util.SimpleMock;
-import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.transaction.TransactionServer;
-import com.metamatrix.dqp.transaction.XAServer;
-public class FakeTransactionService implements TransactionService {
+public class FakeTransactionService extends TransactionServerImpl {
- private TransactionServerImpl server = new TransactionServerImpl();
-
public FakeTransactionService() {
- try {
- server.init(SimpleMock.createSimpleMock(TransactionProvider.class));
- } catch (XATransactionException e) {
- throw new RuntimeException(e);
- }
+ this.setTransactionProvider(SimpleMock.createSimpleMock(TransactionProvider.class));
}
- public TransactionServer getTransactionServer() {
- return server;
- }
-
- public XAServer getXAServer() {
- return server;
- }
-
- public void initialize(Properties props)
- throws ApplicationInitializationException {
- }
-
- public void start(ApplicationEnvironment environment)
- throws ApplicationLifecycleException {
- }
-
- public void stop() throws ApplicationLifecycleException {
- }
-
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -24,11 +24,9 @@
import javax.transaction.xa.XAResource;
-import org.teiid.dqp.internal.transaction.TransactionProvider;
-import org.teiid.dqp.internal.transaction.TransactionServerImpl;
-
import junit.framework.TestCase;
+import com.metamatrix.admin.api.objects.Transaction;
import com.metamatrix.common.xa.MMXid;
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.core.util.SimpleMock;
@@ -52,7 +50,7 @@
*/
protected void setUp() throws Exception {
server = new TransactionServerImpl();
- server.init(SimpleMock.createSimpleMock(TransactionProvider.class));
+ server.setTransactionProvider(SimpleMock.createSimpleMock(TransactionProvider.class));
}
/**
@@ -239,4 +237,18 @@
public void testGetTransactionContext() throws Exception {
assertSame(server.getOrCreateTransactionContext(THREAD1), server.getOrCreateTransactionContext(THREAD1));
}
+
+ public void testGetTransactions() throws Exception {
+ server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100);
+ server.begin(THREAD2);
+
+ assertEquals(2, server.getTransactions().size());
+
+ server.commit(THREAD2);
+ assertEquals(1, server.getTransactions().size());
+
+ Transaction t = server.getTransactions().iterator().next();
+ assertEquals(THREAD1, t.getAssociatedSession());
+ assertNotNull(t.getXid());
+ }
}
Modified: trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -522,16 +522,14 @@
return parent.getResources(identifier);
case MMAdminObject.OBJECT_TYPE_SESSION:
return parent.getSessions(identifier);
- case MMAdminObject.OBJECT_TYPE_SOURCE_REQUEST:
- return parent.getSourceRequests(identifier);
case MMAdminObject.OBJECT_TYPE_SYSTEM_OBJECT:
list = new ArrayList();
list.add(parent.getSystem());
return list;
case MMAdminObject.OBJECT_TYPE_VDB:
return parent.getVDBs(identifier);
-
-
+ case MMAdminObject.OBJECT_TYPE_TRANSACTION:
+ return parent.getTransactions();
case MMAdminObject.OBJECT_TYPE_ENTITLEMENT:
case MMAdminObject.OBJECT_TYPE_MODEL:
case MMAdminObject.OBJECT_TYPE_PROPERTY_DEFINITION:
Modified: trunk/server/src/main/java/com/metamatrix/admin/server/ServerAdminImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/admin/server/ServerAdminImpl.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/server/src/main/java/com/metamatrix/admin/server/ServerAdminImpl.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -28,6 +28,8 @@
import java.util.List;
import java.util.Properties;
+import javax.transaction.xa.Xid;
+
import com.metamatrix.admin.api.exception.AdminException;
import com.metamatrix.admin.api.objects.AdminOptions;
import com.metamatrix.admin.api.objects.ConnectorBinding;
@@ -35,6 +37,7 @@
import com.metamatrix.admin.api.objects.LogConfiguration;
import com.metamatrix.admin.api.objects.ScriptsContainer;
import com.metamatrix.admin.api.objects.SystemObject;
+import com.metamatrix.admin.api.objects.Transaction;
import com.metamatrix.admin.api.objects.VDB;
import com.metamatrix.admin.api.server.ServerAdmin;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -969,4 +972,22 @@
throws AdminException {
return getSecurityAdmin().getGroupsForDomain(domainName);
}
+
+ @Override
+ public Collection<Transaction> getTransactions()
+ throws AdminException {
+ return getMonitoringAdmin().getTransactions();
+ }
+
+ @Override
+ public void terminateTransaction(String transactionId, String sessionId)
+ throws AdminException {
+ getRuntimeAdmin().terminateTransaction(transactionId, sessionId);
+ }
+
+ @Override
+ public void terminateTransaction(Xid transactionId) throws AdminException {
+ getRuntimeAdmin().terminateTransaction(transactionId);
+ }
+
}
\ No newline at end of file
Modified: trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -49,6 +49,7 @@
import com.metamatrix.admin.api.objects.Resource;
import com.metamatrix.admin.api.objects.Session;
import com.metamatrix.admin.api.objects.SystemObject;
+import com.metamatrix.admin.api.objects.Transaction;
import com.metamatrix.admin.api.objects.VDB;
import com.metamatrix.admin.api.server.ServerMonitoringAdmin;
import com.metamatrix.admin.objects.MMAdminObject;
@@ -1226,5 +1227,10 @@
return null;
}
+ @Override
+ public Collection<Transaction> getTransactions()
+ throws AdminException {
+ return getQueryServiceProxy().getTransactions();
+ }
}
\ No newline at end of file
Modified: trunk/server/src/main/java/com/metamatrix/admin/server/ServerRuntimeStateAdminImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/admin/server/ServerRuntimeStateAdminImpl.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/server/src/main/java/com/metamatrix/admin/server/ServerRuntimeStateAdminImpl.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -29,6 +29,8 @@
import java.util.List;
import java.util.Map;
+import javax.transaction.xa.Xid;
+
import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.admin.api.exception.AdminComponentException;
@@ -730,7 +732,16 @@
return true;
}
+ @Override
+ public void terminateTransaction(String transactionId, String sessionId)
+ throws AdminException {
+ this.getQueryServiceProxy().terminateTransaction(transactionId, sessionId);
+ }
+ @Override
+ public void terminateTransaction(Xid transactionId) throws AdminException {
+ this.getQueryServiceProxy().terminateTransaction(transactionId);
+ }
}
\ No newline at end of file
Modified: trunk/server/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/server/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -208,8 +208,7 @@
try {
vdbID = RuntimeMetadataCatalog.getInstance().getActiveVirtualDatabaseID(vdbName, vdbVersion);
} catch (VirtualDatabaseDoesNotExistException e) {
- // Propagate message, don't care about stack trace
- throw new MetaMatrixAuthenticationException(e.getMessage());
+ throw new SessionServiceException(e);
} catch (VirtualDatabaseException e) {
if (vdbVersion == null) {
throw new SessionServiceException(e,PlatformPlugin.Util.getString("SessionServiceImpl.Unexpected_error_finding_latest_version_of_Virtual_Database", new Object[] {vdbName})); //$NON-NLS-1$
Modified: trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -112,9 +112,7 @@
import com.metamatrix.server.HostManagement;
import com.metamatrix.server.ResourceFinder;
import com.metamatrix.server.admin.api.RuntimeMetadataAdminAPI;
-import com.metamatrix.server.admin.api.TransactionAdminAPI;
import com.metamatrix.server.admin.apiimpl.RuntimeMetadataAdminAPIImpl;
-import com.metamatrix.server.admin.apiimpl.TransactionAdminAPIImpl;
import com.metamatrix.server.util.ServerPropertyNames;
/**
@@ -211,7 +209,6 @@
this.clientServices.registerClientService(AuthorizationAdminAPI.class, AuthorizationAdminAPIImpl.getInstance(), PlatformAdminConstants.CTX_AUTHORIZATION_ADMIN_API);
this.clientServices.registerClientService(ExtensionSourceAdminAPI.class, ExtensionSourceAdminAPIImpl.getInstance(), PlatformAdminConstants.CTX_ADMIN_API);
this.clientServices.registerClientService(RuntimeMetadataAdminAPI.class, RuntimeMetadataAdminAPIImpl.getInstance(), PlatformAdminConstants.CTX_RUNTIME_METADATA_ADMIN_API);
- this.clientServices.registerClientService(TransactionAdminAPI.class, TransactionAdminAPIImpl.getInstance(), PlatformAdminConstants.CTX_ADMIN_API);
}
Deleted: trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/TransactionAdminAPIImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/TransactionAdminAPIImpl.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/server/src/main/java/com/metamatrix/server/admin/apiimpl/TransactionAdminAPIImpl.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -1,127 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.server.admin.apiimpl;
-
-import java.util.Collection;
-import java.util.Collections;
-
-import com.metamatrix.admin.api.exception.security.InvalidSessionException;
-import com.metamatrix.admin.api.server.AdminRoles;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MultipleException;
-import com.metamatrix.api.exception.security.AuthorizationException;
-import com.metamatrix.common.xa.TransactionID;
-import com.metamatrix.common.xa.XATransactionException;
-import com.metamatrix.platform.admin.apiimpl.AdminAPIHelper;
-import com.metamatrix.platform.admin.apiimpl.SubSystemAdminAPIImpl;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.SessionToken;
-import com.metamatrix.server.admin.api.TransactionAdminAPI;
-
-public class TransactionAdminAPIImpl extends SubSystemAdminAPIImpl implements TransactionAdminAPI {
-
- //Transaction service proxy
- private static TransactionAdminAPI transactionAdminAPI;
-
- /**
- * ctor
- */
- private TransactionAdminAPIImpl() throws MetaMatrixComponentException {
- }
-
- public synchronized static TransactionAdminAPI getInstance() throws MetaMatrixComponentException {
- if (transactionAdminAPI == null) {
- transactionAdminAPI = new TransactionAdminAPIImpl();
- }
- return transactionAdminAPI;
- }
-
- /**
- * Return all transactions that are in the system.
- *
- * @return a collection of <code>ServerTransaction</code> objects.
- * @throws AuthorizationException if caller is not authorized to perform this method.
- * @throws InvalidSessionException if the <code>callerSessionID</code> is not valid or is expired.
- * @throws MetaMatrixComponentException if an error occurred in communicating with a component.
- */
- public synchronized Collection getAllTransactions()
- throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException {
-
- // Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
- // Any administrator may call this read-only method - no need to validate role
-
- // TODO: This will eventually be replaced
- return Collections.EMPTY_LIST;
- }
-
-
- /**
- * Terminate a transactions.
- * If status == STATUS_ACTIVE or STATUS_MARKED_ROLLBACK, rollback transaction.
- * Else, set status to STATUS_ROLLEDBACK.
- *
- * @param transactionID ID of the transaction to be rolledback.
- * @throws AuthorizationException if caller is not authorized to perform this method.
- * @throws InvalidSessionException if the <code>callerSessionID</code> is not valid or is expired.
- * @throws com.metamatrix.common.xa.InvalidTransactionIDException if the Transaction does not exist.
- * @throws MetaMatrixComponentException if an error occurred in communicating with a component.
- */
- public synchronized void terminateTransaction(TransactionID transactionID)
- throws AuthorizationException, InvalidSessionException, XATransactionException, MetaMatrixComponentException {
-
- // Validate caller's session
- SessionToken callerToken = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(callerToken, AdminRoles.RoleName.ADMIN_PRODUCT, "TransactionAdminAPIImpl.terminateTransaction(" + transactionID + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-
- // TODO: This will eventually be replaced
-// transAdmin.terminateTransaction(transactionID);
- }
-
-
-
- /**
- * Terminate all transactions for the user session.
- * If status == STATUS_ACTIVE or STATUS_MARKED_ROLLBACK, rollback transaction.
- * Else, set status to STATUS_ROLLEDBACK.
- *
- * @param userSessionID the primary identifier for the user account.
- * @throws AuthorizationException if caller is not authorized to perform this method.
- * @throws InvalidSessionException if the <code>callerSessionID</code> is not valid or is expired.
- * @throws MetaMatrixComponentException if an error occurred in communicating with a component.
- */
- public synchronized void terminateAllTransactions(MetaMatrixSessionID userSessionID)
- throws AuthorizationException, InvalidSessionException, MultipleException, MetaMatrixComponentException {
-
- // Validate caller's session
- SessionToken callerToken = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(callerToken, AdminRoles.RoleName.ADMIN_PRODUCT, "TransactionAdminAPIImpl.terminateAllTransactions(" + userSessionID + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-
- // TODO: This will eventually be replaced
-// transAdmin.terminateTransactionsForSession(callerToken);
- }
-
-}
-
Modified: trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformTransactionService.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformTransactionService.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformTransactionService.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -30,30 +30,21 @@
import com.google.inject.Inject;
import com.google.inject.name.Named;
-import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.ResourceNames;
import com.metamatrix.common.config.api.Host;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogCommonConstants;
import com.metamatrix.common.xa.XATransactionException;
-import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.FileUtils;
import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.transaction.TransactionServer;
-import com.metamatrix.dqp.transaction.XAServer;
import com.metamatrix.server.Configuration;
import com.metamatrix.xa.arjuna.ArjunaTransactionProvider;
/**
*/
-public class PlatformTransactionService implements TransactionService{
+public class PlatformTransactionService extends TransactionServerImpl {
- private TransactionServerImpl arjunaTs = new TransactionServerImpl();
- private TransactionServer ts;
private Host host;
@Inject
@@ -83,42 +74,11 @@
props.setProperty(TransactionService.VMNAME, CurrentConfiguration.getInstance().getProcessName());
props.setProperty(TransactionService.TXN_STORE_DIR, host.getDataDirectory());
- arjunaTs.init(ArjunaTransactionProvider.getInstance(props));
-
- final Class[] interfaces = new Class[] {TransactionServer.class, XAServer.class};
-
- ts = (TransactionServer)LogManager.createLoggingProxy(LogCommonConstants.CTX_XA_TXN, arjunaTs, interfaces, MessageLevel.DETAIL);
+ this.setTransactionProvider(ArjunaTransactionProvider.getInstance(props));
+ this.setProcessName(CurrentConfiguration.getInstance().getProcessName());
} catch (XATransactionException err) {
throw new ApplicationInitializationException(err);
}
}
- /*
- * @see com.metamatrix.common.application.ApplicationService#start(com.metamatrix.common.application.ApplicationEnvironment)
- */
- public void start(ApplicationEnvironment environment) throws ApplicationLifecycleException {
-
- }
-
- /*
- * @see com.metamatrix.common.application.ApplicationService#stop()
- */
- public void stop() throws ApplicationLifecycleException {
- arjunaTs.shutdown(true);
- }
-
- /**
- * @see com.metamatrix.dqp.service.TransactionService#getTransactionServer()
- */
- public TransactionServer getTransactionServer() {
- return ts;
- }
-
- /**
- * @see com.metamatrix.dqp.service.TransactionService#getXAServer()
- */
- public XAServer getXAServer() {
- return (XAServer)ts;
- }
-
}
Modified: trunk/server/src/main/java/com/metamatrix/server/query/service/QueryService.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/query/service/QueryService.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/server/src/main/java/com/metamatrix/server/query/service/QueryService.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -26,13 +26,18 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
+import javax.transaction.xa.Xid;
+
import org.teiid.dqp.internal.process.DQPCore;
+import com.metamatrix.admin.api.exception.AdminException;
+import com.metamatrix.admin.api.objects.Transaction;
import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.server.InvalidRequestIDException;
@@ -49,6 +54,7 @@
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.platform.service.api.CacheAdmin;
import com.metamatrix.platform.service.api.ServiceID;
@@ -160,7 +166,7 @@
* @see com.metamatrix.server.query.service.QueryServiceInterface#cancelQueries(com.metamatrix.platform.security.api.SessionToken, boolean, boolean)
*/
public void cancelQueries(SessionToken sessionToken, boolean shouldRollback)
- throws InvalidRequestIDException, MetaMatrixComponentException{
+ throws MetaMatrixComponentException{
this.dqp.terminateConnection(sessionToken.getSessionID().toString());
}
@@ -249,5 +255,35 @@
super.init(id, deployedComponentID, props, listenerRegistry);
listenerRegistry.registerClientService(ClientSideDQP.class, this.dqp, LogConstants.CTX_QUERY_SERVICE);
}
+
+ @Override
+ public Collection<Transaction> getTransactions() {
+ TransactionService ts = getTransactionService();
+ if (ts == null) {
+ return Collections.emptyList();
+ }
+ return ts.getTransactions();
+ }
+
+ @Override
+ public void terminateTransaction(String transactionId, String sessionId)
+ throws AdminException {
+ TransactionService ts = getTransactionService();
+ if (ts != null) {
+ ts.terminateTransaction(transactionId, sessionId);
+ }
+ }
+
+ @Override
+ public void terminateTransaction(Xid transactionId) throws AdminException {
+ TransactionService ts = getTransactionService();
+ if (ts != null) {
+ ts.terminateTransaction(transactionId);
+ }
+ }
+
+ protected TransactionService getTransactionService() {
+ return this.dqp.getTransactionServiceDirect();
+ }
}
Modified: trunk/server/src/main/java/com/metamatrix/server/query/service/QueryServiceInterface.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/query/service/QueryServiceInterface.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/server/src/main/java/com/metamatrix/server/query/service/QueryServiceInterface.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -24,6 +24,10 @@
import java.util.Collection;
+import javax.transaction.xa.Xid;
+
+import com.metamatrix.admin.api.exception.AdminException;
+import com.metamatrix.admin.api.objects.Transaction;
import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.server.InvalidRequestIDException;
@@ -47,8 +51,6 @@
public Collection getAllQueries();
- public Collection getQueriesForSession(SessionToken userToken);
-
//=========================================================================
// Methods to cancel running queries and cursors associated with them
//=========================================================================
@@ -59,6 +61,12 @@
throws InvalidRequestIDException, MetaMatrixComponentException;
public void cancelQuery(RequestID requestID, int nodeID)
- throws InvalidRequestIDException, MetaMatrixComponentException;
+ throws InvalidRequestIDException, MetaMatrixComponentException;
+
+ Collection<Transaction> getTransactions();
+
+ void terminateTransaction(Xid transactionId) throws AdminException;
+
+ void terminateTransaction(String transactionId, String sessionId) throws AdminException;
}
Modified: trunk/server/src/main/resources/com/metamatrix/admin/util/methodroles.properties
===================================================================
--- trunk/server/src/main/resources/com/metamatrix/admin/util/methodroles.properties 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/server/src/main/resources/com/metamatrix/admin/util/methodroles.properties 2009-04-08 15:36:06 UTC (rev 730)
@@ -65,6 +65,7 @@
getPropertyDefinitions=Admin.ReadOnlyAdmin
getQueueWorkerPools=Admin.ReadOnlyAdmin
getRequests=Admin.ReadOnlyAdmin
+getTransactions=Admin.ReadOnlyAdmin
getSessions=Admin.ReadOnlyAdmin
getSourceRequests=Admin.ReadOnlyAdmin
getSystem=Admin.ReadOnlyAdmin
@@ -79,6 +80,7 @@
startConnectorBinding=Admin.ProductAdmin
stopConnectorBinding=Admin.ProductAdmin
terminateSession=Admin.ProductAdmin
+terminateTransaction=Admin.ProductAdmin
#===============================
# ServerAdmin
#===============================
Modified: trunk/server/src/test/java/com/metamatrix/admin/server/FakeQueryService.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/admin/server/FakeQueryService.java 2009-04-08 11:50:41 UTC (rev 729)
+++ trunk/server/src/test/java/com/metamatrix/admin/server/FakeQueryService.java 2009-04-08 15:36:06 UTC (rev 730)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
@@ -31,7 +32,11 @@
import java.util.Properties;
import java.util.Set;
+import javax.transaction.xa.Xid;
+
+import com.metamatrix.admin.api.exception.AdminException;
import com.metamatrix.admin.api.objects.Request;
+import com.metamatrix.admin.api.objects.Transaction;
import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.server.InvalidRequestIDException;
@@ -291,5 +296,21 @@
public Throwable getInitException() {
return null;
}
+
+ @Override
+ public Collection<Transaction> getTransactions() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public void terminateTransaction(String transactionId, String sessionId)
+ throws AdminException {
+
+ }
+
+ @Override
+ public void terminateTransaction(Xid transactionId) throws AdminException {
+
+ }
}
15 years, 8 months