[teiid-commits] teiid SVN: r1911 - in trunk/common-internal: src/main/java and 27 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Thu Mar 4 15:00:29 EST 2010
Author: shawkins
Date: 2010-03-04 15:00:27 -0500 (Thu, 04 Mar 2010)
New Revision: 1911
Added:
trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java
trunk/common-internal/src/main/java/org/
trunk/common-internal/src/main/java/org/teiid/
trunk/common-internal/src/main/java/org/teiid/SecurityHelper.java
Removed:
trunk/common-internal/src/main/java/com/metamatrix/admin/
trunk/common-internal/src/main/java/com/metamatrix/api/exception/
trunk/common-internal/src/main/java/com/metamatrix/common/actions/
trunk/common-internal/src/main/java/com/metamatrix/common/config/api/
trunk/common-internal/src/main/java/com/metamatrix/common/config/model/
trunk/common-internal/src/main/java/com/metamatrix/common/config/util/
trunk/common-internal/src/main/java/com/metamatrix/common/config/xml/
trunk/common-internal/src/main/java/com/metamatrix/common/extensionmodule/
trunk/common-internal/src/main/java/com/metamatrix/common/namedobject/
trunk/common-internal/src/main/java/com/metamatrix/common/object/
trunk/common-internal/src/main/java/com/metamatrix/common/queue/
trunk/common-internal/src/main/java/com/metamatrix/common/util/OSPlatformUtil.java
trunk/common-internal/src/main/java/com/metamatrix/common/util/VDBNameValidator.java
trunk/common-internal/src/main/java/com/metamatrix/common/util/crypto/
trunk/common-internal/src/main/java/com/metamatrix/common/vdb/
trunk/common-internal/src/main/java/com/metamatrix/common/xml/XMLReaderWriter.java
trunk/common-internal/src/main/java/com/metamatrix/common/xml/XMLReaderWriterImpl.java
trunk/common-internal/src/main/java/com/metamatrix/core/util/
trunk/common-internal/src/main/java/com/metamatrix/core/xml/
trunk/common-internal/src/main/java/com/metamatrix/internal/core/xml/vdb/
trunk/common-internal/src/main/java/com/metamatrix/internal/core/xml/xmi/
trunk/common-internal/src/main/java/com/metamatrix/internal/core/xml/xsd/
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataID.java
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataObject.java
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSource.java
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSourceUtil.java
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabase.java
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseDoesNotExistException.java
trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseID.java
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/apiimpl/
trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AbstractAuthorizationObjectEditor.java
trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationModel.java
trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationObjectEditor.java
trunk/common-internal/src/main/java/com/metamatrix/server/admin/api/
trunk/common-internal/src/main/java/com/metamatrix/server/admin/apiimpl/
trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/DatabaseDialect.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/MaterializedViewScriptGenerator.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/MaterializedViewScriptGeneratorImpl.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/ScriptDecorator.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/ScriptType.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/template/
trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicModelInfo.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicURIModelResource.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicVDBDefn.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicVDBInfo.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIModelResource.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIResource.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIResourceReader.java
trunk/common-internal/src/main/java/org/teiid/
trunk/common-internal/src/main/java/org/teiid/SecurityHelper.java
trunk/common-internal/src/main/resources/com/metamatrix/vdb/materialization/
trunk/common-internal/src/test/java/com/metamatrix/common/config/connector/
trunk/common-internal/src/test/java/com/metamatrix/common/config/xml/
trunk/common-internal/src/test/java/com/metamatrix/common/queue/
trunk/common-internal/src/test/java/com/metamatrix/common/util/TestVDBNameValidator.java
trunk/common-internal/src/test/java/com/metamatrix/common/util/crypto/keymanage/
trunk/common-internal/src/test/java/com/metamatrix/common/vdb/api/
trunk/common-internal/src/test/java/com/metamatrix/core/util/
trunk/common-internal/src/test/java/com/metamatrix/internal/core/xml/vdb/
trunk/common-internal/src/test/java/com/metamatrix/internal/core/xml/xmi/
trunk/common-internal/src/test/java/com/metamatrix/internal/core/xml/xsd/
trunk/common-internal/src/test/java/com/metamatrix/vdb/edit/materialization/
Modified:
trunk/common-internal/
trunk/common-internal/pom.xml
trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java
trunk/common-internal/src/main/java/com/metamatrix/internal/core/xml/JdomHelper.java
trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPermissionsImpl.java
trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPolicy.java
trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPolicyFactory.java
trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/VDBKey.java
trunk/common-internal/src/main/resources/com/metamatrix/platform/security/api/authorizations.xsd
Log:
TEIID-833 committing JCA merge
Property changes on: trunk/common-internal
___________________________________________________________________
Name: svn:mergeinfo
-
Modified: trunk/common-internal/pom.xml
===================================================================
--- trunk/common-internal/pom.xml 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/pom.xml 2010-03-04 20:00:27 UTC (rev 1911)
@@ -16,6 +16,7 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-common-core</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
@@ -27,6 +28,7 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
@@ -44,16 +46,11 @@
<artifactId>saxon-dom</artifactId>
</dependency>
- <dependency>
- <groupId>antlr</groupId>
- <artifactId>stringtemplate</artifactId>
- </dependency>
-
<dependency>
- <groupId>com.google.code.guice</groupId>
- <artifactId>guice</artifactId>
- </dependency>
-
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -27,7 +27,6 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import com.google.inject.Inject;
import com.metamatrix.common.CommonPlugin;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.JavaLogWriter;
@@ -87,10 +86,8 @@
*/
public final class LogManager {
- @Inject
static LogConfiguration configuration = new LogConfigurationImpl(MessageLevel.DETAIL); // either injected or manually set using the set methods
- @Inject
static LogListener logListener = new JavaLogWriter(); // either injected or manually set using the set methods
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/util/OSPlatformUtil.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/util/OSPlatformUtil.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/util/OSPlatformUtil.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,175 +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.util;
-
-import java.io.File;
-import java.io.PrintStream;
-import java.util.Properties;
-
-import com.metamatrix.core.util.Assertion;
-
-/**
- * PlatformAwareFileSystemView
- */
-public class OSPlatformUtil {
- public static String OS_PROPERTY_NAME = "os.name"; //$NON-NLS-1$
-
- /** Operating system is Windows NT. */
- public static final int OS_WINNT = 1;
- /** Operating system is Windows 95. */
- public static final int OS_WIN95 = 2;
- /** Operating system is Windows 98. */
- public static final int OS_WIN98 = 4;
- /** Operating system is Solaris. */
- public static final int OS_SOLARIS = 8;
- /** Operating system is Linux. */
- public static final int OS_LINUX = 16;
- /** Operating system is HP-UX. */
- public static final int OS_HP = 32;
- /** Operating system is IBM AIX. */
- public static final int OS_AIX = 64;
- /** Operating system is SGI IRIX. */
- public static final int OS_IRIX = 128;
- /** Operating system is Sun OS. */
- public static final int OS_SUNOS = 256;
- /** Operating system is Compaq TRU64 Unix */
- public static final int OS_TRU64 = 512;
- /** @deprecated please use OS_TRU64 instead */
- public static final int OS_DEC = OS_TRU64;
- /** Operating system is OS/2. */
- public static final int OS_OS2 = 1024;
- /** Operating system is Mac. */
- public static final int OS_MAC = 2048;
- /** Operating system is Windows 2000. */
- public static final int OS_WIN2000 = 4096;
- /** Operating system is Compaq OpenVMS */
- public static final int OS_VMS = 8192;
- /** Operating system is Compaq OpenVMS */
- public static final int OS_WINXP = 16384;
- /**
- *Operating system is one of the Windows variants but we don't know which
- *one it is
- */
- public static final int OS_WIN_OTHER = 16384;
-
- /** Operating system is unknown. */
- public static final int OS_OTHER = 65536;
-
- /** A mask for Windows platforms. */
- public static final int OS_WINDOWS_MASK = OS_WINNT | OS_WIN95 | OS_WIN98 | OS_WIN2000 | OS_WINXP | OS_WIN_OTHER;
- /** A mask for Unix platforms. */
- public static final int OS_UNIX_MASK = OS_SOLARIS | OS_LINUX | OS_HP | OS_AIX | OS_IRIX | OS_SUNOS | OS_TRU64 | OS_MAC;
- /** A mask for Linux platform **/
- public static final int OS_LINUX_MASK = OS_LINUX;
-
- /** The operating system on which MetaMatrix runs*/
- private static int operatingSystem = -1;
-
- /** Get the operating system on which the IDE is running.
- * @return one of the <code>OS_*</code> constants (such as {@link #OS_WINNT})
- */
- public static final int getOperatingSystem () {
- if (operatingSystem == -1) {
- String osName = System.getProperty(OS_PROPERTY_NAME);
- if ("Windows NT".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_WINNT;
- else if ("Windows 95".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_WIN95;
- else if ("Windows 98".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_WIN98;
- else if ("Windows 2000".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_WIN2000;
- else if ("Windows XP".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_WINXP;
- else if (osName.startsWith("Windows ")) //$NON-NLS-1$
- operatingSystem = OS_WIN_OTHER;
- else if ("Solaris".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_SOLARIS;
- else if (osName.startsWith ("SunOS")) //$NON-NLS-1$
- operatingSystem = OS_SOLARIS;
- // JDK 1.4 b2 defines os.name for me as "Redhat Linux" -jglick
- else if (osName.endsWith ("Linux")) //$NON-NLS-1$
- operatingSystem = OS_LINUX;
- else if ("HP-UX".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_HP;
- else if ("AIX".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_AIX;
- else if ("Irix".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_IRIX;
- else if ("SunOS".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_SUNOS;
- else if ("Digital UNIX".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_TRU64;
- else if ("OS/2".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_OS2;
- else if ("OpenVMS".equals (osName)) //$NON-NLS-1$
- operatingSystem = OS_VMS;
- else if (osName.equals ("Mac OS X")) //$NON-NLS-1$
- operatingSystem = OS_MAC;
- else if (osName.startsWith ("Darwin")) //$NON-NLS-1$
- operatingSystem = OS_MAC;
- else
- operatingSystem = OS_OTHER;
- }
- return operatingSystem;
- }
-
- /** Test whether the IDE is running on some variant of Windows.
- * @return <code>true</code> if Windows, <code>false</code> if some other manner of operating system
- */
- public static final boolean isWindows () {
- return (getOperatingSystem () & OS_WINDOWS_MASK) != 0;
- }
-
- /** Test whether the IDE is running on some variant of Unix.
- * Linux is included as well as the commercial vendors.
- * @return <code>true</code> some sort of Unix, <code>false</code> if some other manner of operating system
- */
- public static final boolean isUnix () {
- return (getOperatingSystem () & OS_UNIX_MASK) != 0;
- }
-
- /** Test whether the IDE is running on some variant of Unix.
- * Linux is included as well as the commercial vendors.
- * @return <code>true</code> some sort of Unix, <code>false</code> if some other manner of operating system
- */
- public static final boolean isLinux () {
- return (getOperatingSystem () & OS_LINUX_MASK) != 0;
- }
-
- static void printSystemProperties( PrintStream stream ) {
- Assertion.isNotNull(stream,"The PrintStream reference may not be null"); //$NON-NLS-1$
- Properties p = System.getProperties();
- p.list(stream);
- }
- static void printPermissions(File f, String action) {
- System.out.println("\nFile \"" + f + "\" action = " + action); //$NON-NLS-1$ //$NON-NLS-2$
- System.out.println("exists = "+f.exists()+" canRead = "+f.canRead()+" canWrite = "+f.canWrite()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- static void printRuntimeCmd(String methodName, String cmd) {
- System.out.println("\n[" + methodName + "] Runtime.exec( " + cmd + " )"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
-}
-
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/util/VDBNameValidator.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/util/VDBNameValidator.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/util/VDBNameValidator.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,121 +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.util;
-
-import java.text.StringCharacterIterator;
-
-
-/**
- * @since 5.0
- * This class contains static methods used to validate VDB and Source names. It is not intented to be a fancy string
- * parser/checker, it is only intented for VDB name validation with the following rules.
- *
- * Rules:
- * Names must contain only alphanumeric characters and _ (underscores)
- * Names must begin with a alpha character
- *
- * Along with the above rules there are reserved words that cannot be used for VDB names:
- *
- * System
- * Admin
- * Help
- *
- * Along with the above rules there are reserved words that cannot be used for Source names:
- *
- * System
- *
- *
- */
-public class VDBNameValidator {
-
- static String reservedVDBNames[] = {"System", "Admin", "Help"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- static String reservedSourceNames[] = {"System"}; //$NON-NLS-1$
-
-
- static public boolean isValid (String vdbName) {
-
- if (vdbName == null || vdbName.length() == 0) {
- return false;
- }
-
- if (containsInvalidChars(vdbName)) {
- return false;
- }
-
- // Check for Reserved words
- for (int i=0; i < reservedVDBNames.length; i++) {
- if (vdbName.equalsIgnoreCase(reservedVDBNames[i])) {
- return false;
- }
- }
- return true;
- }
-
- static public boolean isSourceValid (String sourceName) {
-
- if (sourceName == null || sourceName.length() == 0) {
- return false;
- }
-
- if (containsInvalidChars(sourceName)) {
- return false;
- }
- return !isSourceNameReserved(sourceName);
- }
-
- public static boolean isSourceNameReserved(String sourceName) {
- // Check for Reserved words
- for (int i=0; i < reservedSourceNames.length; i++) {
- if (sourceName.equalsIgnoreCase(reservedVDBNames[i])) {
- return true;
- }
- }
- return false;
- }
-
-
- private static boolean containsInvalidChars(String vdbName) {
-
- StringCharacterIterator charIterator = new StringCharacterIterator(vdbName);
-
- // Check to insure 1st character is a letter
- char c = charIterator.first();
- if (c != StringCharacterIterator.DONE) {
- if (!Character.isLetter(c)) {
- return true; // first character must be a letter
- }
- } else {
- return true; // empty string is invalid, should never happen
- }
-
- while (true) {
- c = charIterator.next();
- if (c == StringCharacterIterator.DONE) {
- return false;
- }
- if (!Character.isLetterOrDigit(c) & (c != '_')) {
- return true;
- }
- }
- }
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/xml/XMLReaderWriter.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/xml/XMLReaderWriter.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/xml/XMLReaderWriter.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,60 +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.xml;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.jdom.Document;
-import org.jdom.JDOMException;
-
-
-/**
-* This interface is used to read and write JDOM compliant XML files.
-*/
-public interface XMLReaderWriter {
-
- /**
- * This method will write a JDOM Document to an OutputStream.
- *
- * @param doc the JDOM document to be written to the OutputStream
- * @param stream the output stream to be written to.
- * @throws IOException if there is a problem writing to the OutputStream
- */
- public void writeDocument(Document doc, OutputStream stream) throws IOException;
-
- /**
- * This method will write a JDOM Document to an OutputStream.
- *
- * @param stream the input stream to read the XML document from.
- * @return the JDOM document reference that represents the XML text in the
- * InputStream.
- * @throws IOException if there is a problem reading from the InputStream
- * @throws JDOMException if the InputStream does not represent a JDOM
- * compliant XML document.
- */
- public Document readDocument(InputStream stream) throws JDOMException, IOException;
-
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/xml/XMLReaderWriterImpl.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/xml/XMLReaderWriterImpl.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/xml/XMLReaderWriterImpl.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,104 +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.xml;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.jdom.Document;
-import org.jdom.output.XMLOutputter;
-import org.jdom.JDOMException;
-
-import com.metamatrix.internal.core.xml.JdomHelper;
-
-
-/**
-* This implementation will use the JDOMhelper to read in XML files and will
-* use the JDOM utility to write out JDOM XML files.
-*/
-public class XMLReaderWriterImpl implements XMLReaderWriter{
-
- public static final int DEFAULT_INDENT_SIZE = 4;
- public static final boolean DEFAULT_USE_NEW_LINES = true;
-
- private int indent = DEFAULT_INDENT_SIZE;
- private boolean newLines = DEFAULT_USE_NEW_LINES;
-
- /**
- * This method will write a JDOM Document to an OutputStream.
- *
- * @param doc the JDOM document to be written to the OutputStream
- * @param stream the output stream to be written to.
- * @throws IOException if there is a problem writing to the OutputStream
- */
- public void writeDocument(Document doc, OutputStream stream) throws IOException{
- StringBuffer indentBuffer = new StringBuffer();
- for (int i = 0; i < indent; i++) {
- indentBuffer.append(" "); //$NON-NLS-1$
- }
- XMLOutputter outputter = new XMLOutputter(JdomHelper.getFormat(indentBuffer.toString(), newLines));
-
- outputter.output(doc, stream);
- stream.flush();
- stream.close();
-
- }
-
- /**
- * This method will write a JDOM Document to an OutputStream.
- *
- * @param stream the input stream to read the XML document from.
- * @return the JDOM document reference that represents the XML text in the
- * InputStream.
- * @throws IOException if there is a problem reading from the InputStream
- * @throws JDOMException if the InputStream does not represent a JDOM
- * compliant XML document.
- */
- public Document readDocument(InputStream stream) throws JDOMException, IOException{
- return JdomHelper.buildDocument(stream);
- }
-
- /**
- * This method will set the indent size of all JDOM Documents that are
- * written using this object.
- *
- * @param indent the number of spaces to indent the XML heirarchy in the
- * output files.
- */
- public void setIndentSize(int indent) {
- this.indent = indent;
- }
-
- /**
- * This method will set whether or not new Lines are used to mimic the
- * hierarchal structure of all JDOM Documents that are
- * written using this object.
- *
- * @param newLines whether or not to include new line chars in output files.
- */
- public void setUseNewLines(boolean newLines) {
- this.newLines = newLines;
- }
-
-}
Modified: trunk/common-internal/src/main/java/com/metamatrix/internal/core/xml/JdomHelper.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/internal/core/xml/JdomHelper.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/internal/core/xml/JdomHelper.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -738,22 +738,20 @@
* @throws IOException if there are problems writing to the file.
*/
public static void write( Document doc , String filename, String indent, boolean newlines ) throws IOException {
- if(doc == null){
- ArgCheck.isNotNull(doc,CorePlugin.Util.getString("JdomHelper.The_Document_reference_may_not_be_null_42")); //$NON-NLS-1$
- }
+ ArgCheck.isNotNull(doc,CorePlugin.Util.getString("JdomHelper.The_Document_reference_may_not_be_null_42")); //$NON-NLS-1$
+ ArgCheck.isNotNull(filename,CorePlugin.Util.getString("JdomHelper.The_filename_may_not_be_null_43")); //$NON-NLS-1$
- if(filename == null){
- ArgCheck.isNotNull(filename,CorePlugin.Util.getString("JdomHelper.The_filename_may_not_be_null_43")); //$NON-NLS-1$
- }
-
if(filename.length() == 0){
ArgCheck.isNotZeroLength(filename,CorePlugin.Util.getString("JdomHelper.The_filename_may_not_be_zero-length_44")); //$NON-NLS-1$
}
FileOutputStream out = new FileOutputStream( filename );
- write(doc,out,indent,newlines);
- out.flush();
- out.close();
+ try {
+ write(doc,out,indent,newlines);
+ out.flush();
+ } finally {
+ out.close();
+ }
}
/**
Deleted: trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataID.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataID.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataID.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,170 +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.metadata.runtime.api;
-
-import java.io.Serializable;
-import java.util.List;
-
-
-/**
- * The MetadataID class serves as the interface class for identifiers
- * of objects. This class provides the method signatures
- * common to all ID classes as well as the majority of the implementation, and
- * defines an identification name as a list of one or more non-zero length atomic name components
- * delimeted by a '.' (similar to JNDI names).
- * <p>
- * These classes are shipped between the client and RuntimeMetadata, so
- * the MetadataID class is serializable. To speed serialization and decrease
- * the overhead of shipping MetadataID across the network using RMI, several
- * instance variables that may not be required by all users are made transient
- * and recomputed as needed.
- * <p>
- * Additionally, because IDs are designed
- * to be used as primary keys, the <code>hashCode</code>, <code>equals</code>
- * and <code>compareTo</code> methods are all consistent and optimized for
- * fast performance. This is in part accomplished by caching the hash code value,
- * which is tolerable since all MetadataID subclasses are <i>immutable</i>: they
- * cannot be modified after they have been created.
- * <p>
- * Finally, several key methods that are very commonly used and that will not be
- * overridden in subclasses are marked as <code>final</code> as an inlining hint to the
- * compiler.
- */
-public interface MetadataID extends Cloneable, Comparable, Serializable {
-
- /**
- * Obtain the full name for the object that this identifier represents.
- * @return the full name for this identifier.
- */
- public String getFullName() ;
- /**
- * Obtain the last name component this identifier. This last name component
- * is the logical name for the object that this identifier represents.
- * @return the name for this identifier.
- */
- public String getName();
-
- /**
- * Obtain the path for this component.
- * @return the path
- */
- public String getPath();
-
- /**
- * Obtain the specified component of the name.
- * @param the index of the atomic name component to return; must be less than
- * the result of the method <code>size</code> in order to be valid.
- * @return the full name for this identifier.
- * @throws IndexOutOfBoundsException if the index is not valid and is out of the bounds of this name.
- */
- public String getNameComponent( int index ) ;
- /**
- * Obtain the list of atomic name components for this ID.
- * @return the unmodifiable list of String objects.
- * @throws IndexOutOfBoundsException if the index is not valid and is out of the bounds of this name.
- */
- public List getNameComponents();
- /**
- * Return the number of atomic name components in this identifier.
- * @return the size of this identifier.
- */
- public int size();
- /**
- * Returns true if the specified object is semantically equal to this instance.
- * Note: this method is consistent with <code>compareTo()</code>.
- * <p>
- * @param obj the object that this instance is to be compared to.
- * @return whether the object is equal to this object.
- */
- public boolean equals(Object obj);
-
- /**
- * Compares this object to another. If the specified object is an instance of
- * the MetadataID class, then this method compares the name; otherwise, it throws a
- * ClassCastException (as instances are comparable only to instances of the same
- * class).
- * Note: this method <i>is</i> consistent with <code>equals()</code>, meaning
- * that <code>(compare(x, y)==0) == (x.equals(y))</code>.
- * <p>
- * The algorithm that this method follows is based primarily upon the
- * hash code. When two instances of MetadataID, objects A and B, are being compared,
- * this method first compares the (cached) hash code of the two objects. If the
- * two hash codes are not equal, the method returns the difference in the hash
- * codes (namely <code>A.hashCode() - B.hashCode()</code>).
- * If, however, the two hash code values are equivalent, then the
- * two MetadataID instances are <i>potentially</i> equivalent, and the
- * full names of the BaseIDs are compared (ignoring case) to determine <i>actual</i> result.
- * <p>
- * @param obj the object that this instance is to be compared to.
- * @return a negative integer, zero, or a positive integer as this object
- * is less than, equal to, or greater than the specified object, respectively.
- * @throws IllegalArgumentException if the specified object reference is null
- * @throws ClassCastException if the specified object's type prevents it
- * from being compared to this instance.
- */
- public int compareTo(Object obj);
-
- /**
- * Compares this object to another lexicographically. If the specified object is an instance of
- * the same class, then this method compares the name; otherwise, it throws a
- * ClassCastException (as instances are comparable only to instances of the same
- * class). Note: this method is consistent with <code>equals()</code>.
- * <p>
- * @param obj the object that this instance is to be compared to.
- * @return a negative integer, zero, or a positive integer as this object
- * is less than, equal to, or greater than the specified object, respectively.
- * @throws IllegalArgumentException if the specified object reference is null
- * @throws ClassCastException if the specified object's type prevents it
- * from being compared to this instance.
- */
- public int compareToByName(Object obj);
-
- /**
- * Returns the hash code value for this object.
- * @return a hash code value for this object.
- */
- public int hashCode();
-
- /**
- * Returns a string representing the current state of the object.
- * @return the string representation of this instance.
- */
- public String toString();
- /**
- * Return a deep cloned instance of this object. Subclasses must override
- * this method.
- * @return the object that is the clone of this instance.
- * @throws CloneNotSupportedException if this object cannot be cloned (i.e., only objects in
- * {@link com.metamatrix.metadata.api.Defaults Defaults} cannot be cloned).
- */
- public Object clone() throws CloneNotSupportedException;
- /**
- * Return the full name of the parent. This is a convenience method to return
- * the list of atomic name components that excludes this ID's last atomic name component.
- * @return the full name of the parent, or null if this ID has no parent.
- */
- public String getParentFullName() ;
-
-}
-
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataObject.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataObject.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataObject.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,105 +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.metadata.runtime.api;
-
-import java.util.Properties;
-
-
-public interface MetadataObject extends java.io.Serializable{
-
- /**
- * Return the identifier for this object. The returned type will be an instance of the BaseID subclass
- * which corresponds to the class of this node.
- * @return the specialized BaseID instance for this node.
- */
- MetadataID getID();
-
-
- /**
- * Returns the name for this instance of the object. If you are using
- * the dot notation for a naming conventions, this will return the last
- * node in name.
- * @return the name
- *
- * @see getFullName
- */
- String getName();
-
- /**
- * Returns the full name for this instance of the object.
- * @return the name
- */
- String getFullName();
-
- /**
- * Compares this object to another. If the specified object is an instance of
- * the same class, then this method compares the name; otherwise, it throws a
- * ClassCastException (as instances are comparable only to instances of the same
- * class). Note: this method is consistent with <code>equals()</code>.
- * <p>
- * @param obj the object that this instance is to be compared to.
- * @return a negative integer, zero, or a positive integer as this object
- * is less than, equal to, or greater than the specified object, respectively.
- * @throws ClassCastException if the specified object's type prevents it
- * from being compared to this instance.
- */
- int compareTo(Object obj);
-
- /**
- * Returns a string representing the current state of the object.
- * @return the string representation of this instance.
- */
- String toString();
-
- /**
- * Returns true if the specified object is semantically equal to this instance.
- * Note: this method is consistent with <code>compareTo()</code>.
- * <p>
- * @param obj the object that this instance is to be compared to.
- * @return whether the object is equal to this object.
- */
- boolean equals(Object obj);
-
- /**
- * Return a deep cloned instance of this object. Subclasses must override
- * this method.
- * @return the object that is the clone of this instance.
- * @throws CloneNotSupportedException if this object cannot be cloned (i.e., only objects in
- * {@link com.metamatrix.metadata.api.Defaults Defaults} cannot be cloned).
- */
- public Object clone() throws CloneNotSupportedException;
-
- /**
- * returns the VirtualDatabaseID that identifies the VirtualDatabase this metadata object resides.
- * @return VirtualDatabaseID
- */
- VirtualDatabaseID getVirtualDatabaseID();
-
-
- /**
- * returns the user defined properties for this metadata object.
- * @return Properties
- */
- Properties getProperties() throws VirtualDatabaseException;
-}
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSource.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSource.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSource.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,52 +0,0 @@
-package com.metamatrix.metadata.runtime.api;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Set;
-
-import com.metamatrix.common.vdb.api.ModelInfo;
-
-public interface MetadataSource {
-
- String getName();
-
- /**
- * Return all files known by this metadata source
- * @return
- */
- Set<String> getEntries();
-
- /**
- * Returns the file for the given path, which must exist in the entry set
- * @param path
- * @return
- */
- File getFile(String path);
-
- /**
- * Get the list of model names that will provide metadata
- * @return
- */
- Set<String> getConnectorMetadataModelNames();
-
- /**
- * Whether to cache connector metadata
- * @return
- */
- boolean cacheConnectorMetadata();
-
- /**
- * Save the stream to given path.
- * @param path
- */
- void saveFile(InputStream stream, String path) throws IOException;
-
- /**
- * Get the model with the given name.
- * @param name
- * @return
- */
- ModelInfo getModelInfo(String name);
-
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSourceUtil.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSourceUtil.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/MetadataSourceUtil.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,50 +0,0 @@
-package com.metamatrix.metadata.runtime.api;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
-import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.core.util.ObjectConverterUtil;
-import com.metamatrix.core.util.StringUtil;
-
-public class MetadataSourceUtil {
-
- public static String getFileContentAsString(String path, MetadataSource iss) {
- File f = iss.getFile(path);
- if (f == null) {
- return null;
- }
- try {
- return ObjectConverterUtil.convertFileToString(f);
- } catch (IOException e) {
- LogManager.logError(LogConstants.CTX_CONFIG, e, e.getMessage());
- }
- return null;
- }
-
- /**
- * @see com.metamatrix.modeler.core.index.IndexSelector#getFileContent(java.lang.String, java.lang.String[], java.lang.String[])
- * @since 4.2
- */
- public static InputStream getFileContent(final String path, MetadataSource iss, final String[] tokens, final String[] tokenReplacements) {
- ArgCheck.isNotNull(tokens);
- ArgCheck.isNotNull(tokenReplacements);
- Assertion.isEqual(tokens.length, tokenReplacements.length);
- String fileContents = getFileContentAsString(path, iss);
- if(fileContents != null) {
- for(int i=0; i < tokens.length; i++) {
- final String token = tokens[i];
- final String tokenReplacement = tokenReplacements[i];
- fileContents = StringUtil.replaceAll(fileContents, token, tokenReplacement);
- }
- return new ByteArrayInputStream(fileContents.getBytes());
- }
- return null;
- }
-
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabase.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabase.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabase.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,116 +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.metadata.runtime.api;
-
-import java.util.Collection;
-import java.util.Date;
-
-/**
- * <p>The VirtualDatabase identifies a collection of DataSources and Virtual DataSources that a client can connect to and interrogate its metadata.</p>
- */
-public interface VirtualDatabase extends MetadataObject {
-/**
- * Return the description.
- * @return String
- */
- String getDescription();
-/**
- * Returns the ModelID's that exist in this virtual database.
- * @return Collection of the ModelID's contained in this VirtualDatabase
- */
- Collection getModelIDs();
-/**
- * Returns a short indicating if the status of the VirtualDatabase. There are four
- * status of the VirtualDatabase: "Incomplete", "Inactive", "Active", and "Deleted".
- * @return boolean true indicates marked for deletion
- */
- short getStatus();
-/**
- * Return the global unique identifier for this Virtual Databse. This is the ProjectGUID
- * that identifies the Design Time Configuration that created this VDB.
- * @return String
- */
- String getGUID();
-/**
- * Return the date the Virtual Database was created.
- * @return Date
- */
- Date getVersionDate();
-/**
- * Return the user name who create this version of the Virtual Database.
- * @return String
- */
- String getVersionBy();
-/**
- * Return the date the Virtual Database was created.
- * @return Date
- */
- Date getCreationDate();
-/**
- * Return the user name who create this Virtual Database.
- * @return String
- */
- String getCreatedBy();
-/**
- * Return the date the Virtual Database was updated.
- * @return Date
- */
- Date getUpdateDate();
-/**
- * Return the user name who update this version of the Virtual Database.
- * @return String
- */
- String getUpdatedBy();
-/**
- * Returns the DataTypeID's that exist in this virtual database.
- * @return Collection of the DataTypeID's contained in this VirtualDatabase
- */
- Collection getDataTypeIDs();
-/**
- * Update a VDB attribute. Only the attributes defined in <code>VirtualDatabase.ModifiableAttributes</code>
- * can be modefied.
- * @param attribute attribute to be updated.
- * @param value new value.
- */
- void update(String attribute, Object value);
-
- /**
- * Get this name of the VDB jar file.
- * @return the VDB's name; never null or zero-length
- */
- String getFileName();
-
- /**
- * Returns true if a WSDL is defined for this VDB
- * @return true if a WSDL is defined for this VDB
- */
- boolean hasWSDLDefined();
-
-/**
- * Defines the VDB attributes that can be modified.
- */
- public interface ModifiableAttributes{
- String DESCRIPTION = "description";
- }
-}
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseDoesNotExistException.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseDoesNotExistException.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseDoesNotExistException.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,79 +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.metadata.runtime.api;
-
-
-/**
- * Thrown when the VirtualDatabase is not found.
- */
-public class VirtualDatabaseDoesNotExistException extends VirtualDatabaseException {
-
- /**
- * No-arg costructor required by Externalizable semantics
- */
- public VirtualDatabaseDoesNotExistException() {
- super();
- }
-
- /**
- * Construct an instance with the message specified.
- *
- * @param message A message describing the exception
- */
- public VirtualDatabaseDoesNotExistException( String message ) {
- super( message );
- }
-
- /**
- * Construct an instance with the message and error code specified.
- *
- * @param message A message describing the exception
- * @param code The error code
- */
- public VirtualDatabaseDoesNotExistException( String code, String message ) {
- super( code, message );
- }
-
- /**
- * Construct an instance from a message and an exception to chain to this one.
- *
- * @param code A code denoting the exception
- * @param e An exception to nest within this one
- */
- public VirtualDatabaseDoesNotExistException( Exception e, String message ) {
- super( e, message );
- }
-
- /**
- * Construct an instance from a message and a code and an exception to
- * chain to this one.
- *
- * @param e An exception to nest within this one
- * @param message A message describing the exception
- * @param code A code denoting the exception
- */
- public VirtualDatabaseDoesNotExistException( Exception e, String code, String message ) {
- super( e, code, message );
- }
-}
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseID.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseID.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/metadata/runtime/api/VirtualDatabaseID.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,38 +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.metadata.runtime.api;
-
-
-/**
- * <p>The VirtualDatabaseID should uniquely identify a VirutalDatabase. This is accomplished when instantiating the class by passing the full name of the VirtualDatabase and the version. These 2 arguments uniquely identify a Virtual Database.</p>
- */
-public interface VirtualDatabaseID extends MetadataID {
-
-/**
- * Returns the version.
- * @return String
- */
- public String getVersion();
-
-}
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AbstractAuthorizationObjectEditor.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AbstractAuthorizationObjectEditor.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AbstractAuthorizationObjectEditor.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,691 +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.security.api;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import com.metamatrix.common.actions.AbstractObjectEditor;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
-import com.metamatrix.platform.admin.api.EntitlementMigrationReport;
-import com.metamatrix.platform.admin.api.PermissionTreeView;
-import com.metamatrix.platform.security.util.RolePermissionFactory;
-
-public abstract class AbstractAuthorizationObjectEditor extends AbstractObjectEditor {
- public final static long serialVersionUID = -3690038844414207808L;
-
-
- /**
- * Create an instance of this editor, and specify whether actions are to be created
- * during modifications. If actions are created, then each action is sent directly
- * to the destination at the time the action is created.
- * @param createActions flag specifying whether modification actions should be created
- * for each invocation to <code>modifyObject</code>
- */
- public AbstractAuthorizationObjectEditor( boolean createActions ) {
- super(createActions);
-
- if ( doCreateActions() ) {
- this.setDestination(new com.metamatrix.common.actions.BasicModificationActionQueue());
- }
- }
-
- /**
- * Default ctor creates actions.
- */
- public AbstractAuthorizationObjectEditor() {
- this(true);
- }
-
- // ----------------------------------------------------------------------------------
- // C R E A T E M E T H O D S
- // ----------------------------------------------------------------------------------
-
- /**
- * Create a new AuthorizationPolicy.
- * @param policyID the new policyID from which to create the policy (may not be null).
- * @return The newly created policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicyID</code> is null.
- */
- public AuthorizationPolicy createAuthorizationPolicy(AuthorizationPolicyID policyID) {
- if ( policyID == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0001));
- }
- AuthorizationPolicyID targetID = (AuthorizationPolicyID) verifyTargetClass(policyID, AuthorizationPolicyID.class);
- AuthorizationPolicy policy = new AuthorizationPolicy(targetID);
-
- createCreationAction(targetID, policy);
-
- return policy;
- }
-
- // ----------------------------------------------------------------------------------
- // D E L E T E M E T H O D S
- // ----------------------------------------------------------------------------------
-
- /**
- * Remove an <code>AuthorizationPolicy</code>.
- * @param policyID The target policy ID (may not be null).
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicyIC</code> is null.
- */
- public void remove( AuthorizationPolicyID policyID ) {
- if ( policyID == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0001));
- }
- AuthorizationPolicyID targetID = (AuthorizationPolicyID) verifyTargetClass(policyID, AuthorizationPolicyID.class);
-
- createDestroyAction(targetID, targetID);
-
- }
-
- // ----------------------------------------------------------------------------------
- // C L O N E M E T H O D S
- // ----------------------------------------------------------------------------------
-
- /**
- * Copy the <code>AuthorizationPermission</code>s from a source <code>AuthorizationPolicy</code>
- * to a target <code>AuthorizationPolicy</code> given an <code>AuthorizationRealm</code>.
- * @param targetPolicy The source policy for cloning.
- * @param sourcePerm The source permisison for cloning.
- * @param targetRealm The destination realm in which to place the permissions (may not be null).
- * @return The cloned policy.
- * @throws IllegalArgumentException if either the target <code>AuthorizationPolicy</code>
- * the source <code>AuthorizationPolicy</code> or the <code>AuthorizationRealm</code> is null.
- */
- public AuthorizationPolicy clonePermission(AuthorizationPolicy targetPolicy,
- AuthorizationPermission sourcePerm,
- AuthorizationRealm targetRealm) {
- if ( targetPolicy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( sourcePerm == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0003));
- }
- if ( targetRealm == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0004));
- }
-
- AuthorizationPolicy theTargetPolicy = (AuthorizationPolicy) verifyTargetClass(targetPolicy, AuthorizationPolicy.class);
- AuthorizationRealm newRealm = (AuthorizationRealm) verifyTargetClass(targetRealm, AuthorizationRealm.class);
-
- // Clone the permission
- AuthorizationPermission newPerm = null;
-
- try {
- newPerm = (AuthorizationPermission) sourcePerm.clone();
- } catch(CloneNotSupportedException e) {
- // They're all clonable but log anyway
- final Object[] params = { sourcePerm };
- final String msg = SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0005,params);
- LogManager.logError(LogConstants.CTX_AUTHORIZATION, e, msg );
- }
- newPerm.setRealm(newRealm);
-
- theTargetPolicy = this.addPermission(theTargetPolicy, newPerm);
-
- return theTargetPolicy;
- }
-
-
- /**
- * Copy the <code>Principals</code>s from a source <code>AuthorizationPolicy</code>
- * to a target <code>AuthorizationPolicy</code>.
- * @param sourcePolicy The source policy for cloning.
- * @param targetPolicy The source policy for cloning.
- * @return The cloned policy.
- * @throws IllegalArgumentException if either the target <code>AuthorizationPolicy</code>
- * the source <code>AuthorizationPolicy</code> or the <code>AuthorizationRealm</code> is null.
- */
- public AuthorizationPolicy clonePolicyPrincipals(AuthorizationPolicy sourcePolicy,
- AuthorizationPolicy targetPolicy) {
- return this.clonePolicyPrincipals(sourcePolicy, targetPolicy, null, null);
- }
-
- public AuthorizationPolicy clonePolicyPrincipals(AuthorizationPolicy sourcePolicy,
- AuthorizationPolicy targetPolicy, Set allPrincipals, EntitlementMigrationReport rpt) {
- if ( targetPolicy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( sourcePolicy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0006));
- }
-
- AuthorizationPolicy theSourcePolicy = (AuthorizationPolicy) verifyTargetClass(sourcePolicy, AuthorizationPolicy.class);
- AuthorizationPolicy theTargetPolicy = (AuthorizationPolicy) verifyTargetClass(targetPolicy, AuthorizationPolicy.class);
-
- Set oldPrincipals = theTargetPolicy.getPrincipals();
- if ( oldPrincipals.size() > 0 ) {
- theTargetPolicy = removeAllPrincipals(theTargetPolicy);
- }
-
- // Clone the Principals
- Set principals = new HashSet(theSourcePolicy.getPrincipals());
-
- //filter principals
- //TODO: add reporting for principals
- if (allPrincipals != null) {
- for (Iterator i = principals.iterator(); i.hasNext();) {
- MetaMatrixPrincipalName principal = (MetaMatrixPrincipalName)i.next();
- if (!allPrincipals.contains(principal.getName())) {
- i.remove();
- LogManager.logWarning(LogConstants.CTX_AUTHORIZATION, SecurityPlugin.Util.getString("AbstractAuthorizationObjectEditor.missing_principal", new Object[] {sourcePolicy.getAuthorizationPolicyID().getDisplayName(), principal.getName()})); //$NON-NLS-1$
- }
- }
- }
-
- theTargetPolicy = this.addAllPrincipals(theTargetPolicy, principals);
-
- return theTargetPolicy;
- }
-
- /**
- * Set the description on the policy.
- * @param policy The target policy (may not be null).
- * @param description The new policy description may be null or empty.
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy setDescription( AuthorizationPolicy policy, String description ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
- AuthorizationPolicyID policyID = thePolicy.getAuthorizationPolicyID();
- // Keep old value for undo
- String oldDescription = policyID.getDescription();
-
- createExchangeAction(policyID,
- AuthorizationModel.Attribute.DESCRIPTION,
- oldDescription,
- description );
- policyID.setDescription(description);
-
- return thePolicy;
- }
-
- /**
- * Set the description on the policy.
- * @param policyID The target policy (may not be null).
- * @param description The new policy description may be null or empty.
- * @return The modified policyID.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicyID setDescription( AuthorizationPolicyID policyID, String description ) {
- if ( policyID == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0001));
- }
-
- AuthorizationPolicyID thePolicyID = (AuthorizationPolicyID) verifyTargetClass(policyID, AuthorizationPolicyID.class);
- // Keep old value for undo
- String oldDescription = thePolicyID.getDescription();
-
- createExchangeAction(thePolicyID,
- AuthorizationModel.Attribute.DESCRIPTION,
- oldDescription,
- description );
- thePolicyID.setDescription(description);
-
- return thePolicyID;
- }
-
- /**
- * Add a principal to the policy.
- * @param policy The target policy (may not be null).
- * @param principal The principal to add to the policy (no action taken if null).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy addPrincipal( AuthorizationPolicy policy, MetaMatrixPrincipalName principal ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( principal == null ) {
- return policy;
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
-
- createAddAction(thePolicy.getAuthorizationPolicyID(), AuthorizationModel.Attribute.PRINCIPAL_NAME, principal );
-
- thePolicy.addPrincipal(principal);
-
- return thePolicy;
- }
-
- /**
- * Add a set of principals to the policy.
- * @param policy The target policy (may not be null).
- * @param principals The set of principals to add to the policy (no action taken if null or empty).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy addAllPrincipals( AuthorizationPolicy policy, Set principals ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( principals == null || principals.size() == 0 ) {
- return policy;
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
-
- createAddAction(thePolicy.getAuthorizationPolicyID(),
- AuthorizationModel.Attribute.PRINCIPAL_SET,
- principals);
-
- thePolicy.addAllPrincipals(principals);
-
- return thePolicy;
- }
-
- /**
- * Remove a principal from the policy.
- * @param policy The target policy (may not be null).
- * @param principal The principal to remove from the policy (no action taken if null).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy removePrincipal( AuthorizationPolicy policy, MetaMatrixPrincipalName principal ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( principal == null ) {
- return policy;
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
-
- Set principals = thePolicy.getPrincipals();
- if ( ! principals.contains(principal) ) {
- return policy;
- }
-
- createRemoveAction(thePolicy.getAuthorizationPolicyID(),
- AuthorizationModel.Attribute.PRINCIPAL_NAME,
- principal );
-
- thePolicy.removePrincipal(principal);
-
- return thePolicy;
- }
-
- /**
- * Remove a set of principals from the policy.
- * @param policy The target policy (may not be null).
- * @param principals The set of principals to remove from the policy (no action taken if null or empty).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy removePrincipals( AuthorizationPolicy policy, Set principals ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( principals == null || principals.size() == 0 ) {
- return policy;
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
-
- Set oldPrincipals = thePolicy.getPrincipals();
- oldPrincipals.removeAll(principals);
-
- createRemoveAction(thePolicy.getAuthorizationPolicyID(),
- AuthorizationModel.Attribute.PRINCIPAL_SET,
- principals);
-
- // Set the policy's prinicpals to new ref.
- thePolicy.setPrincipals(oldPrincipals);
-
- return thePolicy;
- }
-
- /**
- * Remove all of the principals from the policy.
- * @param policy The target policy (may not be null).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy removeAllPrincipals( AuthorizationPolicy policy ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
- // Keep old value for undo
- Set oldPrincipals = thePolicy.getPrincipals();
-
- if ( oldPrincipals.size() == 0 ) {
- return policy;
- }
- createRemoveAction(thePolicy.getAuthorizationPolicyID(),
- AuthorizationModel.Attribute.PRINCIPAL_SET,
- oldPrincipals);
-
- // Set the policy's prinicpals to empty set.
- thePolicy.setPrincipals(Collections.EMPTY_SET);
-
- return thePolicy;
- }
-
- /**
- * Modifies permissions belonging to the given <code>AuthorizationPolicy</code>. All are found in
- * the given tree view of <code>PermissionDataNode</code>s.<br></br>
- * <strong>Note that if <code>showHidden</code> is set to <code>false</code> in <code>treeView</code>,
- * permissions WILL NOT be modified in those descendants.</strong>
- * @param treeView The permission tree view containg the modified nodes.
- * @param policy The <code>AuthorizationPolicy</code>, possibly new, on which to apply the new permissions.
- * @return The set of <code>PermissionDataNode</code>s that were modified.
- */
- public abstract Collection modifyPermissions(PermissionTreeView treeView, AuthorizationPolicy policy);
-
- /**
- * Add an <code>AuthorizationPermission</code> to the policy.
- * @param policy The target policy (may not be null).
- * @param permission The permission to add to the policy (no action taken if null).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy addPermission( AuthorizationPolicy policy, AuthorizationPermission permission ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( permission == null ) {
- return policy;
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
-
- // Don't allow creation of roles
- AuthorizationRealm realm = permission.getRealm();
- if ( realm.getRealmName().equals(RolePermissionFactory.getRealmName()) ) {
- return thePolicy;
- }
-
- // If AuthorizationActions == NONE, just remove existing perm on this resource
- String resourceToRemove = null;
- if ( permission.getActions().equals(StandardAuthorizationActions.NONE) ) {
- resourceToRemove = permission.getResourceName();
- }
-
- Iterator itr = thePolicy.iterator();
- while ( itr.hasNext() ) {
- AuthorizationPermission tmpPerm = (AuthorizationPermission) itr.next();
-
- // See if there's a perm to remove...
- if ( resourceToRemove != null && tmpPerm.getResourceName().equals(resourceToRemove) ) {
- thePolicy = removePermission(thePolicy, tmpPerm);
- break;
- }
-
- // Don't do anything if permission is already present.
- if ( permission.equals(tmpPerm) ) {
- return thePolicy;
- }
- }
-
- createAddAction(thePolicy.getAuthorizationPolicyID(), AuthorizationModel.Attribute.PERMISSION, permission );
-
- thePolicy.addPermission(permission);
-
- return thePolicy;
- }
-
- /**
- * Add a set of <code>AuthorizationPermission</code>s to the policy.
- * @param policy The target policy (may not be null).
- * @param permissions The set of permissions to add to the policy (no action taken if null or empty).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- protected AuthorizationPolicy addAllPermissions( AuthorizationPolicy policy, Set permissions ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( permissions == null || permissions.size() == 0 ) {
- return policy;
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
-
- Set permsToRemove = new HashSet();
-
- Iterator permItr = permissions.iterator();
- while ( permItr.hasNext() ) {
- AuthorizationPermission perm = (AuthorizationPermission) permItr.next();
- // If any new perm has AuthorizationActions == NONE, just remove existing perm from policy
- if ( perm.getActions().equals(StandardAuthorizationActions.NONE) ) {
- permsToRemove.add(perm);
- }
-
- // Don't allow creation of roles
- AuthorizationRealm realm = perm.getRealm();
- if ( realm.getRealmName().equals(RolePermissionFactory.getRealmName()) ) {
- return thePolicy;
- }
- }
-
- // Remove permissions whose Actions are being set to NONE
- if ( permsToRemove.size() > 0 ) {
- thePolicy = removePermissions(thePolicy, permsToRemove);
- }
-
- // Keep old value for undo
- AuthorizationPermissions oldPermissions = thePolicy.getAuthorizationPermissions();
- AuthorizationPermissions newPermissions = new AuthorizationPermissionsImpl();
- newPermissions.add(permissions);
- if ( oldPermissions != null && oldPermissions.size() > 0 ) {
- // Don't add any that are already in there
- newPermissions.removeAll(oldPermissions);
- }
-// DEBUG:
-/*if ( newPermissions.size() > 0 ) {
- System.out.println(" *** addAllPermissions: adding " + newPermissions.size() + " permissions" );
- Iterator itr = newPermissions.iterator();
- while ( itr.hasNext() ) {
- System.out.println(" " + itr.next());
- }
-} else {
- System.out.println(" *** addAllPermissions: adding NO permissions");
-}*/
-
- // NOTE: The Set of permissions has been converted to an AuthorizationPermissionsImpl obj.
- // The arg[0] of the action must be cast to that type.
- createAddAction(thePolicy.getAuthorizationPolicyID(), AuthorizationModel.Attribute.PERMISSIONS, newPermissions );
-
- thePolicy.addAllPermissions(newPermissions);
-
- return thePolicy;
- }
-
- /**
- * Remove an <code>AuthorizationPermission</code> from the policy.
- * @param policy The target policy (may not be null).
- * @param permission The permission to remove from the policy (no action taken if null).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy removePermission( AuthorizationPolicy policy, AuthorizationPermission permission ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( permission == null ) {
- return policy;
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
- // Keep old value for undo
- AuthorizationPermission oldPermission = null;
- AuthorizationPermissions oldPermissions = thePolicy.getAuthorizationPermissions();
- Iterator permissionItr = oldPermissions.iterator();
- while ( permissionItr.hasNext() ) {
- AuthorizationPermission tmpPermission = (AuthorizationPermission) permissionItr.next();
- if ( permission.equals( tmpPermission ) ) {
- oldPermission = tmpPermission;
- break;
- }
- }
-
- // If permission was not present, do nothing.
- if ( oldPermission == null ) {
- return policy;
- }
-
- createRemoveAction(thePolicy.getAuthorizationPolicyID(),
- AuthorizationModel.Attribute.PERMISSION,
- oldPermission);
-
- thePolicy.removePermission(permission);
-
- return thePolicy;
- }
-
- /**
- * Remove a <code>Set</code> of <code>AuthorizationPermission</code>s from the policy.
- * @param policy The target policy (may not be null).
- * @param permissions The set of permissions to remove from the policy (no action taken if null or empty).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy removePermissions( AuthorizationPolicy policy, Set permissions ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( permissions == null || permissions.size() == 0 ) {
- return policy;
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
- // Some/All of these will be removed
- AuthorizationPermissions oldPermissions = thePolicy.getAuthorizationPermissions();
-
-// DEBUG:
-/*System.out.println(" *** removePermissions: Old perms " + oldPermissions.size());
-Iterator itr = oldPermissions.iterator();
-while ( itr.hasNext() ) {
- System.out.println(" Old perm: " + itr.next());
-}*/
-// DEBUG:
-/*System.out.println(" *** removePermissions: Perms to remove");
-itr = permissions.iterator();
-while ( itr.hasNext() ) {
- System.out.println(" Removing perm: " + itr.next());
-}*/
- oldPermissions.removeAll(permissions);
- // Now left with subset of old permissions
-// DEBUG:
-/*System.out.println(" *** removePermissions: Perms left:");
-itr = oldPermissions.iterator();
-while ( itr.hasNext() ) {
- System.out.println(" Leaving perm: " + itr.next());
-}*/
-
-// DEBUG:
-//System.out.println(" *** removePermissions: New size: " + oldPermissions.size() + "\n");
-
- createRemoveAction(thePolicy.getAuthorizationPolicyID(),
- AuthorizationModel.Attribute.PERMISSION_SET,
- permissions );
-
- thePolicy.setPermissions(oldPermissions);
-
- return thePolicy;
- }
-
- /**
- * Remove <emph>ALL</emph> <code>AuthorizationPermission</code>s from the
- * given <code>AuthorizationPolicy</code> that have the given resource and are
- * in the given <code>AuthorizationRealm</code>.
- * @param policy The target policy (may not be null).
- * @param resource The resource for which permissions will be removed.
- * @param realm The realm that permissions with given resource must belong to
- * to be removed.
- * @return The modified policy with permissions removed.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> or
- * <code>AuthorizationRealm</code> is null or if the resource is null or empty.
- */
- public AuthorizationPolicy removePermissions( AuthorizationPolicy policy, String resource, AuthorizationRealm realm ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( resource == null || resource.trim().length() == 0 ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0007));
- }
- if ( realm == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0008));
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
- AuthorizationRealm theRealm = (AuthorizationRealm) verifyTargetClass(realm, AuthorizationRealm.class);
-
- // Find candidate permissions for removal
- Set removePerms = new HashSet();
- Iterator permItr = thePolicy.iterator();
- while ( permItr.hasNext() ) {
- AuthorizationPermission perm = (AuthorizationPermission) permItr.next();
-
- if ( perm.getResourceName().equals(resource) && perm.getRealm().equals(theRealm) ) {
- removePerms.add(perm);
- }
- }
-
- // Remove the permissions
- if ( removePerms.size() > 0 ) {
- thePolicy = this.removePermissions(thePolicy, removePerms);
- }
-
- return thePolicy;
- }
-
- /**
- * Remove all of the permissions from the policy.
- * @param policy The target policy (may not be null).
- * @return The modified policy.
- * @throws IllegalArgumentException if the target <code>AuthorizationPolicy</code> is null.
- */
- public AuthorizationPolicy removeAllPermissions( AuthorizationPolicy policy ) {
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
-
- AuthorizationPolicy thePolicy = (AuthorizationPolicy) verifyTargetClass(policy, AuthorizationPolicy.class);
- // Keep old value for undo
- AuthorizationPermissions oldPermissions = new AuthorizationPermissionsImpl(thePolicy.getAuthorizationPermissions());
- if ( oldPermissions.size() == 0 ) {
- return thePolicy;
- }
-
- createRemoveAction(thePolicy.getAuthorizationPolicyID(),
- AuthorizationModel.Attribute.PERMISSIONS,
- oldPermissions);
-
- // Sets the policy's permissions to new empty ref.
- thePolicy.removePermissions();
-
- return thePolicy;
- }
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationModel.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationModel.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationModel.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,88 +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.security.api;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.metamatrix.common.actions.AttributeDefinition;
-import com.metamatrix.common.actions.ClassDefinition;
-
-public class AuthorizationModel {
-
- public static class Class {
- public static final ClassDefinition POLICY = new ClassDefinition( AuthorizationPolicy.class );
- public static final ClassDefinition POLICYID = new ClassDefinition( AuthorizationPolicyID.class );
- }
-
- public static class Attribute {
- // AuthorizationPolicy
- public static final AttributeDefinition DESCRIPTION = new AttributeDefinition(0,"DESCRIPTION"); //$NON-NLS-1$
- public static final AttributeDefinition PRINCIPAL_NAME = new AttributeDefinition(1,"PRINCIPAL_NAME"); //$NON-NLS-1$
- public static final AttributeDefinition PRINCIPAL_SET = new AttributeDefinition(2,"PRINCIPAL_SET"); //$NON-NLS-1$
- public static final AttributeDefinition PERMISSION = new AttributeDefinition(3,"PERMISSION"); //$NON-NLS-1$
- public static final AttributeDefinition PERMISSIONS = new AttributeDefinition(4,"PERMISSIONS"); //$NON-NLS-1$
- public static final AttributeDefinition PERMISSION_SET = new AttributeDefinition(5,"PERMISSION_SET"); //$NON-NLS-1$
- }
-
- private static int ATTRIBUTE_DEFINITION_COUNT = 6;
- private static Map classLookup = new HashMap(3);
- private static Map classLookupByIDClass = new HashMap();
- private static AttributeDefinition[] attributeDefinitions = new AttributeDefinition[ATTRIBUTE_DEFINITION_COUNT];
-
- static {
- // AuthorizationPolicy
- classLookup.put( Class.POLICY.getClassObject(), Class.POLICY );
-
- classLookupByIDClass.put( Class.POLICYID.getClassObject(), AuthorizationPolicyID.class );
-
- addAttributeToLookupMap( Attribute.DESCRIPTION );
- addAttributeToLookupMap( Attribute.PRINCIPAL_NAME );
- addAttributeToLookupMap( Attribute.PRINCIPAL_SET );
- addAttributeToLookupMap( Attribute.PERMISSION );
- addAttributeToLookupMap( Attribute.PERMISSIONS );
- addAttributeToLookupMap( Attribute.PERMISSION_SET );
-
- }
-
- public static ClassDefinition getClassDefinition( Class c ) {
- return (ClassDefinition) classLookup.get(c);
- }
- public static ClassDefinition getClassDefinition( Object obj ) {
- return (ClassDefinition) classLookup.get(obj.getClass());
- }
- public static ClassDefinition getClassDefinition( AuthorizationPolicyID policyID ) {
- return (ClassDefinition) classLookupByIDClass.get(policyID.getClass());
- }
- public static AttributeDefinition getAttributeDefinition( int code ) {
- if ( code < 0 || code >= ATTRIBUTE_DEFINITION_COUNT ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0009, code));
- }
- return attributeDefinitions[ code ];
- }
-
- private static void addAttributeToLookupMap( AttributeDefinition attribute ) {
- attributeDefinitions[ attribute.getCode() ] = attribute;
- }
-}
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationObjectEditor.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationObjectEditor.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationObjectEditor.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,255 +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.security.api;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
-import com.metamatrix.platform.admin.api.AuthorizationEditor;
-import com.metamatrix.platform.admin.api.EntitlementMigrationReport;
-import com.metamatrix.platform.admin.api.PermissionDataNode;
-import com.metamatrix.platform.admin.api.PermissionTreeView;
-import com.metamatrix.platform.admin.apiimpl.PermissionDataNodeImpl;
-
-/**
- * Editor allows automatic creation of individual {@link com.metamatrix.common.actions.Actions}
- * in an enforcable way when making modifications to Authorizations.<br></br>
- * The actions can be submited to the Authorization Service to execute them in a transaction.
- */
-public class AuthorizationObjectEditor extends AbstractAuthorizationObjectEditor implements AuthorizationEditor {
-
- public final static long serialVersionUID = 5799168432068176908L;
-
- /**
- * Create an instance of this editor, and specify whether actions are to be created
- * during modifications. If actions are created, then each action is sent directly
- * to the destination at the time the action is created.
- * @param createActions flag specifying whether modification actions should be created
- * for each invocation to <code>modifyObject</code>
- */
- public AuthorizationObjectEditor( boolean createActions ) {
- super(createActions);
- }
-
- /**
- * Default ctor creates actions.
- */
- public AuthorizationObjectEditor() {
- super(true);
- }
-
- // ----------------------------------------------------------------------------------
- // C L O N E M E T H O D S
- // ----------------------------------------------------------------------------------
-
- /**
- * Copy the <code>AuthorizationPermission</code>s from a source <code>AuthorizationPolicy</code>
- * to a target <code>AuthorizationPolicy</code> given an <code>AuthorizationRealm</code>.
- * @param sourcePolicy The source policy for cloning.
- * @param targetPolicy The source policy for cloning.
- * @param targetRealm The destination realm in which to place the permissions (may not be null).
- * @param allPaths Skip clone of any permission whose resource is not in this set. This set is
- * comprised of all allowable resources in the target realm.
- * @return The cloned policy.
- * @throws IllegalArgumentException if either the target <code>AuthorizationPolicy</code>
- * the source <code>AuthorizationPolicy</code> or the <code>AuthorizationRealm</code> is null.
- */
- public AuthorizationPolicy clonePolicyPermissions(AuthorizationPolicy sourcePolicy,
- AuthorizationPolicy targetPolicy,
- AuthorizationRealm targetRealm,
- Set allPaths, EntitlementMigrationReport rpt) {
- if ( targetPolicy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0002));
- }
- if ( sourcePolicy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0006));
- }
- if ( targetRealm == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0004));
- }
-
- // Clone the permissions
- Set permissions = new HashSet();
- Iterator permItr = sourcePolicy.iterator();
- while ( permItr.hasNext() ) {
- AuthorizationPermission originalPerm = (AuthorizationPermission) permItr.next();
- String resourcePath = originalPerm.getResourceName();
-
- if ( BasicAuthorizationPermission.isRecursiveResource(resourcePath) ) {
- resourcePath = BasicAuthorizationPermission.removeRecursion(resourcePath);
- }
-
- if ( allPaths.contains(resourcePath) ) {
- // Fill in entry values
- if (rpt != null) {
- rpt.addResourceEntry(SecurityPlugin.Util.getString("AuthorizationServiceImpl.Succeeded_migration"), //$NON-NLS-1$
- resourcePath,
- sourcePolicy.getAuthorizationPolicyID().getDisplayName(),
- targetPolicy.getAuthorizationPolicyID().getDisplayName(),
- StandardAuthorizationActions.getActionsString(originalPerm.getActions().getValue()),
- SecurityPlugin.Util.getString("AuthorizationServiceImpl.Migrated")); //$NON-NLS-1$
- }
-
- try {
- // Clone for saftey
- AuthorizationPermission newPerm = (AuthorizationPermission) originalPerm.clone();
- newPerm.setRealm(targetRealm);
- permissions.add(newPerm);
- } catch(CloneNotSupportedException e) {
- // They're all clonable but log anyway
- final Object[] params = { originalPerm };
- final String msg = SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0005, params);
- LogManager.logError(LogConstants.CTX_AUTHORIZATION, e, msg);
- }
- } else {
- if (rpt != null) {
- rpt.addResourceEntry(SecurityPlugin.Util.getString("AuthorizationServiceImpl.Failed_migration"), //$NON-NLS-1$
- resourcePath,
- sourcePolicy.getAuthorizationPolicyID().getDisplayName(),
- "", //$NON-NLS-1$
- StandardAuthorizationActions.getActionsString(originalPerm.getActions().getValue()),
- SecurityPlugin.Util.getString("AuthorizationServiceImpl.The_resource_for_this_permission_does_not_exist_in_the_target_VDB.")); //$NON-NLS-1$
- }
-
- final Object[] params = { originalPerm };
- final String msg = SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0011, params);
- LogManager.logWarning(LogConstants.CTX_AUTHORIZATION, msg);
- }
-
- }
- return this.addAllPermissions(targetPolicy, permissions);
- }
-
- // ----------------------------------------------------------------------------------
- // M O D I F I C A T I O N M E T H O D S
- // ----------------------------------------------------------------------------------
-
- /**
- * Modifies permissions belonging to the given <code>AuthorizationPolicy</code>. All are found in
- * the given tree view of <code>PermissionDataNode</code>s.<br></br>
- * <strong>Note that if <code>showHidden</code> is set to <code>false</code> in <code>treeView</code>,
- * permissions WILL NOT be modified in those descendants.</strong>
- * @param treeView The permission tree view containg the modified nodes.
- * @param policy The <code>AuthorizationPolicy</code>, possibly new, on which to apply the new permissions.
- * @return The set of <code>PermissionDataNode</code>s that were modified.
- */
- public Collection modifyPermissions(PermissionTreeView treeView, AuthorizationPolicy policy) {
- // Make sure it's a valid policy
- if ( policy == null ) {
- throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0012));
- }
- AuthorizationPolicyID thePolicyID = policy.getAuthorizationPolicyID();
- AuthorizationRealm realm = new AuthorizationRealm(thePolicyID.getVDBName(), thePolicyID.getVDBVersionString());
-
- Set permissionsToAdd = new HashSet();
- Set permissionsToRemove = new HashSet();
- List modifiedNodes = treeView.getModified();
- Set effectedNodes = new HashSet();
- AuthorizationPermissions currentPerms = policy.getAuthorizationPermissions();
-
- // Create permissions for all modified nodes in tree
- BasicAuthorizationPermissionFactory permFactory = new BasicAuthorizationPermissionFactory();
-
- LogManager.logTrace(LogConstants.CTX_AUTHORIZATION,"modifyPermissions: Starting..."); //$NON-NLS-1$
- Iterator nodeItr = modifiedNodes.iterator();
- while ( nodeItr.hasNext() ) {
- PermissionDataNodeImpl aNode = (PermissionDataNodeImpl) nodeItr.next();
- LogManager.logTrace(LogConstants.CTX_AUTHORIZATION,"modifyPermissions: Effected node: " + aNode); //$NON-NLS-1$
- AuthorizationActions theActions = aNode.getActions();
- String resourceName = aNode.getResourceName();
- AuthorizationPermission newPerm = null;
- AuthorizationPermission oldPerm = null;
-
- boolean isGroupNode = aNode.isGroupNode();
-
- if ( aNode.isLeafNode() || isGroupNode ) {
- LogManager.logTrace(LogConstants.CTX_AUTHORIZATION,"modifyPermissions: LEAF or GROUP - actions <" + theActions + ">"); //$NON-NLS-1$ //$NON-NLS-2$
- // Remove old permission on this node, if it exists
- oldPerm = getExistingPermission(aNode, policy);
- if ( oldPerm != null ) {
- LogManager.logTrace(LogConstants.CTX_AUTHORIZATION,
- "modifyPermissions: Removing permission: " + oldPerm); //$NON-NLS-1$
- currentPerms.remove(oldPerm);
- permissionsToRemove.add(oldPerm);
- effectedNodes.add(oldPerm);
- }
- if ( ! theActions.equals(StandardAuthorizationActions.NONE) ) {
-
- if ( aNode.isLeafNode() ) {
- LogManager.logTrace(LogConstants.CTX_AUTHORIZATION,"modifyPermissions: Creating LEAF permission."); //$NON-NLS-1$
-
- // Create leaf permission
- newPerm = permFactory.create(resourceName, realm, theActions);
- LogManager.logTrace(LogConstants.CTX_AUTHORIZATION,"modifyPermissions: Adding new ELEMENT perm: <" + newPerm.getResourceName() + " - " + newPerm.getActions() + ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- permissionsToAdd.add(newPerm);
-
- } else if (isGroupNode) {
- LogManager.logTrace(LogConstants.CTX_AUTHORIZATION,"modifyPermissions: Creating GROUP " + theActions + " permission."); //$NON-NLS-1$ //$NON-NLS-2$
-
- // Create new permissions
- newPerm = permFactory.create(resourceName, realm, theActions);
- LogManager.logTrace(LogConstants.CTX_AUTHORIZATION,"modifyPermissions: Adding new GROUP perm: <" + newPerm.getResourceName() + " - " + newPerm.getActions() + ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- permissionsToAdd.add(newPerm);
- }
- }
-
- // Add this node as effected
-// effectedNodes.add(aNode);
- }
-
- // Unmodify this node
- aNode.setModified(false, false);
- } // end modified nodes itr
-
- // Remove all old modified permissions
- this.removePermissions(policy, permissionsToRemove);
-
- // Add new/modified permissions
- this.addAllPermissions(policy, permissionsToAdd);
-
- return effectedNodes;
- }
-
- // ----------------------------------------------------------------------------------
- // H E L P E R M E T H O D S
- // ----------------------------------------------------------------------------------
-
- private AuthorizationPermission getExistingPermission(PermissionDataNode aNode, AuthorizationPolicy policy) {
- AuthorizationPermission permToRemove = null;
- String resourceName = aNode.getResourceName();
- AuthorizationResource resource = new DataAccessResource(resourceName);
- permToRemove = policy.findPermissionWithResource(resource);
- return permToRemove;
- }
-
-}
-
-
-
Modified: trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPermissionsImpl.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPermissionsImpl.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPermissionsImpl.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -27,6 +27,7 @@
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;
+import java.util.concurrent.locks.ReentrantLock;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.LogConstants;
@@ -47,34 +48,32 @@
*/
public final class AuthorizationPermissionsImpl implements AuthorizationPermissions {
- private Set thePermissions;
+ private static final long serialVersionUID = -5223347499647193459L;
+
+ private Set<AuthorizationPermission> thePermissions = new HashSet<AuthorizationPermission>();
// Used to provide permissions collection synchronization
- private Object lockObj = new Object();
+ private ReentrantLock lockObj = new ReentrantLock();
- private boolean readOnly;
+ private boolean readOnly = false;
- /**
- * Creates a new AuthorizationPermissionsImpl object containing no AuthorizationPermission objects.
- */
public AuthorizationPermissionsImpl() {
- this.readOnly = false;
- this.thePermissions = new HashSet();
+
}
-
/**
* Create a new AuthorizationPermissionsImpl object that is a copy of the original.
* Make a deep copy of the orig.
* @param orig The original to be copied.
*/
public AuthorizationPermissionsImpl( AuthorizationPermissions orig ) {
- this();
- synchronized (this.lockObj) {
+
+ lockObj.lock();
+ try {
Iterator permItr = orig.iterator();
while ( permItr.hasNext() ) {
AuthorizationPermission aPerm = (AuthorizationPermission) permItr.next();
if ( aPerm != null ) {
try {
- this.thePermissions.add(aPerm.clone());
+ this.thePermissions.add((AuthorizationPermission)aPerm.clone());
} catch ( CloneNotSupportedException e ) {
// They're all clonable but log anyway
final Object[] params = { aPerm };
@@ -84,6 +83,8 @@
}
}
}
+ } finally {
+ lockObj.unlock();
}
}
@@ -121,8 +122,11 @@
}
boolean result = false;
if ( permission != null ) {
- synchronized (this.lockObj) {
+ lockObj.lock();
+ try {
result = this.thePermissions.add(permission);
+ } finally {
+ lockObj.unlock();
}
}
return result;
@@ -177,8 +181,11 @@
*/
public boolean remove(AuthorizationPermission permission) {
boolean result = false;
- synchronized (this.lockObj) {
+ lockObj.lock();
+ try {
result = this.thePermissions.remove(permission);
+ } finally {
+ lockObj.unlock();
}
return result;
}
@@ -225,8 +232,11 @@
*/
public Iterator iterator() {
Iterator permItr = Collections.EMPTY_SET.iterator();
- synchronized (this.lockObj) {
+ lockObj.lock();
+ try {
permItr = this.thePermissions.iterator();
+ } finally {
+ lockObj.unlock();
}
return permItr;
}
@@ -296,13 +306,16 @@
*/
private boolean addPermissions(Iterator permIter) {
boolean result = false;
- synchronized (this.lockObj) {
+ lockObj.lock();
+ try {
while ( permIter.hasNext() ) {
AuthorizationPermission aPerm = (AuthorizationPermission) permIter.next();
if ( aPerm != null && this.thePermissions.add(aPerm) && !result ) {
result = true;
}
}
+ } finally {
+ lockObj.unlock();
}
return result;
}
@@ -316,13 +329,16 @@
*/
private boolean removePermissions(Iterator permIter) {
boolean result = false;
- synchronized (this.lockObj) {
+ lockObj.lock();
+ try {
while ( permIter.hasNext() ) {
AuthorizationPermission aPerm = (AuthorizationPermission) permIter.next();
if ( aPerm != null && this.thePermissions.remove(aPerm) && !result ) {
result = true;
}
}
+ } finally {
+ lockObj.unlock();
}
return result;
}
Copied: trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java (from rev 1899, branches/JCA/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java)
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java (rev 0)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -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.platform.security.api;
+
+import java.util.Collection;
+
+public class AuthorizationPoliciesHolder {
+ private Collection<AuthorizationPolicy> policies;
+
+ public void setAuthorizationPolicies(Collection<AuthorizationPolicy> policies) {
+ this.policies = policies;
+ }
+
+ public Collection<AuthorizationPolicy> getAuthorizationPolicies(){
+ return this.policies;
+ }
+}
Modified: trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPolicy.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPolicy.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPolicy.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -38,10 +38,12 @@
*/
public class AuthorizationPolicy implements Comparable, Serializable {
- /**
+ private static final long serialVersionUID = -4542635173812413914L;
+
+ /**
* Contains principal name
*/
- private Set principals;
+ private Set<MetaMatrixPrincipalName> principals;
private AuthorizationPermissions permissions;
@@ -56,7 +58,7 @@
throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0001));
}
this.authorizationPolicyID = id;
- this.principals = new LinkedHashSet();
+ this.principals = new LinkedHashSet<MetaMatrixPrincipalName>();
this.permissions = new AuthorizationPermissionsImpl();
}
@@ -67,12 +69,12 @@
* @param principals the set of <code>MetaMatrixPrincipalName</code>s to which this policy applies.
* @param permissions the permissions that define the resource access for this policy.
*/
- public AuthorizationPolicy( AuthorizationPolicyID id, Set principals, Set permissions ) {
+ public AuthorizationPolicy( AuthorizationPolicyID id, Set<MetaMatrixPrincipalName> principals, Set permissions ) {
this.authorizationPolicyID = id;
if ( principals != null ) {
- this.principals = new LinkedHashSet(principals);
+ this.principals = new LinkedHashSet<MetaMatrixPrincipalName>(principals);
} else {
- this.principals = new LinkedHashSet();
+ this.principals = new LinkedHashSet<MetaMatrixPrincipalName>();
}
this.permissions = new AuthorizationPermissionsImpl();
this.permissions.add(permissions);
@@ -84,7 +86,7 @@
*/
public AuthorizationPolicy( AuthorizationPolicy orig ) {
this.authorizationPolicyID = orig.authorizationPolicyID;
- this.principals = new LinkedHashSet( orig.principals );
+ this.principals = new LinkedHashSet<MetaMatrixPrincipalName>( orig.principals );
this.permissions = new AuthorizationPermissionsImpl();
Iterator iter = orig.iterator();
while ( iter.hasNext() ) {
@@ -172,7 +174,7 @@
* @return the set of <code>MetaMatrixPrincipalName</code>s to which this
* policy applies; never null but possibly empty
*/
- public Set getPrincipals() {
+ public Set<MetaMatrixPrincipalName> getPrincipals() {
return principals;
}
@@ -387,38 +389,6 @@
// Compare policy IDs
return (obj1.hashCode() == obj2.hashCode()) ? 0 :
obj1.authorizationPolicyID.compareTo(obj2.authorizationPolicyID);
-
-// JPC 04/25/03 - PolicyIDs are unique so doesn't seem like we need to compare all the rest of this stuff...
-// // Compare policy IDs
-// int compVal = AuthorizationPolicyID.compare(obj1.authorizationPolicyID, obj2.authorizationPolicyID);
-//
-// // Compare principals
-// if ( compVal == 0 ) {
-// compVal += obj1.principals.equals(obj2.principals) ? 0 : -1;
-// }
-//
-// // Compare permissions -
-// // One must imply all of the other AND other must imply all of the one
-// Iterator permItr = obj2.permissions.iterator();
-// while ( permItr.hasNext() && compVal == 0 ) {
-// AuthorizationPermission perm = (AuthorizationPermission) permItr.next();
-// try {
-// compVal += obj1.permissions.implies(perm) ? 0 : -1;
-// } catch ( MetaBaseResourceNotResolvedException e ) {
-// // Do nothing
-// }
-// }
-// permItr = obj1.permissions.iterator();
-// while ( permItr.hasNext() && compVal == 0 ) {
-// AuthorizationPermission perm = (AuthorizationPermission) permItr.next();
-// try {
-// compVal += obj2.permissions.implies(perm) ? 0 : -1;
-// } catch ( MetaBaseResourceNotResolvedException e ) {
-// // Do nothing
-// }
-// }
-//
-// return compVal;
}
// =========================================================================
@@ -453,9 +423,9 @@
* this policy will apply to no principals.
* @param principals the new set of <code>MetaMatrixPrincipalName</code>s to which this policy applies.
*/
- public void setPrincipals(Set principals) {
+ public void setPrincipals(Set<MetaMatrixPrincipalName> principals) {
if ( principals != null ) {
- this.principals = new LinkedHashSet(principals);
+ this.principals = new LinkedHashSet<MetaMatrixPrincipalName>(principals);
} else {
this.principals.clear();
}
@@ -542,7 +512,7 @@
* @return true if this policy changed as a result of the additions.
* @throws IllegalArgumentException if the specified set of principals is null or if the set contains a null value.
*/
- public boolean addAllPrincipals(Set newPrincipals) {
+ public boolean addAllPrincipals(Set<MetaMatrixPrincipalName> newPrincipals) {
if ( newPrincipals == null ) {
throw new IllegalArgumentException(SecurityPlugin.Util.getString(SecurityMessagesKeys.SEC_API_0022));
}
Modified: trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPolicyFactory.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPolicyFactory.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPolicyFactory.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -42,6 +42,7 @@
import org.jdom.input.DOMBuilder;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
+import org.teiid.adminapi.AdminRoles;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -57,7 +58,7 @@
*/
public class AuthorizationPolicyFactory {
- private static final String GROUP = "group"; //$NON-NLS-1$
+ private static final String ROLE = "role"; //$NON-NLS-1$
private static final String PRINCIPALS = "principals"; //$NON-NLS-1$
private static final String ALLOW = "allow-"; //$NON-NLS-1$
private static final String RESOURCE_NAME = "resource-name"; //$NON-NLS-1$
@@ -163,7 +164,7 @@
if (principalsElem != null) {
- List groups = principalsElem.getChildren(GROUP);
+ List groups = principalsElem.getChildren(ROLE);
for (final Iterator groupsIter = groups.iterator(); groupsIter.hasNext();) {
final Element group = (Element)groupsIter.next();
@@ -226,7 +227,7 @@
for (final Iterator principalsIter = principals.iterator(); principalsIter.hasNext();) {
MetaMatrixPrincipalName principal = (MetaMatrixPrincipalName)principalsIter.next();
- principalsElement.addContent(new Element(GROUP).setText(principal.getName()));
+ principalsElement.addContent(new Element(ROLE).setText(principal.getName()));
}
}
} // for
@@ -268,4 +269,14 @@
}
return result;
}
+
+ public static Collection<AuthorizationPolicy> buildDefaultAdminPolicies() {
+ Properties p = new Properties();
+ for (String role:AdminRoles.getAllRoleNames()) {
+ p.setProperty(role, role);
+ }
+ return buildAdminPolicies(p);
+
+ }
+
}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/DatabaseDialect.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/DatabaseDialect.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/DatabaseDialect.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,208 +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.vdb.materialization;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.metamatrix.core.util.StringUtil;
-
-/**
- * Enumeration representing a type of database.
- * @since 4.2
- */
-public final class DatabaseDialect implements Serializable {
-
- private static final int NUMBER_OF_TYPES = 6;
- private static final Map DATABASE_DIALECT_MAP = new HashMap(NUMBER_OF_TYPES);
- private static final List DATABASE_DIALECTS = new ArrayList(NUMBER_OF_TYPES);
-
- private static final String ORACLE_TYPE = "Oracle"; //$NON-NLS-1$
- private static final String DB2_TYPE = "DB2"; //$NON-NLS-1$
- private static final String SQL_SERVER_TYPE = "SqlServer"; //$NON-NLS-1$
- private static final String SQL_SERVER_TYPE2 = "sql_server"; //$NON-NLS-1$
- private static final String SYBASE_TYPE = "Sybase"; //$NON-NLS-1$
- private static final String MYSQL_TYPE = "MySQL"; //$NON-NLS-1$
-
-
- private static final String METAMATRIX_TYPE = "MetaMatrix"; //$NON-NLS-1$
- private static final String CONNECTION_PROPS_TYPE = "ConnectionProps"; //$NON-NLS-1$
-
- private static final String ORACLE_DRIVER = "com.metamatrix.jdbc.oracle.OracleDriver"; //$NON-NLS-1$
- private static final String DB2_DRIVER = "com.metamatrix.jdbc.db2.DB2Driver"; //$NON-NLS-1$
- private static final String SQLSERVER_DRIVER = "com.metamatrix.jdbc.sqlserver.SQLServerDriver"; //$NON-NLS-1$
- private static final String SYBASE_DRIVER = "com.metamatrix.jdbc.sybase.SybaseDriver"; //$NON-NLS-1$
- private static final String MYSQL_DRIVER = "com.mysql.jdbc.Driver"; //$NON-NLS-1$
- private static final String METAMATRIX_DRIVER = "com.metamatrix.jdbc.MMDriver"; //$NON-NLS-1$
-
- // Represents supported RDBMS types
- public static final DatabaseDialect ORACLE = newDatabaseDialect(ORACLE_TYPE, ORACLE_DRIVER);
- public static final DatabaseDialect DB2 = newDatabaseDialect(DB2_TYPE, DB2_DRIVER);
- public static final DatabaseDialect SQL_SERVER = newDatabaseDialect(SQL_SERVER_TYPE, SQLSERVER_DRIVER);
- public static final DatabaseDialect SYBASE = newDatabaseDialect(SYBASE_TYPE, SYBASE_DRIVER);
- public static final DatabaseDialect MYSQL = newDatabaseDialect(MYSQL_TYPE, MYSQL_DRIVER);
-
- // Used only internally for generating internal script types
- public static final DatabaseDialect METAMATRIX = new DatabaseDialect(METAMATRIX_TYPE, METAMATRIX_DRIVER);
- public static final DatabaseDialect CONNECTION_PROPS = new DatabaseDialect(CONNECTION_PROPS_TYPE);
-
- private String type;
- private String driverClassname;
-
- /**
- * Get the named type of this <code>DatabaseDialect</code>.
- * @return The named type.
- */
- public String getType() {
- return this.type;
- }
-
- /**
- * @return Returns the driverClassname.
- */
- public String getDriverClassname() {
- return driverClassname;
- }
-
- /**
- * Get a collection of all known DatabaseDialects that may be iterated over, etc.
- * @return All known DatabaseDialect instances.
- * @since 4.2
- */
- public static Collection getAllDialects() {
- return DATABASE_DIALECTS;
- }
-
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- * @since 4.2
- */
- public boolean equals(Object obj) {
- if ( ! (obj instanceof DatabaseDialect) ) {
- return false;
- }
- return ((DatabaseDialect)obj).type == type;
- }
-
- /**
- * @see java.lang.Object#hashCode()
- * @since 4.2
- */
- public int hashCode() {
- return type.hashCode();
- }
-
- /**
- * @see java.lang.Object#toString()
- * @since 4.2
- */
- public String toString() {
- return type;
- }
-
- /**
- * Don't allow outside instantiation.
- * @param type
- * @since 4.2
- */
- private DatabaseDialect(String type) {
- this(type, null);
- }
- private DatabaseDialect(String type, String driver) {
- this.type = type;
- this.driverClassname = driver;
- }
-
- /**
- * @param type
- * @return
- * @since 4.2
- */
- private static DatabaseDialect newDatabaseDialect(final String type, final String driver) {
- final DatabaseDialect result = new DatabaseDialect(type, driver);
- DATABASE_DIALECT_MAP.put(type.toLowerCase(), result);
- DATABASE_DIALECTS.add(result);
- return result;
- }
-
- /**
- * Implemented so that deserialization of this object
- * produces the same value as the serialized.
- * @return A new instance of the equivalent serialized object.
- * @throws java.io.ObjectStreamException
- */
- private Object readResolve () throws java.io.ObjectStreamException {
- DatabaseDialect aType = (DatabaseDialect)DATABASE_DIALECT_MAP.get(this.type.toLowerCase());
- if ( aType != null ) {
- return aType;
- }
- return newDatabaseDialect(this.type, this.driverClassname);
- }
-
- /**
- * Based on the Database type supplied get the dialect supported. If the
- * type supplied not a registered dialect a null returned
- * @param type - type of database like oracle, sqlserver, db2 mmx etc.
- * @return dialect if match found; null otherwise.
- */
- public static DatabaseDialect getDatabaseDialect(String type) {
- if (type.equalsIgnoreCase("mmx")) { //$NON-NLS-1$
- type = METAMATRIX_TYPE;
- }
- return (DatabaseDialect)DATABASE_DIALECT_MAP.get(type.toLowerCase());
- }
-
-
- /**
- * Based on the Database type supplied get the dialect supported. If the
- * type supplied not a registered dialect a null returned
- * @param type - type of database like oracle, sqlserver, db2 mmx etc.
- * @return dialect if match found; null otherwise.
- */
- public static DatabaseDialect getDatabaseDialectByDDLName(String ddlName) {
-
- if (StringUtil.indexOfIgnoreCase(ddlName, ORACLE_TYPE) != -1) {
- return ORACLE;
- }
- else if (StringUtil.indexOfIgnoreCase(ddlName, DB2_TYPE) != -1) {
- return DB2;
- }
- else if ((StringUtil.indexOfIgnoreCase(ddlName, SQL_SERVER_TYPE) != -1) ||
- (StringUtil.indexOfIgnoreCase(ddlName, SQL_SERVER_TYPE2) != -1)) {
- return SQL_SERVER;
- }
- else if (StringUtil.indexOfIgnoreCase(ddlName, SYBASE_TYPE) != -1) {
- return SYBASE;
- }
- else if (StringUtil.indexOfIgnoreCase(ddlName, MYSQL_TYPE) != -1) {
- return MYSQL;
- }
- else {
- return METAMATRIX;
- }
- }
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/MaterializedViewScriptGenerator.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/MaterializedViewScriptGenerator.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/MaterializedViewScriptGenerator.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,80 +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.vdb.materialization;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-
-
-
-/**
- * This generator creates the load and refresh scripts necessary to facilitate all
- * Materialized Views in a VDB.
- *
- * @since 4.2
- */
-public interface MaterializedViewScriptGenerator {
-
- /**
- * Generate the materialization truncate scripts for all materialized views in a VDB
- * for all supported RDBMS platforms and write them to the given stream.
- * @param stream The stream that will contain all truncate scripts.
- * @param dialect The type of RDBMS for which to generated the script.
- * @throws IOException if an error occurs with the given stream or with any stream
- * used internally to help with scipt generation.
- * @since 4.2
- */
- void generateMaterializationTruncateScript(final OutputStream stream, DatabaseDialect dialect) throws IOException;
-
- /**
- * Generate the materialization load scripts for all materialized views in a VDB
- * for the MetaMatrix platform and write them to the given stream.
- * @param stream The stream that will contain all load scripts.
- * @throws IOException if an error occurs with the given stream or with any stream
- * used internally to help with scipt generation.
- * @since 4.2
- */
- void generateMaterializationLoadScript(final OutputStream stream) throws IOException;
-
- /**
- * Generate the materialization rename scripts for all materialized views in a VDB
- * for all supported RDBMS platforms and write them to the given stream.
- * @param stream The stream that will contain all rename scripts.
- * @param dialect The type of RDBMS for which to generated the script.
- * @throws IOException if an error occurs with the given stream or with any stream
- * used internally to help with scipt generation.
- * @since 4.2
- */
- void generateMaterializationSwapScript(final OutputStream stream, DatabaseDialect dialect) throws IOException;
-
- /**
- * Generate the connection properties file for all materialized views in a VDB and
- * write it to the given stream.
- * @param stream The stream that will contain the connection property file.
- * @throws IOException if an error occurs with the given stream or with any stream
- * used internally to help with file generation.
- * @since 4.2
- */
- void generateMaterializationConnectionPropFile(final OutputStream stream) throws IOException;
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/MaterializedViewScriptGeneratorImpl.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/MaterializedViewScriptGeneratorImpl.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/MaterializedViewScriptGeneratorImpl.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,159 +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.vdb.materialization;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.vdb.materialization.template.ExpandedTemplate;
-import com.metamatrix.vdb.materialization.template.Template;
-import com.metamatrix.vdb.materialization.template.TemplateData;
-import com.metamatrix.vdb.materialization.template.TemplateExpander;
-
-
-/**
- * @since 4.2
- */
-public class MaterializedViewScriptGeneratorImpl implements MaterializedViewScriptGenerator {
-
- private static final String TEMPLATE_PATH = "com/metamatrix/vdb/materialization/template/"; //$NON-NLS-1$
- private static final String PARENT_TEMPLATE = "scriptMaterializedView"; //$NON-NLS-1$
- private static final String PLATFORM_SPECIALIZED_TEMPLATE = "loadMaterializedView_"; //$NON-NLS-1$
- private static final String TEMPLATE_EXT = ".stg"; //$NON-NLS-1$
-
- private TemplateData templateData;
-
- /**
- * Default ctor.
- * @param materializedViewTemplateData The template data for a materialization.
- *
- * @since 4.2
- */
- public MaterializedViewScriptGeneratorImpl(TemplateData materializedViewTemplateData) {
- this.templateData = materializedViewTemplateData;
- }
-
- /**
- * @throws IOException
- * @see com.metamatrix.vdb.materialization.MaterializedViewScriptGenerator#generateMaterializationTruncateScript(OutputStream, DatabaseDialect)
- * @since 4.2
- */
- public void generateMaterializationTruncateScript(OutputStream stream, DatabaseDialect dialect) throws IOException {
- generateTemplate(Template.TRUNCATE, this.templateData, dialect, stream);
- }
-
- /**
- * @see com.metamatrix.vdb.materialization.MaterializedViewScriptGenerator#generateMaterializationLoadScript(OutputStream)
- * @since 4.2
- */
- public void generateMaterializationLoadScript(OutputStream stream) throws IOException {
- generateTemplate(Template.LOAD, this.templateData, DatabaseDialect.METAMATRIX, stream);
- }
-
- /**
- * @see com.metamatrix.vdb.materialization.MaterializedViewScriptGenerator#generateMaterializationSwapScript(OutputStream, DatabaseDialect)
- * @since 4.2
- */
- public void generateMaterializationSwapScript(OutputStream stream, DatabaseDialect dialect) throws IOException {
- generateTemplate(Template.SWAP, this.templateData, dialect, stream);
- }
-
- /**
- * @see com.metamatrix.vdb.materialization.MaterializedViewScriptGenerator#generateMaterializationConnectionPropFile(java.io.OutputStream)
- * @since 4.2
- */
- public void generateMaterializationConnectionPropFile(OutputStream stream) throws IOException {
- generateTemplate(Template.CONN_PROPS, this.templateData, DatabaseDialect.CONNECTION_PROPS, stream);
- }
-
- /**
- *
- * @param command
- * @param data
- * @param database
- * @param stream
- * @throws IOException
- * @since 4.2
- */
- private void generateTemplate(String command, TemplateData data, DatabaseDialect database, OutputStream stream) throws IOException {
- String name = database.getType() + "_" + command; //$NON-NLS-1$
- TemplateExpander expander = new TemplateExpander(data, database);
- Reader[] templateReaders = getTemplateReaders(command, database);
- ExpandedTemplate template = expander.expand(name, templateReaders, command);
- closeReaders(templateReaders);
- toStream(template, stream);
- }
-
- /**
- * Get the heirarchy of template readers for the given database platform.
- * <p><b>Close readers when done!!!</b></p>
- * @param command
- * @param database
- * @return
- * @since 4.2
- */
- private Reader[] getTemplateReaders(String command, DatabaseDialect database) throws IOException {
- InputStreamReader parent = getReader(PARENT_TEMPLATE);
- InputStreamReader child = getReader(PLATFORM_SPECIALIZED_TEMPLATE + database);
- return new Reader[] {parent, child};
- }
-
- private void closeReaders(Reader[] readers) throws IOException {
- for ( int i=0; i<readers.length; ++i ) {
- readers[i].close();
- }
- }
-
- /**
- * Get an InputStreamReader for the given filename.
- * @param fileName the file for which to get the InputStreamReader.
- * @return InputStreamReader for the file.
- * @since 4.2
- */
- private InputStreamReader getReader(String fileName) throws IOException {
- String templateName = TEMPLATE_PATH + fileName + TEMPLATE_EXT;
- InputStream inputStream = MaterializedViewScriptGeneratorImpl.class.getClassLoader().getResourceAsStream(templateName);
- if ( inputStream == null ) {
- throw new MetaMatrixRuntimeException("Unable to find resource: " + templateName); //$NON-NLS-1$
- }
- return new InputStreamReader(inputStream);
- }
-
-
- /**
- * Stream the contents to an <code>OutputStream</code>.
- * @param contents the string to stream
- * @param stream the stream to write to
- * @throws IOException if the given OutputStream has problems
- */
- private void toStream(ExpandedTemplate template, OutputStream stream) throws IOException {
- OutputStreamWriter writer = new OutputStreamWriter(stream);
- writer.write(template.contents, 0, template.contents.length());
- writer.flush();
- }
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/ScriptDecorator.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/ScriptDecorator.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/ScriptDecorator.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,67 +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.vdb.materialization;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-/**
- * This class modifies the DDL, which generated of the VDB. Sometimes like in the
- * Materialization Model, we need to add extra specific DDL statements into the
- * original DDL, which are not generated by default. This class used as
- * Intercepter after the generation, before saving, so that proper DDL can be
- * generated for any purpose.
- */
-public class ScriptDecorator {
-
- /**
- * Add the custom extensions or modify the original DDL script
- * into a customized format based on the database type supplied.
- *
- * @param dbType - Database Style
- * @param orignalContent - Byte stream of original DDL
- * @return modified DDL, if custom extnsion needed, otherwise
- * original byte stream returned
- */
- public byte[] modifyDDL(String name, byte[] orignalContent) {
- DatabaseDialect dbDialect = DatabaseDialect.getDatabaseDialectByDDLName(name);
-
- // For now just use simplified code to do the job fast, if we ever
- // need we can subclass and go more fancy.
- if (dbDialect == DatabaseDialect.DB2) {
- String orginalDDL = new String(orignalContent);
- try {
- Pattern pattern = Pattern.compile("\\)%"); //$NON-NLS-1$
- Matcher matcher = pattern.matcher(orginalDDL);
- String modifiedDDL = matcher.replaceAll(") NOT LOGGED INITIALLY%"); //$NON-NLS-1$
- return modifiedDDL.getBytes();
- } catch (PatternSyntaxException e) {
- // Ignore as this only happends on bad expression
- }
- }
- return orignalContent;
- }
-
-
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/ScriptType.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/ScriptType.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/materialization/ScriptType.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,129 +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.vdb.materialization;
-
-import com.metamatrix.core.util.StringUtil;
-
-
-/**
- * @since 4.2
- */
-public class ScriptType {
- public static final String MATERIALIZATION_SCRIPT_NAME_SEPARATOR = "_"; //$NON-NLS-1$
-
- public static final String MATERIALIZATION_MODEL_FILE_PREFIX = "MaterializationModel"; //$NON-NLS-1$
- public static final String MATERIALIZATION_CREATE_SCRIPT_FILE_PREFIX = "Create"; //$NON-NLS-1$
- public static final String MATERIALIZATION_LOAD_SCRIPT_FILE_PREFIX = "Load"; //$NON-NLS-1$
- public static final String MATERIALIZATION_TRUNCATE_SCRIPT_FILE_PREFIX = "Truncate"; //$NON-NLS-1$
- public static final String MATERIALIZATION_SWAP_SCRIPT_FILE_PREFIX = "Swap"; //$NON-NLS-1$
- public static final String MATERIALIZATION_SCRIPT_FILE_SUFFIX = ".ddl"; //$NON-NLS-1$
-
- public static final String MATERIALIZATION_CONNECTION_PROP_FILE_PREFIX = "Connection"; //$NON-NLS-1$
- public static final String MATERIALIZATION_CONNECTION_PROP_FILE_SUFFIX = ".properties"; //$NON-NLS-1$
- public static final String MATERIALIZATION_SCRIPTS_LOG_FILE_SUFFIX = ".log"; //$NON-NLS-1$
-
- /**
- * Utility functions to create the needed file name patterns
- */
- public static String createScriptFileName(String vdbName, String vdbVersion) {
- return buildRuntimeScriptName(vdbName, vdbVersion,MATERIALIZATION_CREATE_SCRIPT_FILE_PREFIX, MATERIALIZATION_SCRIPT_FILE_SUFFIX);
- }
- public static String createScriptFileName(DatabaseDialect dbDialect, String vdbName) {
- return buildVDBScriptName(dbDialect.getType(), vdbName, MATERIALIZATION_CREATE_SCRIPT_FILE_PREFIX, MATERIALIZATION_SCRIPT_FILE_SUFFIX);
- }
-
- public static String loadScriptFileName(String vdbName, String vdbVersion) {
- return buildRuntimeScriptName(vdbName, vdbVersion,MATERIALIZATION_LOAD_SCRIPT_FILE_PREFIX, MATERIALIZATION_SCRIPT_FILE_SUFFIX);
- }
- public static String loadScriptFileName(DatabaseDialect dbDialect, String vdbName) {
- return buildVDBScriptName(dbDialect.getType(), vdbName, MATERIALIZATION_LOAD_SCRIPT_FILE_PREFIX, MATERIALIZATION_SCRIPT_FILE_SUFFIX);
- }
-
- public static String swapScriptFileName(String vdbName, String vdbVersion) {
- return buildRuntimeScriptName(vdbName, vdbVersion,MATERIALIZATION_SWAP_SCRIPT_FILE_PREFIX, MATERIALIZATION_SCRIPT_FILE_SUFFIX);
- }
- public static String swapScriptFileName(DatabaseDialect dbDialect, String vdbName) {
- return buildVDBScriptName(dbDialect.getType(), vdbName, MATERIALIZATION_SWAP_SCRIPT_FILE_PREFIX, MATERIALIZATION_SCRIPT_FILE_SUFFIX);
- }
-
- public static String truncateScriptFileName(String vdbName, String vdbVersion) {
- return buildRuntimeScriptName(vdbName, vdbVersion,MATERIALIZATION_TRUNCATE_SCRIPT_FILE_PREFIX, MATERIALIZATION_SCRIPT_FILE_SUFFIX);
- }
- public static String truncateScriptFileName(DatabaseDialect dbDialect, String vdbName) {
- return buildVDBScriptName(dbDialect.getType(), vdbName, MATERIALIZATION_TRUNCATE_SCRIPT_FILE_PREFIX, MATERIALIZATION_SCRIPT_FILE_SUFFIX);
- }
-
- public static String connectionPropertyFileName(String vdbName, String vdbVersion) {
- return buildRuntimeScriptName(vdbName, vdbVersion, MATERIALIZATION_CONNECTION_PROP_FILE_PREFIX, MATERIALIZATION_CONNECTION_PROP_FILE_SUFFIX);
- }
- public static String logFileName(String vdbName, String vdbVersion) {
- StringBuffer sb = new StringBuffer();
- sb.append(vdbName)
- .append(MATERIALIZATION_SCRIPT_NAME_SEPARATOR)
- .append(vdbVersion)
- .append(MATERIALIZATION_SCRIPTS_LOG_FILE_SUFFIX);
- return sb.toString();
- }
-
- public static boolean isDDLScript(String name) {
- return StringUtil.endsWithIgnoreCase(name, ScriptType.MATERIALIZATION_SCRIPT_FILE_SUFFIX);
- }
-
- public static boolean isMaterializationScript(String name) {
- return StringUtil.indexOfIgnoreCase(name, MATERIALIZATION_MODEL_FILE_PREFIX) >= 0;
- }
- public static boolean isCreateScript(String name) {
- return StringUtil.indexOfIgnoreCase(name, MATERIALIZATION_CREATE_SCRIPT_FILE_PREFIX) >= 0;
- }
-
- public static boolean isLoadScript(String name) {
- return StringUtil.indexOfIgnoreCase(name, MATERIALIZATION_LOAD_SCRIPT_FILE_PREFIX) >= 0;
- }
- public static boolean isSwapScript(String name) {
- return StringUtil.indexOfIgnoreCase(name, MATERIALIZATION_SWAP_SCRIPT_FILE_PREFIX) >= 0;
- }
- public static boolean isTruncateScript(String name) {
- return StringUtil.indexOfIgnoreCase(name, MATERIALIZATION_TRUNCATE_SCRIPT_FILE_PREFIX) >= 0;
- }
-
- private static String buildRuntimeScriptName(String vdbName, String version, String type, String suffix) {
- StringBuffer sb = new StringBuffer();
- sb.append(vdbName)
- .append(MATERIALIZATION_SCRIPT_NAME_SEPARATOR)
- .append(version)
- .append(MATERIALIZATION_SCRIPT_NAME_SEPARATOR)
- .append(type)
- .append(suffix);
- return sb.toString();
- }
-
- private static String buildVDBScriptName(String dbType, String vdbName, String type, String suffix) {
- StringBuffer sb = new StringBuffer();
- sb.append(dbType).append(MATERIALIZATION_SCRIPT_NAME_SEPARATOR)
- .append(vdbName)
- .append(MATERIALIZATION_SCRIPT_NAME_SEPARATOR)
- .append(type)
- .append(suffix);
- return sb.toString();
- }
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicModelInfo.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicModelInfo.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicModelInfo.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,454 +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.vdb.runtime;
-
-import java.io.InputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import com.metamatrix.common.util.ByteArrayHelper;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.core.vdb.ModelType;
-
-/**
- */
-public class BasicModelInfo implements ModelInfo, Serializable {
-
-
- private static final URIResource uriresource = new URIResource();
-
- private String name;
- private String uuid;
- private String version;
- private Date versionDate;
- private String versionedBy;
- private String description;
- private boolean isPhysical;
- private boolean requireConnBinding;
- private String pathInVdb;
-
- // contains the binding name
- private Set bindingNames = Collections.synchronizedSet(new HashSet());
- private boolean multiSourceBindingEnabled;
-
-
- private int modelType = ModelType.UNKNOWN;
- private String uri=null;
-
- private boolean isVisible;
-
- private Map ddlFileNamesToFiles = Collections.EMPTY_MAP;
-
- private Properties properties;
-
- protected BasicModelInfo() {
-
- }
-
- /**
- * CTOR used when the vdb is being sent to the
- * runtime for creation.
- * @param model
- */
- public BasicModelInfo(ModelInfo model) {
- this(model.getName());
- this.setModelType(model.getModelType());
- this.setModelURI(model.getModelURI());
- this.setVersion(model.getVersion());
- this.setUuid(model.getUUID());
- this.setConnectorBindingNames(model.getConnectorBindingNames());
- this.setIsVisible(model.isVisible());
- this.enableMutliSourceBindings(model.isMultiSourceBindingEnabled());
- this.setDescription(model.getDescription());
- this.setVersionDate(model.getDateVersioned());
- this.setVersionedBy(model.getVersionedBy());
- this.setPath(model.getPath());
- }
-
-
-
- public BasicModelInfo(String modelName){
- this.name = modelName;
- }
-
- public String getUUID() {
- return uuid!=null?uuid:"NoUUID";//$NON-NLS-1$
- }
-
- public String getName() {
- return name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getVersion() {
- return version!=null?version:"0"; //$NON-NLS-1$
- }
-
- public int getModelType() {
- return this.modelType;
- }
-
- public String getModelTypeName() {
- return ModelType.MODEL_NAMES[this.modelType];
- }
-
- public String getModelURI() {
- return this.uri;
- }
-
-
- public Date getDateVersioned() {
- return versionDate;
- }
-
-
- public String getVersionedBy() {
- return versionedBy;
- }
-
-
- public boolean isPhysical() {
- return isPhysical;
- }
-
- public boolean requiresConnectorBinding() {
- return requireConnBinding;
- }
-
- public List getConnectorBindingNames() {
- if (bindingNames.isEmpty()) {
- return Collections.EMPTY_LIST;
- }
-
- List bindings = new ArrayList(bindingNames.size());
- bindings.addAll(this.bindingNames);
- return bindings;
- }
-
-
- /**
- * Returns true if the model, based on its model type,
- * supports mutliple connector bindings.
- * If true, {@see #isMultiSourceBindingEnabled()} to determine
- * if the model has been flagged so that the user can
- * actually assign multi connector bindngs.
- *
- * @see org.teiid.adminapi.Model#supportsMultiSourceBindings()
- * @since 4.2
- */
- public boolean supportsMultiSourceBindings() {
- switch (modelType) {
- case ModelType.PHYSICAL: {
- return true;
- }
- default: {
- return false;
- }
- }
-
- }
-
-
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @param uuid
- */
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- /**
- * @param version
- */
- public void setVersion(String version) {
- this.version = version;
- }
-
- /**
- * @param date
- */
- public void setVersionDate(Date date) {
- versionDate = date;
- }
-
- /**
- * @param versionedBy
- */
- public void setVersionedBy(String versionedBy) {
- this.versionedBy = versionedBy;
- }
-
- public boolean isVisible() {
- if (this.uri == null) {
- return false;
- }
- return isVisible;
- }
-
- /**
- * Check whether this model is a materialization
- * of a virtual group.
- * @return Returns the isMaterialization.
- * @since 4.2
- */
- public boolean isMaterialization() {
- return (this.modelType == ModelType.MATERIALIZATION);
- }
-
- /**
- * @see com.metamatrix.common.vdb.api.ModelInfo#getDDLFileContentsGetBytes(java.lang.String)
- * @since 4.2
- */
- public byte[] getDDLFileContentsGetBytes(String ddlFileName) {
- byte[] ddlFile = null;
- if ( this.modelType == ModelType.MATERIALIZATION ) {
- ddlFile = (byte[]) this.ddlFileNamesToFiles.get(ddlFileName);
- }
- return ddlFile;
- }
-
- /**
- * @see com.metamatrix.common.vdb.api.ModelInfo#getDDLFileContentsAsStream(java.lang.String)
- * @since 4.2
- */
- public InputStream getDDLFileContentsAsStream(String ddlFileName) {
- if ( this.modelType == ModelType.MATERIALIZATION ) {
- byte[] ddlFile = (byte[]) this.ddlFileNamesToFiles.get(ddlFileName);
- if (ddlFile == null) {
- return null;
- }
- InputStream fileStream;
- try {
- fileStream = ByteArrayHelper.toInputStream(ddlFile);
- } catch (Exception err) {
- return null;
- }
- return fileStream;
- }
-
- return null;
- }
-
- /**
- * @see com.metamatrix.common.vdb.api.ModelInfo#getDDLFileNames()
- * @since 4.2
- */
- public String[] getDDLFileNames() {
- if ( this.modelType == ModelType.MATERIALIZATION ) {
- Set keys = this.ddlFileNamesToFiles.keySet();
- String[] ddlFileNames = new String[keys.size()];
- Iterator fileNameItr = keys.iterator();
- for ( int i=0; fileNameItr.hasNext(); i++ ) {
- String afileName = (String) fileNameItr.next();
- ddlFileNames[i] = afileName;
- }
- return ddlFileNames;
- }
- return new String[] {};
- }
-
- /**
- * @see com.metamatrix.common.vdb.api.ModelInfo#setDDLFiles(Map)
- * @param ddlFileNamesToFiles
- * @since 4.2
- */
- public void setDDLFiles(Map ddlFileNamesToFiles) {
- this.ddlFileNamesToFiles = ddlFileNamesToFiles;
- }
-
- public void setIsVisible(boolean visibility) {
- this.isVisible = visibility;
- }
-
- public void setVisibility(short visibility) {
- if (visibility == PUBLIC) {
- setIsVisible(true);
- } else {
- setIsVisible(false);
- }
- }
-
- public short getVisibility() {
- if (isVisible) {
- return PUBLIC;
- }
- return PRIVATE;
- }
-
- boolean isConnectorBindingUsed(String bindingName) {
- return this.bindingNames.contains(bindingName);
- }
-
- public void addConnectorBindingByName(String connectrBindingName) {
- if (this.bindingNames == null) {
- bindingNames = new HashSet();
- }
-
- bindingNames.add(connectrBindingName);
- }
-
-
- public void setConnectorBindingNames(List newbindingNames) {
- this.bindingNames.clear();
- this.bindingNames.addAll(newbindingNames);
- }
-
-
- public void removeConnectorBindingName(String bindingName) {
- this.bindingNames.remove(bindingName);
- }
-
-
- public void renameConnectorBinding(String exitingbindingName, String newbindingname) {
-
- boolean removed = this.bindingNames.remove(exitingbindingName);
- if (removed) {
- addConnectorBindingByName(newbindingname);
- }
- }
-
- public void setModelType(int type) {
- this.modelType = type;
-
- setTypeLogic();
- }
-
- public void setModelURI(String uri) {
- this.uri = uri;
- setTypeLogic();
- }
-
- public void setDescription(String desc) {
- this.description = desc;
- }
-
- private void setTypeLogic() {
- if (this.modelType == ModelType.PHYSICAL ||
- this.modelType == ModelType.MATERIALIZATION ) {
- setIsPhysical(true);
-
- if (this.uri != null && this.uri.trim().length() > 0) {
- if (uriresource.isPhysicalBindingAllowed(uri)) {
- setRequireConnectorBinding(true);
- } else {
- setRequireConnectorBinding(false);
- }
- } else {
- setRequireConnectorBinding(false);
-
- }
-
-
- } else {
-
- setIsPhysical(false);
- setRequireConnectorBinding(false);
-
- }
-
- }
-
-
- private void setRequireConnectorBinding(boolean requireConnBinding){
- this.requireConnBinding = requireConnBinding;
- }
-
-
- private void setIsPhysical(boolean isPhysical) {
- this.isPhysical = isPhysical;
- }
-
-
-
- /**
- * @see com.metamatrix.common.vdb.api.ModelInfo#enableMutliSourceBindings(boolean)
- * @since 4.2
- */
- public void enableMutliSourceBindings(boolean isEnabled) {
- this.multiSourceBindingEnabled = isEnabled;
- }
- /**
- * @see com.metamatrix.common.vdb.api.ModelInfo#isMultiSourceBindingEnabled()
- * @since 4.2
- */
-
-
- public boolean isMultiSourceBindingEnabled() {
- return this.multiSourceBindingEnabled;
- }
-
- public String getPath() {
- return this.pathInVdb!=null?pathInVdb:"NoPath";//$NON-NLS-1$
- }
-
- public void setPath(String path) {
- this.pathInVdb = path;
- }
-
- @Override
- public Properties getProperties() {
- return this.properties;
- }
-
- public void setProperties(Properties properties) {
- this.properties = properties;
- }
-
- public String toString() {
- StringBuffer sw = new StringBuffer();
-
- sw.append("ModelInfo: " + this.getName());//$NON-NLS-1$
- sw.append("\n\tVersion: " + this.getVersion());//$NON-NLS-1$
- sw.append("\n\tTypeCode: " + this.getModelType());//$NON-NLS-1$
-
- sw.append("\n\tType: " + this.getModelTypeName());//$NON-NLS-1$
- sw.append("\n\thasBindings: " + (this.getConnectorBindingNames().size() > 0));//$NON-NLS-1$
-
- sw.append("\n\tIsVisible: " + this.isVisible());//$NON-NLS-1$
- sw.append("\n\tIsPhysical: " + this.isPhysical());//$NON-NLS-1$
- sw.append("\n\tIsMaterialization: " + this.isMaterialization());//$NON-NLS-1$
- sw.append("\n\tURI: " + this.getModelURI());//$NON-NLS-1$
- sw.append("\n\tRequiresBinding: " + this.requiresConnectorBinding());//$NON-NLS-1$
-
-
- return sw.toString();
-
- }
-
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicURIModelResource.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicURIModelResource.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicURIModelResource.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,75 +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.vdb.runtime;
-
-
-/**
- */
-public class BasicURIModelResource implements URIModelResource {
-
-
-
- private String uri=null;
- private String authlevel;
- private boolean isXMLDocType = false;
- private boolean isPhysicalBindingAllowed = false;
-
-
- protected BasicURIModelResource(String uri) {
- this.uri = uri;
-
- }
-
- public String getURI() {
- return this.uri;
- }
-
- public String getAuthLevel() {
- return this.authlevel;
- }
-
- public boolean isXMLDocType() {
- return this.isXMLDocType;
- }
-
- public boolean isPhysicalBindingAllowed() {
- return this.isPhysicalBindingAllowed;
- }
-
- protected void setAuthLevel(String level) {
- this.authlevel = level;
- }
-
- protected void setIsXMLDocType(boolean isDocType) {
- this.isXMLDocType = isDocType;
- }
-
- protected void setIsPhysicalBindingAllowed(boolean allowsBinding) {
- this.isPhysicalBindingAllowed = allowsBinding;
- }
-
-
-
-}
-
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicVDBDefn.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicVDBDefn.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicVDBDefn.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,695 +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.vdb.runtime;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import com.metamatrix.common.config.api.ComponentType;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.common.config.model.BasicUtil;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.common.vdb.api.VDBDefn;
-import com.metamatrix.common.vdb.api.VDBStream;
-import com.metamatrix.core.vdb.VDBStatus;
-
-/**
- * Date Dec 3, 2002
- *
- * To import a VDB, the following information is required:
- * 1. VDB Jar {@link #setVDBJar(Object)}. This jar will provide
- * the model and their model info.
- * 2. Add a model to connector binding mapping {@link #addModelToConnectorMapping(String, String)}
- * that indicates which binding should be used for that model
- * 3. set VDB name (version will be assign at creation time)
- *
- * Optional information:
- * 1. Add a ConnectorBinding {@link #addConnectorBinding(ConnectorBinding)}. If this
- * already exist in the configration, it will not be loaded. The
- * model will reference the existing binding.
- * If not added, the connector binding mapping will indicate an
- * assumed already existing binding.
- * 2. Add a ConnectorType {@link #addConnectorType(ComponentType). If
- * already exist in the configration, it will not be loaded. The
- * binding will reference the existing type.
- */
-public class BasicVDBDefn extends BasicVDBInfo implements VDBDefn {
-
- /**
- * The connector types are optional, if
- * not specified on the import, then the
- * connector type(s) is assumed to already
- * exist in configuration
- * <key> connector type name <value> ComponentType {@see com.metamatrix.common.config.api.ComponentType }
- */
- private Map connectorTypes = null;
-
- /**
- * The connector bindings are optional, if
- * not specified on the import, then the
- * connector binding(s) is assumed to already
- * exist in configuration
- * <key> connector binding name <value> ConnectorBinding {@see com.metamatrix.common.config.api.ConnectorBinding }
- */
- private Map connectorBindings = null;
-
- /**
- * contains the VDB Jar.
- */
- private VDBStream vdbcontent = null;
-
- // list of validity errors.
- private ArrayList validityErrors = null;
-
-
- /**
- * Controls when the VDB is imported whether
- * its status will be set to active or not.
- */
- private short status = VDBStatus.INCOMPLETE;
-
- private boolean invalidVDBorModel = false;
-
- // Visibility information on the VDB resources.
- private Map visibilityMap = null;
-
- private char[] dataroles;
-
- private Properties headerProperties;
-
- private Properties infoProperties;
-
- public BasicVDBDefn(String name) {
- super(name);
- }
-
- /**
- * @see com.metamatrix.common.vdb.api.VDBDefn#getVDBStream()
- * @since 4.3
- */
- public VDBStream getVDBStream() {
- return vdbcontent;
- }
-
- public void setVDBStream(VDBStream stream) {
- this.vdbcontent = stream;
- }
-
- public boolean doesVDBHaveValidityError() {
- return this.invalidVDBorModel;
- }
-
- /**
- * Call to add the binding to the VDBDefn set of bindings and
- * add the binding to the model-to-binding mapping.
- * @param modelName
- * @param binding
- * @since 4.2
- */
- public void addConnectorBinding(String modelName, ConnectorBinding binding) {
- addConnectorBinding(binding);
- BasicModelInfo model = (BasicModelInfo) this.getModel(modelName);
- if (model != null) {
- model.addConnectorBindingByName(binding.getFullName());
- }
- }
-
- public void addConnectorBinding(ConnectorBinding binding) {
- if (connectorBindings == null) {
- connectorBindings = new HashMap();
- }
- connectorBindings.put(binding.getName(), binding);
-
- }
-
- public void renameConnectorBinding(String existingBindingName, String newBindingName) {
- ConnectorBinding cb = removeConnectorBindingFromMap(existingBindingName);
- if (cb != null) {
-
- // go thru each model and rename the binding where it is used
- Collection ms = this.getModels();
- for (Iterator it=ms.iterator(); it.hasNext();) {
- BasicModelInfo model = (BasicModelInfo) it.next();
- if (model.isConnectorBindingUsed(cb.getFullName())) {
- model.renameConnectorBinding(existingBindingName, newBindingName);
- }
- }
-
- // rename the binding and add it back
- ConnectorBinding newcb = BasicUtil.getEditor().createConnectorComponent(cb.getConfigurationID(), cb, newBindingName, cb.getRoutingUUID());
- addConnectorBinding(newcb);
-
- }
-
-
- }
-
- public void removeConnectorBinding(String bindingName) {
- if (connectorBindings != null) {
- ConnectorBinding cb = this.getConnectorBindingByName(bindingName);
- if (cb != null) {
- // remove the binding from any model that it is associated with
- Collection ms = this.getModels();
- for (Iterator it=ms.iterator(); it.hasNext();) {
- BasicModelInfo model = (BasicModelInfo) it.next();
- if (model.isConnectorBindingUsed(cb.getFullName())) {
- model.removeConnectorBindingName(cb.getFullName());
- }
- }
- removeFromAvailableConnectorBindings(bindingName);
-
- }
- }
- }
-
- public void removeConnectorBindingNameOnly(String bindingName) {
- if (connectorBindings != null) {
- ConnectorBinding cb = this.getConnectorBindingByName(bindingName);
- if (cb != null) {
- // remove the binding from any model that it is associated with
- Collection ms = this.getModels();
- for (Iterator it=ms.iterator(); it.hasNext();) {
- BasicModelInfo model = (BasicModelInfo) it.next();
- if (model.isConnectorBindingUsed(cb.getFullName())) {
- model.removeConnectorBindingName(cb.getFullName());
- }
- }
- removeConnectorBindingFromMap(bindingName);
- }
- }
- }
-
- private ConnectorBinding removeConnectorBindingFromMap(String bindingName) {
- ConnectorBinding cb = null;
- if (connectorBindings != null) {
- cb = (ConnectorBinding) connectorBindings.remove(bindingName);
- }
- return cb;
-
- }
-
- private void removeFromAvailableConnectorBindings(String bindingName) {
- ConnectorBinding cb = removeConnectorBindingFromMap(bindingName);
- if (cb != null) {
- if (!isConnectorTypeInUse(cb.getComponentTypeID().getFullName())) {
- removeConnectorType(cb.getComponentTypeID().getFullName());
- }
- }
-
- }
-
- public void removeConnectorBinding(String modelName, String bindingName) {
- if (connectorBindings != null) {
- ConnectorBinding cb = getConnectorBindingByName(bindingName);
- if (cb != null) {
- BasicModelInfo model = (BasicModelInfo) this.getModel(modelName);
- if (model != null) {
- model.removeConnectorBindingName(cb.getFullName());
- }
- // if the connector binding is no referenced by any model
- // then remove
- if (!isBindingInUse(cb)) {
- removeFromAvailableConnectorBindings(cb.getFullName());
- }
- }
- }
- }
-
- public boolean isBindingInUse(ConnectorBinding binding) {
-
-// if (binding.getRoutingUUID() == null) {
-// ArgCheck.isNotNull(binding.getRoutingUUID(), "ConnectorBinding routing UUID must not be null"); //$NON-NLS-1$
-// }
- Collection ms = this.getModels();
- for (Iterator it=ms.iterator(); it.hasNext();) {
- BasicModelInfo model = (BasicModelInfo) it.next();
- if (model.isConnectorBindingUsed(binding.getFullName())) {
- return true;
- }
- }
-
- return false;
- }
-
- public boolean isBindingInUse(String bindingName) {
- Collection ms = this.getModels();
- for (Iterator it=ms.iterator(); it.hasNext();) {
- BasicModelInfo model = (BasicModelInfo) it.next();
- if (model.isConnectorBindingUsed(bindingName)) {
- return true;
- }
- }
- return false;
- }
-
- private boolean isConnectorTypeInUse(String typeName) {
- if (connectorTypes == null) {
- return true;
- }
-
- Iterator it = this.connectorBindings.values().iterator();
- while (it.hasNext()) {
- ConnectorBinding cb = (ConnectorBinding) it.next();
- if (cb.getComponentTypeID().getFullName().equalsIgnoreCase(typeName)) {
- return true;
- }
- }
- return false;
-
- }
-
- /**
- * Call to add the binding to the VDBDefn set of bindings and
- * initializes the set of model-to-binding mappings
- * with the binding.
- * @param modelName
- * @param binding
- * @since 4.2
- */
-
- public void setConnectorBinding(String modelName, ConnectorBinding binding) {
- addConnectorBinding(binding);
- BasicModelInfo model = (BasicModelInfo) this.getModel(modelName);
- if (model != null) {
- ArrayList names = new ArrayList(1);
- names.add(binding.getFullName());
- model.setConnectorBindingNames(names);
- }
- }
-
- protected void setConnectorBindings(Map bindings) {
- if (bindings != null) {
- if (connectorBindings == null) {
- connectorBindings = new HashMap(bindings.size());
- }
-
- connectorBindings.putAll(bindings);
- }
- }
-
-
- protected void setConnectorTypes(Map types) {
- if (types != null) {
- if (connectorTypes == null) {
- connectorTypes = new HashMap(types.size());
- }
- connectorTypes.putAll(types);
- }
- }
-
- public void removeConnectorType(String typeName) {
- if (connectorTypes != null) {
- connectorTypes.remove(typeName);
- }
- }
-
- public void addConnectorType(ComponentType type) {
- if (connectorTypes == null) {
- connectorTypes = new HashMap();
- }
- connectorTypes.put(type.getName(), type);
-
- }
-
- public Map getConnectorTypes() {
- Map m = new HashMap();
- if (this.connectorTypes != null) {
- m.putAll(this.connectorTypes);
- }
- return m;
-
- }
-
- public ComponentType getConnectorType(String componentTypeName) {
- if (this.connectorTypes == null) {
- return null;
- }
- if (this.connectorTypes.containsKey(componentTypeName)) {
- return (ComponentType) this.connectorTypes.get(componentTypeName);
- }
-
- return null;
- }
-
-
- public Map getConnectorBindings() {
- Map m = new HashMap();
- if (this.connectorBindings != null) {
- m.putAll(this.connectorBindings);
- }
- return m;
-
- }
-
- public ConnectorBinding getConnectorBindingByRouting(String routingUUID) {
- if (this.connectorBindings == null) {
- return null;
- }
- Iterator it = this.connectorBindings.values().iterator();
- while (it.hasNext()) {
- ConnectorBinding cb = (ConnectorBinding) it.next();
- if (cb.getRoutingUUID().equals(routingUUID)) {
- return cb;
- }
- }
-
- return null;
- }
-
- public ConnectorBinding getConnectorBindingByName(String bindingName) {
- if (this.connectorBindings == null) {
- return null;
- }
-
- ConnectorBinding cb = (ConnectorBinding) this.connectorBindings.get(bindingName);
- return cb;
-
- }
-
-
- public Map getModelToBindingMappings() {
- Map bm = new HashMap();
-
- Collection mdlsd = getModels();
- for (Iterator it=mdlsd.iterator(); it.hasNext(); ) {
- ModelInfo m = (ModelInfo) it.next();
-
-
- if(m.getConnectorBindingNames().size() > 0) {
- List uuids = new ArrayList();
- for (Iterator bits=m.getConnectorBindingNames().iterator(); bits.hasNext();) {
- String name = (String) bits.next();
- ConnectorBinding cb = (ConnectorBinding) this.connectorBindings.get(name);
- uuids.add(cb.getRoutingUUID());
- }
- bm.put(m.getName(), uuids);
-
- } else if(m.getConnectorBindingNames().size() > 0) {
- List uuids = new ArrayList();
- for (Iterator bits=m.getConnectorBindingNames().iterator(); bits.hasNext();) {
- String name = (String) bits.next();
- ConnectorBinding cb = (ConnectorBinding) this.connectorBindings.get(name);
- uuids.add(cb.getRoutingUUID());
- }
- bm.put(m.getName(), uuids);
-
- }
-
- }
-
- return bm;
-
- }
-
-
- /**
- * Returns the collection of all the model names contained
- * in the vdb archive.
- * @return Collection
- *
- */
- public Collection getModelNames() {
-
- Collection mdlsd = getModels();
- Collection mdls = new ArrayList(mdlsd.size());
- for (Iterator it=mdlsd.iterator(); it.hasNext(); ) {
- ModelInfo m = (ModelInfo) it.next();
- mdls.add(m.getName());
- }
-
- return mdls;
- }
-
- public ModelInfo removeModelInfo(String modelName, boolean removeBindings) {
-
- ModelInfo m = super.removeModelInfo(modelName);
- //this.getModel(modelName);
- if (m!= null && removeBindings) {
- Collection names = m.getConnectorBindingNames();
- for (Iterator it=names.iterator(); it.hasNext(); ) {
- final String cbName= (String) it.next();
- ConnectorBinding cb = getConnectorBindingByName(cbName);
- if (cb !=null) {
- if (!isBindingInUse(cb)) {
- removeConnectorBinding(cb.getFullName());
- }
-
- }
-
- }
-
- }
- return m;
- }
-
- public ModelInfo removeModelInfo(String modelName) {
- return removeModelInfo(modelName,true);
- }
-
- /**
- * @see com.metamatrix.common.vdb.api.VDBDefn#getMatertializationModel()
- * @since 4.2
- */
- public ModelInfo getMatertializationModel() {
- ModelInfo matModel = null;
- Iterator modelItr = getModels().iterator();
- while ( modelItr.hasNext() ) {
- ModelInfo aModel = (ModelInfo)modelItr.next();
- if ( aModel != null && aModel.isMaterialization() ) {
- matModel = aModel;
- break;
- }
- }
- return matModel;
- }
-
- public short getStatus() {
- if (invalidVDBorModel) {
- return VDBStatus.INCOMPLETE;
- }
-
- return this.status;
- }
-
- /**
- * Set the status of the VDB
- * see {@link MetadataConstants.VDB_STATUS}
- * @param status
- * @since 4.2
- */
- public void setStatus(short status) {
- this.status = status;
- }
-
- public boolean isActiveStatus() {
- // as long as it has a validity error, it cannot be active
- if (invalidVDBorModel) {
- return false;
- }
- if (this.status == VDBStatus.ACTIVE || this.status == VDBStatus.ACTIVE_DEFAULT) {
- return true;
- }
- return false;
- }
-
- public void setVDBValidityError(boolean hasError) {
- invalidVDBorModel = hasError;
- }
-
- public void setVDBValidityError(boolean hasError, String msg) {
- invalidVDBorModel = hasError;
- if (this.validityErrors == null) {
- this.validityErrors = new ArrayList();
- }
- if (msg != null) {
- this.validityErrors.add(msg);
- }
- }
-
- public String[] getVDBValidityErrors() {
- if (this.validityErrors != null) {
- return (String[])this.validityErrors.toArray(new String[this.validityErrors.size()]);
- }
- return new String[0];
- }
-
- public void determineVdbsStatus() {
- if (invalidVDBorModel) {
- setStatus( VDBStatus.INCOMPLETE);
- return;
- }
- Map mapConnBind = this.getModelToBindingMappings();
- // examine the map looking for any models that do
- // not have a connector binding specified.
- // if any missing, return:
- // MetadataConstants.VDB_STATUS.INCOMPLETE
- // if all are present, return
- // MetadataConstants.VDB_STATUS.INACTIVE
- // how about this... just look for values that are ""?
- short siStatus;
- boolean bHasMissingValues = false;
- boolean bHasNoBindings = false;
- boolean requiresBindings = false;
-
- // verify that at least one model requires a binding
- Iterator mit = getModels().iterator();
- while (mit.hasNext()) {
- ModelInfo mi = (ModelInfo)mit.next();
- if (mi.requiresConnectorBinding()) {
- requiresBindings = true;
- break;
- }
- }
-
- // if no binding is required, then the vdb can
- // be considered for active status
- if (!requiresBindings) {
- setStatus(VDBStatus.INACTIVE);
- return;
- }
-
- int connBind = 0;
- Iterator it = mapConnBind.values().iterator();
-
- // Count the number of bindings
- while (it.hasNext()) {
- List list = (List)it.next();
- if ((list == null) || (list.size() == 0)) {
- bHasMissingValues = true;
- } else {
- connBind += list.size();
- }
- }
-
- if (connBind == 0) {
- bHasNoBindings = true;
- }
-
- if (bHasNoBindings || bHasMissingValues) {
- siStatus = VDBStatus.INCOMPLETE;
- } else {
- siStatus = VDBStatus.ACTIVE;
- }
- setStatus(siStatus);
-
- }
-
-
- /**
- * Remove ConnectorBindings from this VDBDefn that are not referenced by any of the ModelInfos
- *
- * @since 4.3
- */
- public synchronized void removeUnmappedBindings() {
- //build up list of all binding names referred to by a model
- HashSet allBindingNames = new HashSet();
- for (Iterator iter = getModels().iterator(); iter.hasNext(); ) {
- ModelInfo model = (ModelInfo) iter.next();
- allBindingNames.addAll(model.getConnectorBindingNames());
- }
-
- //remove any connector binding that's not referred to
- for (Iterator iter = getConnectorBindings().values().iterator(); iter.hasNext(); ) {
- ConnectorBinding binding = (ConnectorBinding) iter.next();
- String bindingName = binding.getFullName();
-
- if (! allBindingNames.contains(bindingName)) {
- connectorBindings.remove(bindingName);
- }
- }
-
- }
-
- /**
- * @see com.metamatrix.common.vdb.api.VDBDefn#isVisible(java.lang.String)
- */
- public boolean isVisible(String resourcePath) {
- if (visibilityMap == null) {
- return false;
- }
-
- Boolean visibility = (Boolean)visibilityMap.get(resourcePath);
- if (visibility == null && resourcePath.startsWith("/")) { //$NON-NLS-1$
- visibility = (Boolean)visibilityMap.get(resourcePath.substring(1));
- }
-
- if (visibility == null || visibility.equals(Boolean.FALSE)) {
- return false;
- }
- return true;
- }
-
- public void setVisibility(String resoucePath, boolean visible) {
- if (visibilityMap == null) {
- visibilityMap = new HashMap();
- }
- visibilityMap.put(resoucePath, visible?Boolean.TRUE:Boolean.FALSE);
- }
-
-
- /**
- * @see com.metamatrix.common.vdb.api.VDBDefn#getDataRoles()
- */
- public char[] getDataRoles() {
- return dataroles;
- }
-
- public void setDataRoles(char[] roles) {
- this.dataroles = roles;
- }
-
- public void renameModelInfo(String modelName, String newModelName) {
- if (modelName == null || modelName.length() == 0) {
- return;
- }
- if (this.modelInfos != null) {
- BasicModelInfo bmi = (BasicModelInfo) modelInfos.remove(modelName);
- if (bmi != null) {
- bmi.setName(newModelName);
- addModelInfo(bmi);
- }
- }
- }
-
- public Properties getHeaderProperties() {
- return headerProperties;
- }
-
- public void setHeaderProperties(Properties props) {
- this.headerProperties = props;
- }
-
- public Properties getInfoProperties() {
- return infoProperties;
- }
-
- public void setInfoProperties(Properties props) {
- this.infoProperties = props;
- }
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicVDBInfo.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicVDBInfo.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/BasicVDBInfo.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,218 +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.vdb.runtime;
-
-import java.io.Serializable;
-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.Map;
-
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.common.vdb.api.VDBInfo;
-
-/**
- */
-public class BasicVDBInfo implements VDBInfo, Serializable {
- private String fileName;
- private String name;
- private String uuid;
- private String desc;
- private Date created;
- private String createdBy;
- protected Map modelInfos=Collections.synchronizedMap(new HashMap());
- private boolean WSDLDefined=false;
- private String version;
-
- public BasicVDBInfo(String vdbName){
- this.name = vdbName;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.metadata.runtime.api.VDBInfo#getName()
- */
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.metadata.runtime.api.VDBInfo#getUUID()
- */
- public String getUUID() {
- return uuid;
- }
-
- /**
- * Returns the vdbVersion.
- * @return String
- */
- public String getVersion() {
- return version;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.metadata.runtime.api.VDBInfo#getDescription()
- */
- public String getDescription() {
- return desc;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.metadata.runtime.api.VDBInfo#getDateCreated()
- */
- public Date getDateCreated() {
- return created;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.metadata.runtime.api.VDBInfo#getCreatedBy()
- */
- public String getCreatedBy() {
- return createdBy;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.metadata.runtime.api.VDBInfo#getModels()
- */
- public Collection getModels() {
- if (modelInfos == null || modelInfos.size() == 0) {
- return Collections.EMPTY_LIST;
- }
-
- Collection models = new ArrayList(modelInfos.size());
- models.addAll(modelInfos.values());
- return models;
- }
-
- /**
- * Returns the {@link ModelInfo ModelInfo} for the name specified
- * @return ModelInfo
- *
- */
- public ModelInfo getModel(String name) {
- return (ModelInfo) modelInfos.get(name);
- }
-
- /**
- * Returns true if a WSDL is defined for this VDB
- * @return true if a WSDL is defined for this VDB
- */
- public boolean hasWSDLDefined() {
- return WSDLDefined;
- }
-
- /**
- * @param date
- */
- public void setDateCreated(Date date) {
- created = date;
- }
-
- /**
- * @param createdBy
- */
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- /**
- * @param description
- */
- public void setDescription(String description) {
- desc = description;
- }
-
- /**
- * @param modelInfos
- */
- public void setModelInfos(final Collection models) {
- modelInfos.clear();
- for (Iterator it=models.iterator(); it.hasNext();) {
- ModelInfo mi = (ModelInfo) it.next();
- modelInfos.put(mi.getName(), mi);
- }
- }
-
- public void addModelInfo(ModelInfo model) {
- if (model == null) {
- return;
- }
- // first remove an existing model,
- // model names are assumed unique
- removeModelInfo(model.getName());
- this.modelInfos.put(model.getName(), model);
- }
-
- public ModelInfo removeModelInfo(String modelName) {
- if (modelName == null || modelName.length() == 0) {
- return null;
- }
- if (this.modelInfos != null) {
- return (ModelInfo) modelInfos.remove(modelName);
- }
- return null;
- }
-
-
- /**
- * @param objectID
- */
- public void setUUID(String objectID) {
- uuid = objectID;
- }
-
- public void setHasWSDLDefined(boolean defined ) {
- WSDLDefined = defined;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.metadata.runtime.api.VDBInfo#getFileName()
- */
- public String getFileName() {
- return fileName;
- }
-
- public void setFileName(String fileName) {
- this.fileName = fileName;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
-
- public String toString() {
- StringBuffer sb = new StringBuffer("\nDefn for VDB " + getName() + " and # models " + (modelInfos==null?0:modelInfos.size())); //$NON-NLS-1$ //$NON-NLS-2$
- return sb.toString();
-
- }
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIModelResource.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIModelResource.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIModelResource.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,50 +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.vdb.runtime;
-
-
-/**
- */
-public interface URIModelResource {
-
-
- String getURI();
-
- String getAuthLevel();
-
- boolean isXMLDocType();
-
- boolean isPhysicalBindingAllowed();
-
-
- public class AUTH_LEVEL {
- public static final String ALL = "all";//$NON-NLS-1$
- public static final String MODEL = "model";//$NON-NLS-1$
- public static final String GROUP = "group";//$NON-NLS-1$
-
-
- }
-
-}
-
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIResource.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIResource.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIResource.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,84 +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.vdb.runtime;
-
-import java.util.Map;
-
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-
-
-/**
- */
-public final class URIResource {
-
- private static Map resources = null;
-
-
- static {
- try {
- URIResourceReader reader = new URIResourceReader();
- resources = reader.getURIResources();
-
-
- } catch (Exception e) {
- String msg = CommonPlugin.Util.getString("URIResource.Resource_not_found", new Object[]{URIResourceReader.RESOURCE_NAME}); //$NON-NLS-1$
- throw new MetaMatrixRuntimeException(e, msg);
- }
- }
-
-
- public boolean isXMLDocument(String uri) {
- URIModelResource r = getURIModelResource(uri);
- if (r != null) {
- return r.isXMLDocType();
- }
- return false;
- }
-
- public String getAuthorizationLevel(String uri) {
- URIModelResource r = getURIModelResource(uri);
- if (r != null) {
- return r.getAuthLevel();
- }
- return URIModelResource.AUTH_LEVEL.ALL;
- }
-
- public boolean isPhysicalBindingAllowed(String uri) {
- URIModelResource r = getURIModelResource(uri);
- if (r != null) {
- return r.isPhysicalBindingAllowed();
- }
- return false;
- }
-
- private URIModelResource getURIModelResource(String uri) {
- if (resources.containsKey(uri)) {
- return (URIModelResource) resources.get(uri);
- }
- return null;
-
- }
-}
-
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIResourceReader.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIResourceReader.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/URIResourceReader.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,170 +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.vdb.runtime;
-
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.jdom.Attribute;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-
-import com.metamatrix.common.xml.XMLReaderWriter;
-import com.metamatrix.common.xml.XMLReaderWriterImpl;
-import com.metamatrix.core.util.ArgCheck;
-
-/**
- */
-public class URIResourceReader {
- private Map resources = new HashMap();
-
-// private static final String TRUE = Boolean.TRUE.toString();
- private static final String FALSE = Boolean.FALSE.toString();
-
- public static final String RESOURCE_NAME = "uriprimarymodeltypes.xml"; //$NON-NLS-1$
-
- public URIResourceReader () {
-
- }
-
-
- public Map getURIResources() throws Exception {
- InputStream in = loadAsResource(RESOURCE_NAME);
-
- ArgCheck.isNotNull(in);
- Document doc = null;
-
- try {
- doc = getXMLReaderWriter().readDocument(in);
- } catch (JDOMException e) {
- try {
- in.close();
- } catch (Exception ce) {
-
- }
- throw new Exception(e.getMessage());
- }
-
- Element root = doc.getRootElement();
-
- Collection uriElements = root.getChildren(Constants.URI.ELEMENT);
-
-
- Iterator iterator = uriElements.iterator();
- while (iterator.hasNext()) {
- Element uriElement = (Element)iterator.next();
- String name = null;
- String authlevel = URIModelResource.AUTH_LEVEL.ALL;
- String isxmldoctype = FALSE;
- String isphysicalbinding = FALSE;
- List attrs = uriElement.getAttributes();
- for (Iterator ait=attrs.iterator(); ait.hasNext();) {
- Attribute a = (Attribute) ait.next();
- String n = a.getName();
- if (n.equalsIgnoreCase(Constants.URI.Attribute.NAME)) {
- name = a.getValue();
- } else if (n.equalsIgnoreCase(Constants.URI.Attribute.AUTHLEVEL)) {
- authlevel = a.getValue();
- } else if (n.equalsIgnoreCase(Constants.URI.Attribute.ISXMLDOCTYPE)) {
- isxmldoctype = a.getValue();
- } else if (n.equalsIgnoreCase(Constants.URI.Attribute.PHYSICAL_BINDING)) {
- isphysicalbinding = a.getValue();
- }
-
-// System.out.println("Name: " + n + " value: " + a.getValue());
-
- }
- ArgCheck.isNotNull(name, "The attribute " + Constants.URI.Attribute.NAME + " was not defined"); //$NON-NLS-1$ //$NON-NLS-2$
- BasicURIModelResource resource = new BasicURIModelResource(name);
- resource.setAuthLevel(authlevel);
-
-// System.out.println("Name: " + name + " auth: " + authlevel + " doc: " + isxmldoctype);
- resource.setIsXMLDocType(new Boolean(isxmldoctype).booleanValue());
- resource.setIsPhysicalBindingAllowed(new Boolean(isphysicalbinding).booleanValue());
-
- resources.put(name, resource);
-
- }
-
- if (in != null) {
- try {
- in.close();
- } catch (Exception ce) {
-
- }
- }
-
- return resources;
-
- }
-
- private InputStream loadAsResource(String resourceName) throws Exception {
- InputStream is = null;
- try {
- is = URIResourceReader.class.getResourceAsStream(resourceName) ;
- // .getClassLoader().getResourceAsStream(resourceName);
- ArgCheck.isNotNull(is);
- } catch (Exception e) {
- throw e;
-
- }
- return is;
- }
-
- private XMLReaderWriter getXMLReaderWriter() {
- return new XMLReaderWriterImpl();
- }
-
-
- public static class Constants {
- public static final String URI_RESOURCES = "urimodeltypes";//$NON-NLS-1$
-
- public static class URI {
- public static final String ELEMENT = "uri"; //$NON-NLS-1$
- public static class Attribute {
- public static final String NAME = "name"; //$NON-NLS-1$
- // indicates to what level the authorization will be enabled
- public static final String AUTHLEVEL = "authlevel"; //$NON-NLS-1$
- // indicates if this is uri represents an xml document type
- public static final String ISXMLDOCTYPE = "xmldoctype"; //$NON-NLS-1$
- // indicates if this uri is associated with a physical model type, does it allow a binding
- public static final String PHYSICAL_BINDING = "physicalbindingallowed"; //$NON-NLS-1$
-
-
- }
- }
-
-
- }
-
-}
-
-
-
-
-
Modified: trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/VDBKey.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/VDBKey.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/java/com/metamatrix/vdb/runtime/VDBKey.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -22,11 +22,14 @@
package com.metamatrix.vdb.runtime;
+import java.io.Serializable;
+
import com.metamatrix.core.util.HashCodeUtil;
-public class VDBKey {
-
- private String name;
+public class VDBKey implements Serializable{
+ private static final long serialVersionUID = -7249750823144856081L;
+
+ private String name;
private String version;
public VDBKey(String name, String version) {
@@ -36,6 +39,11 @@
}
}
+ public VDBKey(String name, int version) {
+ this.name = name.toUpperCase();
+ this.version = String.valueOf(version);
+ }
+
public String getName() {
return name;
}
Copied: trunk/common-internal/src/main/java/org (from rev 1899, branches/JCA/common-internal/src/main/java/org)
Copied: trunk/common-internal/src/main/java/org/teiid (from rev 1899, branches/JCA/common-internal/src/main/java/org/teiid)
Deleted: trunk/common-internal/src/main/java/org/teiid/SecurityHelper.java
===================================================================
--- branches/JCA/common-internal/src/main/java/org/teiid/SecurityHelper.java 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/common-internal/src/main/java/org/teiid/SecurityHelper.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,39 +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 org.teiid;
-
-import java.security.Principal;
-
-import javax.security.auth.Subject;
-
-public interface SecurityHelper {
-
- boolean assosiateSecurityContext(String securityDomain, Object context);
-
- void clearSecurityContext(String securityDomain);
-
- Object getSecurityContext(String securityDomain);
-
- Object createSecurityContext(String securityDomain, Principal p, Object credentials, Subject subject);
-
-}
Copied: trunk/common-internal/src/main/java/org/teiid/SecurityHelper.java (from rev 1899, branches/JCA/common-internal/src/main/java/org/teiid/SecurityHelper.java)
===================================================================
--- trunk/common-internal/src/main/java/org/teiid/SecurityHelper.java (rev 0)
+++ trunk/common-internal/src/main/java/org/teiid/SecurityHelper.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -0,0 +1,39 @@
+/*
+ * 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;
+
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+
+public interface SecurityHelper {
+
+ boolean assosiateSecurityContext(String securityDomain, Object context);
+
+ void clearSecurityContext(String securityDomain);
+
+ Object getSecurityContext(String securityDomain);
+
+ Object createSecurityContext(String securityDomain, Principal p, Object credentials, Subject subject);
+
+}
Modified: trunk/common-internal/src/main/resources/com/metamatrix/platform/security/api/authorizations.xsd
===================================================================
--- trunk/common-internal/src/main/resources/com/metamatrix/platform/security/api/authorizations.xsd 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/main/resources/com/metamatrix/platform/security/api/authorizations.xsd 2010-03-04 20:00:27 UTC (rev 1911)
@@ -60,7 +60,7 @@
<xs:element minOccurs="0" name="principals">
<xs:complexType>
<xs:sequence>
- <xs:element maxOccurs="unbounded" name="group" type="xs:string"/>
+ <xs:element maxOccurs="unbounded" name="role" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Deleted: trunk/common-internal/src/test/java/com/metamatrix/common/util/TestVDBNameValidator.java
===================================================================
--- trunk/common-internal/src/test/java/com/metamatrix/common/util/TestVDBNameValidator.java 2010-03-04 19:47:03 UTC (rev 1910)
+++ trunk/common-internal/src/test/java/com/metamatrix/common/util/TestVDBNameValidator.java 2010-03-04 20:00:27 UTC (rev 1911)
@@ -1,102 +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.util;
-
-import junit.framework.TestCase;
-
-
-/**
- * @since 4.3
- */
-public class TestVDBNameValidator extends TestCase {
-
- public TestVDBNameValidator(String name) {
- super(name);
- }
-
- public final void testValidName1() {
- assertTrue(VDBNameValidator.isValid("ValidName")); //$NON-NLS-1$
- }
-
- public final void testValidName2() {
- assertTrue(VDBNameValidator.isValid("System_1")); //$NON-NLS-1$
- }
-
- public final void testValidName3() {
- assertTrue(VDBNameValidator.isValid("Admin__")); //$NON-NLS-1$
- }
-
- public final void testValidNameWithUnderscore() {
- assertTrue(VDBNameValidator.isValid("Valid_Name")); //$NON-NLS-1$
- }
-
- public final void testAllValidCharacters() {
- assertTrue(VDBNameValidator.isValid("abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")); //$NON-NLS-1$
- }
-
- public final void testInvalidName1() {
- assertFalse(VDBNameValidator.isValid("InvalidName`")); //$NON-NLS-1$
- }
-
- public final void testInvalidName2() {
- assertFalse(VDBNameValidator.isValid("Inalid/Name")); //$NON-NLS-1$
- }
-
- public final void testInvalidName3() {
- assertFalse(VDBNameValidator.isValid("Invalid-Name")); //$NON-NLS-1$
- }
-
- public final void testInvalidName4() {
- assertFalse(VDBNameValidator.isValid("Invalid?Name")); //$NON-NLS-1$
- }
-
- public final void testNameThatStartWithDigit() {
- assertFalse(VDBNameValidator.isValid("1VDBName")); //$NON-NLS-1$
- }
-
- public final void testNameThatStartWithUnderscore() {
- assertFalse(VDBNameValidator.isValid("_VDBName")); //$NON-NLS-1$
- }
-
- public final void testEmptyVDBName() {
- assertFalse(VDBNameValidator.isValid("")); //$NON-NLS-1$
- }
-
- public final void testNullName() {
- assertFalse(VDBNameValidator.isValid(null));
- }
-
- public final void testReservedSystemName() {
- assertFalse(VDBNameValidator.isValid("System")); //$NON-NLS-1$
- }
-
- public final void testReservedHelpName() {
- assertFalse(VDBNameValidator.isValid("System")); //$NON-NLS-1$
- }
-
- public final void testReservedAdminName() {
- assertFalse(VDBNameValidator.isValid("System")); //$NON-NLS-1$
- }
-
-
-}
More information about the teiid-commits
mailing list