Author: shawkins
Date: 2009-11-30 12:12:55 -0500 (Mon, 30 Nov 2009)
New Revision: 1606
Added:
trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java
Removed:
trunk/common-internal/src/main/java/com/metamatrix/common/tree/PassThroughTreeNodeFilter.java
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNode.java
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeComparator.java
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeEditor.java
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeException.java
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeFilter.java
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeIterator.java
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeNameComparator.java
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodePathComparator.java
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodePropertyComparator.java
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeSource.java
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeView.java
trunk/common-internal/src/main/java/com/metamatrix/common/tree/basic/
trunk/common-internal/src/main/java/com/metamatrix/common/tree/directory/
trunk/common-internal/src/main/java/com/metamatrix/common/vdb/api/SystemVdbUtility.java
trunk/common-internal/src/test/java/com/metamatrix/common/config/model/
trunk/common-internal/src/test/java/com/metamatrix/common/tree/directory/
trunk/engine/src/main/java/org/teiid/dqp/internal/process/QueryMetadataWrapper.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/ModelVisibilityValidationVisitor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestModelVisibilityValidationVisitor.java
trunk/engine/src/test/java/org/teiid/metadata/TestCompositeMetadataStore.java
Modified:
trunk/common-internal/src/main/java/com/metamatrix/common/object/PropertyType.java
trunk/common-internal/src/main/java/com/metamatrix/common/object/StandardPropertyTypeValidator.java
trunk/common-internal/src/main/java/com/metamatrix/common/vdb/api/VDBArchive.java
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/PermissionNode.java
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/apiimpl/PermissionDataNodeImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/AuthorizationService.java
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedRequestWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java
trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java
trunk/runtime/src/main/java/com/metamatrix/platform/security/membership/service/MembershipServiceImpl.java
Log:
TEIID-750 consolidating the entitlement and visibility checking and ensuring that
visibility is checked on prepared statements. also removing common tree code
Modified:
trunk/common-internal/src/main/java/com/metamatrix/common/object/PropertyType.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/object/PropertyType.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/object/PropertyType.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -22,6 +22,7 @@
package com.metamatrix.common.object;
+import java.io.File;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@@ -73,7 +74,7 @@
public static final PropertyType SET = new PropertyType(113, SET_NAME,
java.util.Set.class.getName() );
public static final PropertyType URL = new PropertyType(114, URL_NAME,
java.net.URL.class.getName() );
public static final PropertyType HOSTNAME = new PropertyType(115,
HOSTNAME_NAME, java.net.InetAddress.class.getName() );
- public static final PropertyType FILE = new PropertyType(116, FILE_NAME,
com.metamatrix.common.tree.directory.DirectoryEntry.class.getName() );
+ public static final PropertyType FILE = new PropertyType(116, FILE_NAME,
File.class.getName() );
public static final PropertyType OBJECT_ID = new PropertyType(117,
OBJECT_ID_NAME, com.metamatrix.core.id.ObjectID.class.getName() );
public static final PropertyType PASSWORD = new PropertyType(119,
PASSWORD_NAME, PASSWORD_CLASS.getName() );
public static final PropertyType PROPERTIED_OBJECT = new PropertyType(120,
PROPERTIED_OBJECT_NAME, com.metamatrix.common.object.PropertiedObject.class.getName()
);
Modified:
trunk/common-internal/src/main/java/com/metamatrix/common/object/StandardPropertyTypeValidator.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/object/StandardPropertyTypeValidator.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/object/StandardPropertyTypeValidator.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -22,6 +22,7 @@
package com.metamatrix.common.object;
+import java.io.File;
import java.io.Serializable;
import java.net.InetAddress;
import java.net.MalformedURLException;
@@ -31,7 +32,6 @@
import java.util.HashMap;
import java.util.Map;
-import com.metamatrix.common.tree.directory.DirectoryEntry;
import com.metamatrix.core.id.ObjectID;
public final class StandardPropertyTypeValidator implements Serializable {
@@ -331,7 +331,9 @@
}
class DirectoryEntryValidator implements PropertyTypeValidator, Serializable {
public boolean isValidValue(Object value ) {
- if ( value instanceof DirectoryEntry ) {
+ if (value instanceof String) {
+ return true;
+ } else if ( value instanceof File ) {
return true;
}else if(value instanceof Object[]) {
return StandardPropertyTypeValidator.isValidValue((Object[])value, this);
Deleted:
trunk/common-internal/src/main/java/com/metamatrix/common/tree/PassThroughTreeNodeFilter.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/tree/PassThroughTreeNodeFilter.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/tree/PassThroughTreeNodeFilter.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -1,44 +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.tree;
-
-
-
-public class PassThroughTreeNodeFilter implements TreeNodeFilter {
-
- /**
- * Obtain a description for this filter.
- * @return the readable description. For example: "JPG and GIF Images"
- */
- public String getDescription(){
- return "All files (*.*)"; //$NON-NLS-1$
- }
- /**
- * Determine whether the given TreeNode is accepted by this filter.
- * @return true if accepted, or false otherwise.
- */
- public boolean accept(TreeNode entry){
- return true;
- }
-}
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNode.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNode.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNode.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -1,124 +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.tree;
-
-import com.metamatrix.common.object.ObjectDefinition;
-import com.metamatrix.common.object.PropertiedObject;
-
-/**
- * This interface represents a single entry on a hierarchical system.
- */
-public interface TreeNode extends Comparable, PropertiedObject {
-
- /**
- * Return whether this TreeNode represents an existing resource.
- * @return true the entry exists, or false otherwise.
- */
- boolean exists();
-
- /**
- * Obtain the name of this TreeNode. The name does not contain the
- * namespace but is unique within the namespace of the TreeNode.
- * @return the name of the node; never null or zero-length
- */
- String getName();
-
- /**
- * Obtain the full name of the TreeNode which is unique within the TreeView.
- * The full name is the concatenation of the namespace, separator, and
- * name of this TreeNode.
- * @return the fully qualified name of this node; never null
- */
- String getFullName();
-
- /**
- * Obtain the namespace to which this tree node belongs. The separator
- * character is used between each of the components of the namespace.
- * @return the string that represents the namespace of this node; never null
- */
- String getNamespace();
-
- /**
- * Get this type for this tree node.
- * @return the entity's type; never null
- */
- ObjectDefinition getType();
-
- /**
- * Obtain the character that is used to separate names in a path sequence for
- * the abstract path. This character is completely dependent upon the
implementation.
- * @return the charater used to delimit names in the abstract path.
- */
- char getSeparatorChar();
-
- /**
- * Obtain the character (as a String) that is used to separate names in a path
sequence for
- * the abstract path.
- * @return the string containing the charater used to delimit names in the abstract
path; never null
- */
- String getSeparator();
-
- /**
- * Return whether this node has undergone changes. The time from which changes are
- * maintained is left to the implementation.
- * @return true if this TreeNode has changes, or false otherwise.
- */
- boolean isModified();
-
- /**
- * Compares this object to another. If the specified object is
- * an instance of the TreeNode class, then this
- * method compares the contents; otherwise, it throws a
- * ClassCastException (as instances are comparable only to
- * instances of the same
- * class).
- * <p>
- * Note: this method <i>is</i> consistent with
- * <code>equals()</code>, meaning that
- * <code>(compare(x, y)==0) == (x.equals(y))</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.
- */
- int compareTo(Object par1);
- /**
- * Returns true if the specified object is semantically equal
- * to this instance.
- * Note: this method is consistent with
- * <code>compareTo()</code>.
- * @param obj the object that this instance is to be compared to.
- * @return whether the object is equal to this object.
- */
- boolean equals(Object par1);
-
- /**
- * Return the string form of this TreeNode.
- * @return the stringified abstract path, equivalent to
<code>getPath</code>
- */
- String toString();
-
-}
Deleted:
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeComparator.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeComparator.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeComparator.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -1,31 +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.tree;
-
-import java.util.Comparator;
-
-public interface TreeNodeComparator extends Comparator {
-
- void setTreeNodeEditor(TreeNodeEditor editor);
-}
-
Deleted:
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeEditor.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeEditor.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeEditor.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -1,200 +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.tree;
-
-import com.metamatrix.common.object.ObjectDefinition;
-import com.metamatrix.common.object.PropertiedObjectEditor;
-import com.metamatrix.common.object.PropertyDefinition;
-
-/**
- * This interface defines a view of a hierarchy of TreeNode instances.
- */
-public interface TreeNodeEditor extends PropertiedObjectEditor {
-
- /**
- * Set the marked state of the TreeNode node.
- * @param marked the marked state of the node.
- */
- void setMarked(TreeNode node, boolean marked);
-
- /**
- * Return the marked state of the specified node.
- * @return the marked state of the node.
- */
- boolean isMarked(TreeNode node);
-
- /**
- * Determine whether the specified node is a child of the given parent node.
- * @return true if the node is a child of the given parent node.
- */
- boolean isParentOf(TreeNode parent, TreeNode child);
-
- /**
- * Determine whether the specified node is a descendent of the given ancestor node.
- * @return true if the node is a descendent of the given ancestor node.
- */
- boolean isAncestorOf(TreeNode ancestor, TreeNode descendent);
-
- /**
- * Create a new instance of a TreeNode under the specified parent and
- * with the specified type. The name of the new object is created automatically.
- * @param parent the TreeNode that is to be the parent of the new tree node object
- * @param type the ObjectDefinition instance that defines the type of tree node
- * object to instantiate.
- * @return the new instance or null if the new instance could not be created.
- * @throws IllegalArgumentException if the parent and the new TreeNode
- * are not compatible
- * @throws AssertionError if <code>parent</code> or
<code>type</code>
- * is null
- */
- TreeNode create(TreeNode parent, ObjectDefinition type);
-
- /**
- * Create a new instance of a TreeNode under the specified parent,
- * with the specified type and with the specified name
- * @param parent the TreeNode that is to be the parent of the new tree node object
- * @param name the name for the new object
- * @param type the ObjectDefinition instance that defines the type of tree node
- * object to instantiate.
- * @return the new instance or null if the new instance could not be created.
- * @throws IllegalArgumentException if the parent and the new TreeNode
- * are not compatible
- * @throws AssertionError if <code>parent</code> or
<code>type</code>
- * is null
- */
- TreeNode create(TreeNode parent, String name, ObjectDefinition type);
-
- /**
- * Removes the specified TreeNode instance (and all its children) from
- * its parent. After this method is called, the caller is responsible for
- * maintaining the referenced to the specified object (to prevent garbage
- * collection).
- * @param obj the node to be deleted; may not be null
- * @return true if deletion is successful, or false otherwise.
- * @throws AssertionError if <code>obj</code> is null
- */
- boolean delete(TreeNode node);
-
- /**
- * Creates and places a copy of the specified original TreeNode under the specified
new parent.
- * This method does not affect the original TreeNode or its contents.
- * <p>
- * This methods may be used in conjunction with a reference
- * to an existing TreeNode instance in this or another session to
<i>copy</i>
- * TreeNode instances and paste them in this session.
- * @param original the original node to be copied; may not be null
- * @param newParent the nodethat is to be considered the
- * parent of the newly created instances; may not be null
- * @param deepCopy true if this paste operation is to place a deep copy of
- * <code>original</code>, or false if only the
<code>original</code>
- * node and its immediate properties are to be pasted.
- * @return the node that resulted from the paste, or null if the paste failed.
- * @throws AssertionError if either of <code>original</code> or
<code>newParent</code> is null
- */
- TreeNode paste(TreeNode original, TreeNode newParent, boolean deepCopy);
-
- /**
- * Moves this TreeNode to be a child of the specified new parent.
- * The specified object <i>is</i> modified, since it's namespace is
changed
- * to be newParent.
- * <p>
- * This method may be used in conjunction with the <code>delete</code>
method
- * of an editor from this or another another session to <i>cut</i>
TreeNode instances
- * from the original's session and paste them (or move them) into this session.
- * <p>
- * @param obj the node to be moved; may not be null
- * @param newParent the node that is to be considered the
- * parent of the existing instance; may not be null
- * @return true if this node was moved, or false otherwise.
- * @throws AssertionError if either of <code>obj</code> or
<code>newParent</code> is null
- */
- boolean move(TreeNode node, TreeNode newParent);
-
- /**
- * Moves this TreeNode to be a child at a particular index in the specified new
parent.
- * The specified object <i>is</i> modified, since it's namespace is
changed
- * to be newParent.
- * <p>
- * This method may be used in conjunction with the <code>delete</code>
method
- * of an editor from this or another another session to <i>cut</i>
TreeNode instances
- * from the original's session and paste them (or move them) into this session.
- * <p>
- * @param obj the node to be moved; may not be null
- * @param newParent the node that is to be considered the
- * parent of the existing instance; may not be null
- * @param indexInNewParent the position that this node will occupy within the ordered
list
- * of children for newParent.
- * @return true if this node was moved, or false otherwise.
- * @throws AssertionError if either of <code>obj</code> or
<code>newParent</code> is null
- * @throws IndexOutOfBoundsException if the index is not within the range
- * <code>0 <= newIndex < childCount</code>
- */
- boolean move(TreeNode node, TreeNode newParent, int indexInNewParent);
-
- /**
- * Moves this TreeNode to the specified location within the ordered list of
- * children for the node's parent.
- * @param child the node to be moved; may not be null
- * @param newIndex the position that this node will occupy within the ordered list
- * of children for the node's parent.
- * @return true if this node was moved, or false otherwise.
- * @throws AssertionError if either of <code>obj</code> or
<code>newParent</code> is null
- * @throws IndexOutOfBoundsException if the index is not within the range
- * <code>0 <= newIndex < childCount</code>
- */
- boolean moveChild(TreeNode child, int newIndex);
-
- /**
- * Renames this TreeNode to the specified new name. This operation will
- * not succeed if there is already a node underneath the parent
- * with the same name as the specified newName.
- * @param obj the node to be renamed; may not be null
- * @param newName the new name for the object; may not be null or zero-length,
- * and must not be used by an existing sibling
- * @return true if this node was renamed, or false otherwise.
- * @throws AssertionError if either of <code>obj</code> or
<code>newName</code> is null,
- * or if <code>newName</code> is zero-length
- */
- boolean rename(TreeNode node, String newName);
-
- /**
- * Filter the specified PropertyDefinition instances and return the first
- * definition that is mapped to "the name" property for the tree node.
- * @param obj the tree node; may not be null
- * @return the first PropertyDefinition instance found in the list of
- * PropertyDefinition instances that represents the name property for the object,
- * or null if no such PropertyDefinition is found.
- */
- PropertyDefinition getNamePropertyDefinition(TreeNode obj);
-
- /**
- * Filter the specified PropertyDefinition instances and return the first
- * definition that is mapped to "the description" property for the metadata
object.
- * @param obj the tree node; may not be null
- * @return the first PropertyDefinition instance found in the list of
- * PropertyDefinition instances that represents the description property for the
object,
- * or null if no such PropertyDefinition is found.
- */
-// PropertyDefinition getDescriptionPropertyDefinition(TreeNode obj);
-
-}
Deleted:
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeException.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeException.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeException.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -1,82 +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.tree;
-
-import com.metamatrix.api.exception.MetaMatrixException;
-
-/**
- * This exception denotes that the user account could not be identified, could not be
located, or was invalid.
- */
-public class TreeNodeException extends MetaMatrixException{
-
- /**
- * No-arg costructor required by Externalizable semantics
- */
- public TreeNodeException() {
- super();
- }
-
- /**
- * Construct an instance with the message specified.
- *
- * @param message A message describing the exception
- */
- public TreeNodeException( 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 TreeNodeException( 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 TreeNodeException( 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 TreeNodeException( Exception e, String code, String message ) {
- super( e, code, message );
- }
-}
-
-
-
Deleted:
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeFilter.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeFilter.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeFilter.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -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 com.metamatrix.common.tree;
-
-public interface TreeNodeFilter {
-
- /**
- * Obtain a description for this filter.
- * @return the readable description. For example: "JPG and GIF Images"
- */
- String getDescription();
-
- /**
- * Determine whether the given TreeNode is accepted by this filter.
- * @return true if accepted, or false otherwise.
- */
- boolean accept(TreeNode entry);
-}
-
Deleted:
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeIterator.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeIterator.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeIterator.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -1,144 +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.tree;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.util.ErrorMessageKeys;
-import com.metamatrix.core.util.ArgCheck;
-
-public class TreeNodeIterator implements Iterator {
-
- private List startingNodes;
- private TreeView view;
- private TreeNode last;
- private TreeNode next;
-
- public TreeNodeIterator( List startingNodes, TreeView view ) {
- ArgCheck.isNotNull(startingNodes);
- ArgCheck.isNotNull(view);
- this.startingNodes = startingNodes;
- this.view = view;
- if ( this.startingNodes.size() != 0 ) {
- this.next = (TreeNode) this.startingNodes.get(0);
- } else {
- this.next = null;
- }
- this.last = null;
- }
-
- public TreeNodeIterator( TreeNode startingNode, TreeView view ) {
- ArgCheck.isNotNull(startingNode);
- ArgCheck.isNotNull(view);
- this.startingNodes = new ArrayList(1);
- this.startingNodes.add(startingNode);
- this.view = view;
- this.next = startingNode;
- this.last = null;
- }
-
- public boolean hasNext() {
- return this.next != null;
- }
-
- public Object next() {
- return nextPreOrder(false);
- }
-
- protected Object nextPreOrder( boolean skipChildren ) {
- if ( this.next != null ) {
- this.last = this.next;
-
- if ( !skipChildren ) {
- // The next node is the first child ...
- List children = this.view.getChildren(this.last);
- if ( children != null && children.size() != 0 ) {
- this.next = (TreeNode) children.get(0);
- return this.last;
- }
- }
-
- // If no children, the next node is the next sibling of this node ...
- this.next = getNextSibling(this.last);
- if ( this.next != null ) {
- return this.last; // found a next sibling ...
- }
-
- // If no next sibling, go up to the ancestor that has a next sibling
- TreeNode node = this.last;
- while ( ! isStartingNode(node) ) {
- node = this.view.getParent(node);
- // If there is no parent ...
- if ( node == null ) {
- break;
- }
- this.next = getNextSibling(node);
- if ( this.next != null ) {
- return this.last;
- }
- }
-
- // There's nothing left
- this.next = null;
- return this.last;
- }
- throw new
NoSuchElementException(CommonPlugin.Util.getString(ErrorMessageKeys.TREE_ERR_0012));
- }
-
- public void remove() {
- throw new
UnsupportedOperationException(CommonPlugin.Util.getString(ErrorMessageKeys.TREE_ERR_0013));
- }
-
- protected boolean isStartingNode( TreeNode node ) {
- return this.startingNodes.contains(node);
- }
-
- protected TreeNode getNextSibling( TreeNode node ) {
- // If the node is one of the starting nodes ...
- if ( this.startingNodes.contains(node) ) {
- int indexOfNode = this.startingNodes.indexOf(node);
- int indexOfNext = indexOfNode + 1;
- if ( indexOfNext != this.startingNodes.size() ) {
- return (TreeNode) this.startingNodes.get(indexOfNext);
- }
- return null;
- }
-
- TreeNode parent = this.view.getParent(node);
- if ( parent != null ) {
- List siblings = this.view.getChildren(parent);
- int indexOfNode = siblings.indexOf(node);
- int indexOfNext = indexOfNode + 1;
- if ( indexOfNext != siblings.size() ) {
- return (TreeNode) siblings.get(indexOfNext);
- }
- }
- return null;
- }
-
-}
-
Deleted:
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeNameComparator.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeNameComparator.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeNameComparator.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.tree;
-
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.util.ErrorMessageKeys;
-
-public class TreeNodeNameComparator implements TreeNodeComparator {
-
- private static final boolean DEFAULT_IGNORE_CASE = false;
-
-// private TreeNodeEditor editor = null;
- private boolean ignoreCase;
-
- public TreeNodeNameComparator( boolean ignoreCase ) {
- this.ignoreCase = ignoreCase;
- }
-
- public TreeNodeNameComparator() {
- this(DEFAULT_IGNORE_CASE);
- }
-
- public void setTreeNodeEditor( TreeNodeEditor editor ) {
- if ( editor == null ) {
- throw new
AssertionError(CommonPlugin.Util.getString(ErrorMessageKeys.TREE_ERR_0014));
- }
-// this.editor = editor;
- }
-
- public int compare(Object obj1, Object obj2){
- TreeNode entity1 = (TreeNode) obj1; // May throw ClassCastException
- TreeNode entity2 = (TreeNode) obj2; // May throw ClassCastException
- if ( entity1 == null && entity2 == null ) {
- return 0;
- }
- if ( entity1 != null && entity2 == null ) {
- return 1;
- }
- if ( entity1 == null && entity2 != null ) {
- return -1;
- }
- int result = 0;
- if ( this.ignoreCase ) {
- result = entity1.getName().compareToIgnoreCase(entity2.getName());
- } else {
- result = entity1.getName().compareTo(entity2.getName());
- }
-//System.out.println("-- Comparing " + entity1.getFullName() + " to "
+ entity2.getFullName() + " = " + result);
- return result;
- }
- public boolean equals(Object obj){
- // Both classes must match exactly!!!
- // Since this class has no state, there are no attributes to compare
- return ( obj != null && this.getClass() == obj.getClass() );
- }
-}
-
Deleted:
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodePathComparator.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodePathComparator.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodePathComparator.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -1,69 +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.tree;
-
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.util.ErrorMessageKeys;
-
-public class TreeNodePathComparator implements TreeNodeComparator {
-
-// private TreeNodeEditor editor = null;
-
- public void setTreeNodeEditor( TreeNodeEditor editor ) {
- if ( editor == null ) {
- throw new
AssertionError(CommonPlugin.Util.getString(ErrorMessageKeys.TREE_ERR_0014));
- }
-// this.editor = editor;
- }
-
- public int compare(TreeNode entry1, TreeNode entry2){
- if ( entry1 == null ) {
- throw new
AssertionError(CommonPlugin.Util.getString(ErrorMessageKeys.TREE_ERR_0015));
- }
- if ( entry2 == null ) {
- throw new
AssertionError(CommonPlugin.Util.getString(ErrorMessageKeys.TREE_ERR_0016));
- }
- String value1 = entry1.getFullName();
- String value2 = entry2.getFullName();
- if ( value1 == null ) {
- throw new
AssertionError(CommonPlugin.Util.getString(ErrorMessageKeys.TREE_ERR_0017));
- }
- if ( value2 == null ) {
- throw new
AssertionError(CommonPlugin.Util.getString(ErrorMessageKeys.TREE_ERR_0018));
- }
- return value1.compareTo(value1);
- }
- public boolean equals(TreeNodePathComparator comparator){
- if ( comparator == null ) {
- return false;
- }
- return ( comparator.getClass() == this.getClass() );
- }
- public int compare(Object entry1, Object entry2){
- throw new
ClassCastException(CommonPlugin.Util.getString(ErrorMessageKeys.TREE_ERR_0019));
- }
- public boolean equals(Object entry){
- throw new
ClassCastException(CommonPlugin.Util.getString(ErrorMessageKeys.TREE_ERR_0020));
- }
-}
-
Deleted:
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodePropertyComparator.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodePropertyComparator.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodePropertyComparator.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -1,83 +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.tree;
-
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.object.PropertyDefinition;
-import com.metamatrix.common.util.ErrorMessageKeys;
-
-public class TreeNodePropertyComparator implements TreeNodeComparator {
-
- private PropertyDefinition defn;
- private TreeNodeEditor editor = null;
-
- public void setTreeNodeEditor( TreeNodeEditor editor ) {
- if ( editor == null ) {
- throw new
AssertionError(CommonPlugin.Util.getString(ErrorMessageKeys.TREE_ERR_0014));
- }
- this.editor = editor;
- }
-
-
- public void setPropertyDefinition( PropertyDefinition defn ) {
- if ( defn == null ) {
- throw new
AssertionError(CommonPlugin.Util.getString(ErrorMessageKeys.TREE_ERR_0021));
- }
- this.defn = defn;
- }
-
- public int compare(TreeNode entry1, TreeNode entry2){
- if ( entry1 == null ) {
- throw new
AssertionError(CommonPlugin.Util.getString(ErrorMessageKeys.TREE_ERR_0015));
- }
- if ( entry2 == null ) {
- throw new
AssertionError(CommonPlugin.Util.getString(ErrorMessageKeys.TREE_ERR_0016));
- }
- if ( this.editor == null ) {
- throw new
AssertionError(CommonPlugin.Util.getString(ErrorMessageKeys.TREE_ERR_0014));
- }
- String value1 = this.editor.getValue(entry1,this.defn).toString();
- String value2 = this.editor.getValue(entry2,this.defn).toString();
- if ( value1 == null ) {
- if ( value2 == null ) {
- return 0;
- }
- return value2.compareTo(value1);
- }
- return value1.compareTo(value1);
- }
- public boolean equals(TreeNodePathComparator comparator){
- if ( comparator == null ) {
- return false;
- }
- return false;
-
- }
- public int compare(Object entry1, Object entry2){
- throw new
ClassCastException(CommonPlugin.Util.getString(ErrorMessageKeys.TREE_ERR_0019));
- }
- public boolean equals(Object entry){
- throw new
ClassCastException(CommonPlugin.Util.getString(ErrorMessageKeys.TREE_ERR_0020));
- }
-}
-
Deleted:
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeSource.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeSource.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeNodeSource.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -1,87 +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.tree;
-
-import java.util.List;
-
-/**
- * This interface defines an interface to a source of TreeNode information.
- */
-public interface TreeNodeSource {
-
- /**
- * Obtain the set of entries that are considered the children of the specified
- * TreeNode.
- * @param parent the TreeNode instance for which the child entries
- * are to be obtained; may not be null
- * @return the list of TreeNode instances that are considered the children
- * of the specified entry; never null but possibly empty
- */
- List getChildren(TreeNode parent);
-
- /**
- * Determine the parent TreeNode for the specified entry, or null if
- * the specified entry is a root.
- * @param entry the TreeNode instance for which the parent is to be obtained;
- * may not be null
- * @return the parent entry, or null if there is no parent
- */
- TreeNode getParent(TreeNode node);
-
- /**
- * Create a new instance of TreeNodeEditor, which is an editor that may
- * be used to access and/or modify a single TreeNode object.
- * @return the new editor instance; never null
- */
- TreeNodeEditor createTreeNodeEditor();
-
- /**
- * Determine whether the specified TreeNode may contain children.
- * @param entry the TreeNode instance that is to be checked; may
- * not be null
- * @return true if the entry can contain children, or false otherwise.
- */
- boolean allowsChildren(TreeNode node);
-
- /**
- * Determine whether the specified node is a child of the given parent node.
- * @return true if the node is a child of the given parent node.
- */
- boolean isParentOf(TreeNode parent, TreeNode child);
-
- /**
- * Determine whether the specified node is a descendent of the given ancestor node.
- * @return true if the node is a descendent of the given ancestor node.
- */
- boolean isAncestorOf(TreeNode ancestor, TreeNode descendent);
-
- /**
- * Determine whether the specified TreeNode is considered read-only
- * @param entry the TreeNode instance that is to be checked; may
- * not be null
- * @return true if the entry is read-only, or false otherwise.
- */
- boolean isReadOnly(TreeNode node);
-}
-
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeView.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeView.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/tree/TreeView.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -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.common.tree;
-
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import com.metamatrix.common.object.PropertiedObjectView;
-
-/**
- * This interface defines a view of a hierarchy of TreeNode instances.
- */
-public interface TreeView extends PropertiedObjectView {
-
- /**
- * Set the filter that limits the set of TreeNode instances
- * returned from this view.
- * @param filter the filter, or null if the default "pass-through" filter
should be used.
- */
- void setFilter(TreeNodeFilter filter);
-
- /**
- * Set the filter that limits the set of TreeNode instances
- * returned from this view.
- * @return the current filter; never null
- */
- TreeNodeFilter getFilter();
-
- /**
- * Set the comparator that should be used to order the children.
- * @param comparator the comparator, or null if entry name sorting should be used.
- */
- void setComparator(Comparator comparator);
-
- /**
- * Set the comparator that provides the order for children
- * returned from this view.
- * @return the current comparator; never null
- */
- Comparator getComparator();
-
- /**
- * Get the definitions of the properties for the TreeNode instances
- * returned from this view.
- * @return the unmodifiable list of PropertyDefinition instances; never null
- */
- List getPropertyDefinitions();
-
- /**
- * Returns all root partitians on this TreeNode system.
- * @return the unmodifiable list of TreeNode instances
- * that represent the roots
- */
- List getRoots();
-
- /**
- * Determine whether the specified TreeNode is a root of the underlying
- * system.
- * @param entry the TreeNode instance that is to be checked; may
- * not be null
- * @return true if the entry is a root, or false otherwise.
- */
- boolean isRoot(TreeNode entry);
-
- /**
- * Determine whether the specified TreeNode may contain children.
- * @param entry the TreeNode instance that is to be checked; may
- * not be null
- * @return true if the entry can contain children, or false otherwise.
- */
- boolean allowsChildren(TreeNode entry);
-
- /**
- * Determine whether the specified parent TreeNode may contain the
- * specified child node.
- * @param parent the TreeNode instance that is to be the parent;
- * may not be null
- * @param potentialChild the TreeNode instance that is to be the child;
- * may not be null
- * @return true if potentialChild can be placed as a child of parent,
- * or false otherwise.
- */
- boolean allowsChild(TreeNode parent, TreeNode potentialChild);
-
- /**
- * Determine whether the specified TreeNode is hidden.
- * @param entry the TreeNode instance that is to be checked; may
- * not be null
- * @return true if the entry is hidden, or false otherwise.
- */
- boolean isHidden(TreeNode entry);
-
- /**
- * Return the marked state of the specified entry.
- * @return the marked state of the entry.
- */
- boolean isMarked(TreeNode entry);
-
- /**
- * Set the marked state of the specified entry.
- * @param true if the node is to be marked, or false if it is to be un-marked.
- */
- void setMarked(TreeNode entry, boolean markedState);
-
- /**
- * Return the set of marked nodes for this view.
- * @param the unmodifiable set of marked nodes; never null
- */
- Set getMarked();
-
- /**
- * Obtain the TreeNode that represents the home for the underlying
- * system. If the underlying system does not support a home entry concept,
- * null is returned.
- * @return the entry that represents the home, or null if no home concept
- * is supported.
- */
- TreeNode getHome();
-
- /**
- * Obtain the abstract path for this TreeNode.
- * @return the string that represents the abstract path of this entry; never null
- */
- String getPath(TreeNode entry);
-
- /**
- * Obtain the character that is used to separate names in a path sequence for
- * the abstract path. This character is completely dependent upon the
implementation.
- * @return the charater used to delimit names in the abstract path.
- */
- char getSeparatorChar();
-
- /**
- * Obtain the character (as a String) that is used to separate names in a path
sequence for
- * the abstract path.
- * @return the string containing the charater used to delimit names in the abstract
path; never null
- */
- String getSeparator();
-
- /**
- * Determine the parent TreeNode for the specified entry, or null if
- * the specified entry is a root.
- * @param entry the TreeNode instance for which the parent is to be obtained;
- * may not be null
- * @return the parent entry, or null if there is no parent
- */
- TreeNode getParent(TreeNode entry);
-
- /**
- * Obtain the set of entries that are considered the children of the specified
- * TreeNode.
- * @param parent the TreeNode instance for which the child entries
- * are to be obtained; may not be null
- * @return the unmodifiable list of TreeNode instances that are considered the
children
- * of the specified entry; never null but possibly empty
- */
- List getChildren(TreeNode parent);
-
- /**
- * Determine whether the specified node is a child of the given parent node.
- * @return true if the node is a child of the given parent node.
- */
- boolean isParentOf(TreeNode parent, TreeNode child);
-
- /**
- * Determine whether the specified node is a descendent of the given ancestor node.
- * @return true if the node is a descendent of the given ancestor node.
- */
- boolean isAncestorOf(TreeNode ancestor, TreeNode descendent);
-
- /**
- * Return the tree node editor for this view.
- * @return the TreeNodeEditor instance
- */
- TreeNodeEditor getTreeNodeEditor();
-
- /**
- * Obtain an iterator for this whole view, which navigates the view's
- * nodes using pre-order rules (i.e., it visits a node before its children).
- * @return the iterator that traverses the nodes in this view; never null
- */
- Iterator iterator();
-
- /**
- * Obtain an iterator for the view starting at the specified node. This
- * implementation currently navigates the subtree using pre-order rules
- * (i.e., it visits a node before its children).
- * @param startingPoint the root of the subtree over which the iterator
- * is to navigate; may not be null
- * @return the iterator that traverses the nodes in the subtree starting
- * at the specified node; never null
- */
- Iterator iterator(TreeNode startingPoint);
-}
-
-
Deleted:
trunk/common-internal/src/main/java/com/metamatrix/common/vdb/api/SystemVdbUtility.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/vdb/api/SystemVdbUtility.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/vdb/api/SystemVdbUtility.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -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.vdb.api;
-
-import com.metamatrix.core.util.ResourceNameUtil;
-
-public class SystemVdbUtility {
-
- public static final String VDB_NAME = ResourceNameUtil.SYSTEM_NAME;;
- public static final String VIRTUAL_MODEL_NAME = ResourceNameUtil.SYSTEM_NAME;
- public static final String PHYSICAL_MODEL_NAME = ResourceNameUtil.SYSTEMPHYSICAL_NAME;
- public static final String ADMIN_PHYSICAL_MODEL_NAME =
ResourceNameUtil.SYSTEMADMINPHYSICAL_NAME;
-
- public final static String[] SYSTEM_MODEL_NAMES = {
- ResourceNameUtil.SYSTEM_NAME,
- ResourceNameUtil.SYSTEMPHYSICAL_NAME,
- ResourceNameUtil.SYSTEMADMIN_NAME,
- ResourceNameUtil.SYSTEMADMINPHYSICAL_NAME,
- ResourceNameUtil.SYSTEMSCHEMA_NAME,
- ResourceNameUtil.SYSTEMODBCMODEL,
- ResourceNameUtil.DATASERVICESYSTEMMODEL_NAME,
- ResourceNameUtil.WSDL1_1_NAME, ResourceNameUtil.WSDLSOAP_NAME,
- ResourceNameUtil.JDBCSYSTEM_NAME
- };
-
-
- /**
- * Return true if the specified model name matches the name of any system
- * model of TABLE_TYPES.SYSTEM_TYPE (match ignores case)
- */
- public final static boolean isSystemModelWithSystemTableType(String modelName) {
- for(int i=0; i < SYSTEM_MODEL_NAMES.length; i++) {
- String matchName = SYSTEM_MODEL_NAMES[i];
- if(matchName.equalsIgnoreCase(modelName)) {
- return true;
- }
- }
- return false;
- }
-}
Modified:
trunk/common-internal/src/main/java/com/metamatrix/common/vdb/api/VDBArchive.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/vdb/api/VDBArchive.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/vdb/api/VDBArchive.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -44,6 +44,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.protocol.URLHelper;
import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.core.CoreConstants;
import com.metamatrix.core.util.FileUtil;
import com.metamatrix.core.util.FileUtils;
import com.metamatrix.core.util.ObjectConverterUtil;
@@ -90,6 +91,10 @@
private boolean open;
private VDBKey key;
+
+ public final static boolean isSystemModelWithSystemTableType(String modelName) {
+ return CoreConstants.SYSTEM_MODEL.equalsIgnoreCase(modelName);
+ }
public static VDBArchive loadVDB(URL vdbURL, File deployDirectory) throws IOException {
boolean loadedFromDef = false;
Modified:
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/PermissionNode.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/PermissionNode.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/PermissionNode.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -23,12 +23,10 @@
package com.metamatrix.platform.admin.api;
import com.metamatrix.core.id.ObjectID;
-import com.metamatrix.common.tree.TreeNode;
-
import com.metamatrix.platform.admin.api.exception.PermissionNodeNotActionableException;
import com.metamatrix.platform.security.api.AuthorizationActions;
-public interface PermissionNode extends TreeNode {
+public interface PermissionNode {
/**
* Display name for node.
* @return The name of the data node for display.
Modified:
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/apiimpl/PermissionDataNodeImpl.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/apiimpl/PermissionDataNodeImpl.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/apiimpl/PermissionDataNodeImpl.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -22,14 +22,26 @@
package com.metamatrix.platform.admin.apiimpl;
+import java.io.PrintStream;
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
import com.metamatrix.admin.AdminMessages;
+import com.metamatrix.common.CommonPlugin;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.tree.basic.BasicTreeNode;
+import com.metamatrix.common.object.ObjectDefinition;
+import com.metamatrix.common.object.PropertyDefinition;
+import com.metamatrix.common.object.PropertyType;
+import com.metamatrix.common.util.ErrorMessageKeys;
import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.id.ObjectID;
import com.metamatrix.core.util.Assertion;
@@ -45,8 +57,30 @@
/**
* Defines a tree node for displaying entitlements.
*/
-public class PermissionDataNodeImpl extends BasicTreeNode implements PermissionDataNode,
Serializable, Comparable {
+public class PermissionDataNodeImpl implements PermissionDataNode, Serializable,
Comparable {
+ public static final char DELIMITER_CHAR = '.';
+ public static final String DELIMITER = "."; //$NON-NLS-1$
+
+ private ObjectID globalUID;
+ private ObjectDefinition type;
+ private boolean exists = true;
+ private String name;
+ private List children; // list of TreeNode refs
+ private List unmodifiableChildren;
+ private PermissionDataNodeImpl parent;
+ private boolean marked;
+ private boolean modified;
+
+ /**
+ * The holder for the property values for this entity, keyed upon the
+ * reference to the PropertyDefinition instance.
+ * @link aggregationByValue
+ * @supplierCardinality 0..1
+ */
+ private Map properties;
+// private Map unmodifiableProperties;
+
private int actionsCreatedWith;
private int descendantActions;
private AuthorizationActions actions;
@@ -69,12 +103,28 @@
* @param nodeIsPhysical Is this node physical are virtual.
* @param guid the globally-unique identifier for this instance; may not be null
*/
- public PermissionDataNodeImpl(BasicTreeNode parent,
+ public PermissionDataNodeImpl(PermissionDataNodeImpl parent,
AuthorizationActions allowedActions,
PermissionDataNodeDefinition nodeDefinition,
boolean nodeIsPhysical,
ObjectID guid) {
- super(parent, nodeDefinition.getDisplayName(), nodeDefinition, guid);
+ Assertion.isNotNull(nodeDefinition,"The ObjectDefinition reference may not be
null"); //$NON-NLS-1$
+ Assertion.isNotNull(guid,"The ObjectID reference may not be null");
//$NON-NLS-1$
+ this.type = nodeDefinition;
+ this.globalUID = guid;
+ this.children = new ArrayList(5);
+ this.unmodifiableChildren = Collections.unmodifiableList(this.children);
+ this.properties = new HashMap();
+// this.unmodifiableProperties = Collections.unmodifiableMap(this.properties);
+ this.setNameOfNode(nodeDefinition.getDisplayName());
+ this.modified = true; // by default, a new object is considered modified
+ if ( parent != null ) {
+ parent.addChild(this,nodeDefinition,-1); // this call may not be efficient
if 'exists' is false
+ this.setExists(true);
+ } else {
+ this.ensureNameIsValid();
+ this.setExists(true); // this must be a root entity that should be made
existent
+ }
this.allowedActions = allowedActions;
this.descendantActions = StandardAuthorizationActions.NONE_VALUE;
this.actions = StandardAuthorizationActions.NONE;
@@ -82,7 +132,7 @@
this.isHidden = false;
this.isPhysical = nodeIsPhysical;
this.hashCode = nodeDefinition.getName().hashCode();
- // BasicTreeNode is set to modified when created! Unset it.
+ // PermissionDataNodeImpl is set to modified when created! Unset it.
this.setModified(false, false);
}
@@ -440,56 +490,6 @@
}
/**
- * Returns true if the specified object is semantically equal to this instance.
- * Note: this method is consistent with <code>compareTo()</code>.
- * @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) {
- // Check if instances are identical ...
- if ( this == obj ) {
- return true;
- }
-
- // Check if object can be compared to this one
- // (this includes checking for null ) ...
- boolean areEqual = false;
- if ( obj instanceof PermissionDataNodeImpl ) {
- PermissionDataNodeImpl that = (PermissionDataNodeImpl) obj;
- // Must always have resourceNames
- areEqual = getType().getName().equals( that.getResourceName() );
- }
-
- return areEqual;
- }
- /**
- * Compares this object to another. If the specified object is not an instance of
- * the <code>PermissionDataNodeImpl</code> class, then this method 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>
- * @param obj the object that this instance is to be compared to; may not be null.
- * @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.
- */
- public int compareTo(Object obj) {
- PermissionDataNodeImpl that = (PermissionDataNodeImpl) obj; // May throw
ClassCastException
- if(obj == null){
-
Assertion.isNotNull(obj,SecurityPlugin.Util.getString(AdminMessages.ADMIN_0039));
- }
-
- if ( obj == this ) {
- return 0;
- }
-
- return compare(this, that);
- }
-
- /**
* Utility method to compare two PermissionDataNodeImpl instances. Returns a
negative integer, zero,
* or a positive integer as this object is less than, equal to, or greater than
* the specified object. <p>
@@ -520,13 +520,6 @@
/**
* Return stringafied representation of the object.
*/
- public String toString() {
- return getType().getName() + " " + this.actions; //$NON-NLS-1$
- }
-
- /**
- * Return stringafied representation of the object.
- */
public String printDebug() {
StringBuffer buf = new StringBuffer();
buf.append("\nResource: " + getType().getName()); //$NON-NLS-1$
@@ -735,4 +728,1012 @@
// }
// return true;
// }
+
+ /**
+ * Construct a new instance by specifying the parent that owns this entity,
+ * the name of the instance, the type of the instance and the global UID
+ * for the instance.
+ * <b>Note:</b> this constructor does <i>NOT</i> verify that
the name is valid within
+ * the parent's namespace.
+ * @param parent the parent that is considered the owning namespace for this
+ * instance; may be null if the new instance is to be the root
+ * @param name the name for the new entity instance; may be null or zero length
+ * if the node name is to be determined
+ * @param type the reference to the MetaModelEntity that defines the type
+ * of entity; may not be null
+ * @param guid the globally-unique identifier for this instance; may not be null
+ */
+ public PermissionDataNodeImpl(PermissionDataNodeImpl parent, String name,
ObjectDefinition defn, ObjectID guid ) {
+// Assertion.isNotNull(name,"The name may not be null");
+ Assertion.isNotNull(defn,"The ObjectDefinition reference may not be
null"); //$NON-NLS-1$
+ Assertion.isNotNull(guid,"The ObjectID reference may not be null");
//$NON-NLS-1$
+ this.type = defn;
+ this.globalUID = guid;
+ this.children = new ArrayList(5);
+ this.unmodifiableChildren = Collections.unmodifiableList(this.children);
+ this.properties = new HashMap();
+// this.unmodifiableProperties = Collections.unmodifiableMap(this.properties);
+ this.setNameOfNode(name);
+ this.modified = true; // by default, a new object is considered modified
+
+ if ( parent != null ) {
+ parent.addChild(this,defn,-1); // this call may not be efficient if
'exists' is false
+ this.setExists(true);
+ } else {
+ this.ensureNameIsValid();
+ this.setExists(true); // this must be a root entity that should be made
existent
+ }
+ }
+
+ // ########################## PropertiedObject Methods
###################################
+
+ // ########################## TreeNode Methods ###################################
+
+ /**
+ * Get this name of this entity. The name does not contain the namespace,
+ * but is unique within the namespace of the entity.
+ * @return the entity's name; never null or zero-length
+ */
+ public String getName(){
+ return this.name;
+ }
+
+ /**
+ * Get the actual or programmatic name of this property.
+ * @return the property's name (never null)
+ */
+ public String getFullName(){
+ return this.addFullName( new StringBuffer(), DELIMITER ).toString();
+ }
+ /**
+ * Get the actual or programmatic name of this property.
+ * @param delimiter the string delimiter to use between the names of nodes
+ * @return the property's name (never null)
+ */
+ public String getFullName(String delimiter){
+ return this.addFullName( new StringBuffer(), delimiter ).toString();
+ }
+ /**
+ * Helper method to build a string of the full name without having to
+ * construct a new StringBuffer in each node.
+ * <p>
+ * This method is implemented by having the node invoke this method on
+ * its parent (so that the parent can add its full name first), and then
+ * this node adds the delimiter and its name.
+ * @param sb the StringBuffer to which the name of this node should be appended
+ * @return the StringBuffer containing the full name of this node
+ */
+ protected StringBuffer addFullName(StringBuffer sb, String delimiter) {
+ if ( delimiter == null || delimiter.length() == 0 ) {
+ delimiter = DELIMITER;
+ }
+ StringBuffer result = sb;
+ if ( parent != null ) {
+ result = parent.addFullName(result,delimiter);
+ result.append(delimiter);
+ }
+ result.append(this.name);
+ return result;
+ }
+ /**
+ * Get the actual or programmatic name of this property.
+ * @return the property's name (never null)
+ */
+ public String getNamespace() {
+ if ( this.parent == null ) {
+ return ""; //$NON-NLS-1$
+ }
+ return this.parent.getFullName();
+ }
+
+ /**
+ * Get this type for this entity.
+ * @return the entity's type; never null
+ */
+ public ObjectDefinition getType() {
+ return this.type;
+ }
+
+ /**
+ * Return whether this TreeNode represents an existing metadata entity.
+ * <p>
+ * This attribute is set to true any time the object is part of a model,
+ * and it is set to false whenever the object is removed (deleted) from
+ * a model.
+ * @return true the entry exists, or false otherwise.
+ */
+ public boolean exists() {
+ return exists;
+ }
+
+ /**
+ * Ensure that the existance flag on this instance is set to the specified
+ * value. If the values are the same, this method simply returns without
+ * doing anything. However, if the existance value is different that the
+ * desired value, this method sets the existance value on this node and all
+ * of its children (recursively).
+ */
+ public void setExists( boolean value ) {
+ if ( this.exists != value ) {
+ this.exists = value;
+ Iterator iter = this.iterator();
+ while ( iter.hasNext() ) {
+ PermissionDataNodeImpl child = (PermissionDataNodeImpl) iter.next();
+ child.setExists(value);
+ }
+ }
+ }
+
+ /**
+ * Obtain the character that is used to separate names in a path sequence for
+ * the abstract path. This character is completely dependent upon the
implementation.
+ * @return the charater used to delimit names in the abstract path.
+ */
+ public char getSeparatorChar() {
+ return DELIMITER_CHAR;
+ }
+
+ /**
+ * Obtain the character (as a String) that is used to separate names in a path
sequence for
+ * the abstract path.
+ * @return the string containing the charater used to delimit names in the abstract
path; never null
+ */
+ public String getSeparator() {
+ return DELIMITER;
+ }
+
+ /**
+ * 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) {
+ // Check if instances are identical ...
+ if ( this == obj ) {
+ return true;
+ }
+
+ // Check if object can be compared to this one
+ // (this includes checking for null ) ...
+ //if ( this.getClass().isInstance(obj) ) {
+ if ( obj instanceof PermissionDataNodeImpl ) {
+ PermissionDataNodeImpl that = (PermissionDataNodeImpl) obj;
+ return ( this.globalUID.equals( that.getGlobalUID() ) );
+ }
+
+ // Otherwise not comparable ...
+ return false;
+ }
+ /**
+ * Compares this object to another. If the specified object is not an instance of
+ * the ModelEntity class, then this method 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>
+ * @param obj the object that this instance is to be compared to; may not be null.
+ * @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.
+ */
+ public int compareTo(Object obj) {
+ PermissionDataNodeImpl that = (PermissionDataNodeImpl) obj; // May throw
ClassCastException
+ Assertion.isNotNull(obj,"Attempt to compare null"); //$NON-NLS-1$
+ if ( obj == this ) {
+ return 0;
+ }
+
+ return this.globalUID.compareTo(that.getGlobalUID());
+ }
+ /**
+ * Returns a string representing the current state of the object.
+ * @return the string representation of this instance.
+ */
+ public String toString(){
+ return this.getName();
+ }
+
+ // ########################## Implementation Methods
###################################
+
+ public ObjectID getGlobalUID(){
+ return globalUID;
+ }
+
+ /**
+ * Use this with extreme care!!!!
+ */
+ protected void setGlobalUID(ObjectID newID){
+ if ( newID != null ) {
+ globalUID = newID;
+ }
+ }
+
+ public Iterator iterator() {
+ return this.unmodifiableChildren.iterator();
+ }
+
+ /**
+ * Return the immediate child of this object that has the specified name.
+ * @param name the name of the child to find; may not be null or zero-length
+ * @param ignoreCase flag specifying true if the names should be compared in
+ * a case-insensitive manner, or false if the names should compare in a
+ * case-sensitive manner.
+ * @return the list of children with the matching name, or null if no child is
found.
+ */
+ public List getChildren( String name, boolean ignoreCase ) {
+ Assertion.isNotNull(name,"The name reference may not be null");
//$NON-NLS-1$
+ Assertion.isNotZeroLength(name,"The name reference may not be
zero-length"); //$NON-NLS-1$
+ List result = new ArrayList();
+ Iterator iter = this.children.iterator();
+
+ // Break into one of two loops based upon 'ignoreCase'; this is
+ // done like this for runtime efficiency with the knowlege
+ // that there is duplicate code.
+ if ( ignoreCase ) {
+ while ( iter.hasNext() ) {
+ PermissionDataNodeImpl obj = (PermissionDataNodeImpl) iter.next();
+ if ( obj.getName().equalsIgnoreCase(name) ) {
+ result.add(obj);
+ }
+ }
+ } else {
+ while ( iter.hasNext() ) {
+ PermissionDataNodeImpl obj = (PermissionDataNodeImpl) iter.next();
+ if ( obj.getName().equals(name) ) {
+ result.add(obj);
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Return the immediate child of this object that has the specified name.
+ * @param name the name of the child to find; may not be null or zero-length
+ * @param ignoreCase flag specifying true if the names should be compared in
+ * a case-insensitive manner, or false if the names should compare in a
+ * case-sensitive manner.
+ * @return the child with the matching name, or null if no child is found.
+ */
+ public PermissionDataNodeImpl getChild( String name, ObjectDefinition defn, boolean
ignoreCase ) {
+ Assertion.isNotNull(name,"The name reference may not be null");
//$NON-NLS-1$
+ Assertion.isNotZeroLength(name,"The name reference may not be
zero-length"); //$NON-NLS-1$
+ Assertion.isNotNull(defn,"The ObjectDefinition reference may not be
null"); //$NON-NLS-1$
+ Iterator iter = this.children.iterator();
+
+ // Break into one of two loops based upon 'ignoreCase'; this is
+ // done like this for runtime efficiency with the knowlege
+ // that there is duplicate code.
+ if ( ignoreCase ) {
+ while ( iter.hasNext() ) {
+ PermissionDataNodeImpl obj = (PermissionDataNodeImpl) iter.next();
+ if ( defn.equals(obj.getType()) &&
obj.getName().equalsIgnoreCase(name) ) {
+ return obj;
+ }
+ }
+ } else {
+ while ( iter.hasNext() ) {
+ PermissionDataNodeImpl obj = (PermissionDataNodeImpl) iter.next();
+ if ( defn.equals(obj.getType()) && obj.getName().equals(name) )
{
+ return obj;
+ }
+ }
+ }
+ return null;
+ }
+
+ public int getIndexOfChild( PermissionDataNodeImpl child ) {
+ PermissionDataNodeImpl nodesParent = assertPermissionDataNodeImpl(child).parent;
+ Assertion.assertTrue(this==nodesParent,"The referenced child is not
contained in this entity"); //$NON-NLS-1$
+ Iterator iter = this.children.iterator();
+ int index = 0;
+ while ( iter.hasNext() ) {
+ if ( iter.next() == child ) {
+ return index;
+ }
+ ++index;
+ }
+ throw new
AssertionError(CommonPlugin.Util.getString(ErrorMessageKeys.TREE_ERR_0022));
+ }
+
+ /**
+ * Return the ordered list of children.
+ */
+ public List getChildren() {
+ return this.unmodifiableChildren;
+ }
+
+ /**
+ * Return true if this node is allowed to have any children.
+ */
+// public boolean getAllowsChildren() {
+// return CHILD_RULES.getAllowsChildren(this.getType());
+// }
+
+ /**
+ * Return true if this node currently does have any children.
+ */
+ public boolean hasChildren() {
+ return ( this.unmodifiableChildren.size() != 0 );
+ }
+
+ public int getChildCount() {
+ return this.unmodifiableChildren.size();
+ }
+
+ public boolean containsChildWithName( String name ) {
+ Assertion.isNotNull(name,"The name reference may not be null");
//$NON-NLS-1$
+ if ( name.length() == 0 ) {
+ return false;
+ }
+ Iterator iter = this.iterator();
+ while ( iter.hasNext() ) {
+ PermissionDataNodeImpl child = (PermissionDataNodeImpl) iter.next();
+ if ( child.getName().equals(name) ) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Set the name of this node.
+ * <b>Note:</b> this method does <i>NOT</i> verify that the
child's name is valid within this
+ * namespace
+ */
+ public void setName(String newName) {
+ this.setNameOfNode(newName);
+ this.ensureNameIsValid();
+ }
+
+ protected void setNameOfNode(String newName) {
+ this.name = newName;
+ PropertyDefinition nameDefn = this.getNamePropertyDefinition();
+ if ( nameDefn != null ) {
+ this.setPropertyValue(nameDefn,newName);
+ }
+ }
+
+ protected PermissionDataNodeImpl assertPermissionDataNodeImpl( PermissionDataNodeImpl
obj ) {
+ Assertion.isNotNull(obj,"The TreeNode reference may not be null");
//$NON-NLS-1$
+ Assertion.assertTrue(obj instanceof PermissionDataNodeImpl,"The referenced
object is not an PermissionDataNodeImpl"); //$NON-NLS-1$
+ return (PermissionDataNodeImpl) obj;
+ }
+
+ /**
+ * Get the model entity which which is the parent of this entity.
+ * @return the parent model entity, which may be null if no parent exists.
+ */
+ public PermissionDataNodeImpl getParent() {
+ return this.parent;
+ }
+
+ /**
+ * Determine whether this handle is the parent of the specified handle.
+ * The result of this method is equivalent to calling the following,
+ * although this method uses a much more efficient algorithm that
+ * does not rely upon string comparisons:
+ * <p>
+ * <code>return this.getFullName().equals( node.getNamespace() )</code>
+ * </p>
+ * @return true if this handle is the namespace of the specified node
+ */
+ public boolean isParentOf(PermissionDataNodeImpl node) {
+ PermissionDataNodeImpl nodesParent = assertPermissionDataNodeImpl(node).parent;
+ return ( this == nodesParent );
+ }
+
+ /**
+ * Determine whether this handle is an ancestor of the specified handle,
+ * The result of this method is equivalent to calling the following,
+ * although this method uses a much more efficient algorithm that
+ * does not rely upon string comparisons:
+ * <p>
+ * <code>return node.getNamespace().startsWith( this.getFullName()
)</code>
+ * </p>
+ * @return true if this handle is an ancestor of the specified node
+ */
+ public boolean isAncestorOf(PermissionDataNodeImpl node) {
+ PermissionDataNodeImpl ancestor = assertPermissionDataNodeImpl(node).parent;
+ while( ancestor != null ) {
+ if ( this == ancestor ) {
+ return true;
+ }
+ ancestor = assertPermissionDataNodeImpl(ancestor).parent;
+ }
+ return false;
+ }
+
+ /**
+ * Return whether this node has undergone changes. The time from which changes are
+ * maintained is left to the implementation.
+ * @return true if this TreeNode has changes, or false otherwise.
+ */
+ public boolean isModified() {
+ return this.modified;
+ }
+
+ /**
+ * Set the modified state of the TreeNode node.<br></br>Default behavior
is to
+ * set as modified the whole subtree starting with this node.
+ * @param marked the marked state of the node.
+ */
+ public void setModified(boolean modified) {
+ this.setModified(modified, true);
+ }
+
+ /**
+ * Set the modified state of the TreeNode node.
+ * @param modified the marked state of the node.
+ * @param recursive true if the whole subtree starting from this node should
+ * be set as modified, or false if only this node is to be set as modified.
+ */
+ public synchronized void setModified(boolean modified, boolean recursive) {
+ this.modified = modified;
+ if ( recursive ) {
+ Iterator iter = this.children.iterator();
+ while ( iter.hasNext() ) {
+ PermissionDataNodeImpl child = (PermissionDataNodeImpl) iter.next();
+ child.setModified(modified, true);
+ }
+ }
+ }
+
+ /**
+ * Return the marked state of the specified node.
+ * @return the marked state of the node.
+ */
+ public boolean isMarked() {
+ return this.marked;
+ }
+
+ /**
+ * Set the marked state of the TreeNode node.<br></br>Default behavior is
to
+ * mark the whole subtree from this node.
+ * @param marked the marked state of the node.
+ */
+ public void setMarked(boolean marked) {
+ this.setMarked(marked, true);
+ }
+
+ /**
+ * Set the marked state of the TreeNode node.
+ * @param marked the marked state of the node.
+ * @param recursive mark the whole subtree starting from this node.
+ */
+ public synchronized void setMarked(boolean marked, boolean recursive) {
+ this.marked = marked;
+ if ( recursive ) {
+ Iterator iter = this.children.iterator();
+ while ( iter.hasNext() ) {
+ PermissionDataNodeImpl child = (PermissionDataNodeImpl) iter.next();
+ child.setMarked(marked, true);
+ }
+ }
+ }
+
+ /**
+ * Return the set of marked nodes for this view.
+ * @param the unmodifiable set of marked nodes; never null
+ */
+ protected synchronized void addMarkedNodesToSet( Set result ) {
+ if ( this.isMarked() ) {
+ result.add(this);
+ }
+
+ PermissionDataNodeImpl child = null;
+ Iterator iter = this.children.iterator();
+ while ( iter.hasNext() ) {
+ child = (PermissionDataNodeImpl) iter.next();
+ child.addMarkedNodesToSet( result );
+ }
+ }
+
+ /**
+ * Go through the tree and find out the leaf nodes beneath this object.
+ * @return true if there are nodes below this node that are marked
+ */
+ public synchronized void findLeafNodes( Set leafNodes ) {
+ if ( this.getChildCount() == 0 ) {
+ leafNodes.add(this);
+ return;
+ }
+
+ // Otherwise, call this same method on all children ...
+ PermissionDataNodeImpl child = null;
+ Iterator iter = this.children.iterator();
+ while ( iter.hasNext() ) {
+ child = (PermissionDataNodeImpl) iter.next();
+ child.findLeafNodes( leafNodes );
+ }
+ }
+
+ /**
+ * Go through the tree and find out the top-level objects that are not marked
+ * and that do not have marked nodes beneath them, and find the leaf-level marked
+ * objects.
+ * @return true if there are nodes below this node that are marked
+ */
+ public synchronized boolean findMarkedAndUnmarkedNodes( Set unmarkedNodes, Set
markedLeafNodes ) {
+ // If this node is marked, go no further ...
+ if ( this.isMarked() ) {
+ this.findLeafNodes(markedLeafNodes);
+ return true;
+ }
+ unmarkedNodes.add(this);
+
+ // Otherwise, call this same method on all children ...
+ boolean childHasMarkedNodes = false;
+ PermissionDataNodeImpl child = null;
+ Iterator iter = this.children.iterator();
+ while ( iter.hasNext() ) {
+ child = (PermissionDataNodeImpl) iter.next();
+ if ( child.findMarkedAndUnmarkedNodes( unmarkedNodes, markedLeafNodes ) ) {
+ childHasMarkedNodes = true;
+ }
+ }
+
+ if ( childHasMarkedNodes ) {
+ unmarkedNodes.remove(this);
+ }
+ return childHasMarkedNodes;
+ }
+
+ /**
+ * Go through the tree and find out the top-level objects that are not marked
+ * and that do not have marked nodes beneath them, and find the leaf-level marked
+ * objects.
+ * @return true if there are nodes below this node that are marked
+ */
+ public synchronized void findTopLevelMarkedNodes( Set markedTopLevelNodes ) {
+ // If this node is marked, go no further ...
+ if ( this.isMarked() ) {
+ markedTopLevelNodes.add(this);
+ }
+
+ // Otherwise, call this same method on all children ...
+ PermissionDataNodeImpl child = null;
+ Iterator iter = this.children.iterator();
+ while ( iter.hasNext() ) {
+ child = (PermissionDataNodeImpl) iter.next();
+ child.findTopLevelMarkedNodes(markedTopLevelNodes);
+ }
+ }
+
+ public Collection getDecendant( String pathWithName, String delimiter, boolean
ignoreCase ) {
+ if ( delimiter == null || delimiter.length() == 0 ) {
+ delimiter = DELIMITER;
+ }
+ Set parents = new HashSet();
+ Set decendents = new HashSet();
+ parents.add(this);
+ PermissionDataNodeImpl parent = this;
+ StringTokenizer tokenizer = new StringTokenizer(pathWithName,delimiter);
+ while ( tokenizer.hasMoreTokens() ) {
+ String name = tokenizer.nextToken();
+ decendents.clear();
+ Iterator iter = parents.iterator();
+ while ( iter.hasNext() ) {
+ parent = (PermissionDataNodeImpl) iter.next();
+ decendents.addAll( parent.getChildren( name, ignoreCase ) );
+ }
+ parents.clear();
+ parents.addAll(decendents);
+ }
+ return decendents;
+ }
+
+ public Collection getDecendant( String pathWithName, boolean ignoreCase ) {
+ return getDecendant(pathWithName,DELIMITER,ignoreCase);
+ }
+
+ /**
+ * Remove from this node the specified child, null the parent reference
+ * of the node, and mark the node as non-existant.
+ * @param child the child entity
+ */
+ public synchronized void remove( PermissionDataNodeImpl child ) {
+ Assertion.assertTrue(child!=this,"The specified node may not be removed from
itself"); //$NON-NLS-1$
+ Assertion.isNotNull(child,"Unable to remove a null child reference");
//$NON-NLS-1$
+ boolean found = this.children.remove(child);
+ Assertion.assertTrue(found,"The specified child was not found within this
node"); //$NON-NLS-1$
+ child.parent = null;
+ child.setExists(false);
+ }
+
+ /**
+ * Remove from this node the child specified by the index, null the parent reference
+ * of the node, and mark the node as non-existant.
+ * @param index the index of the child to be removed
+ * @throws IndexOutOfBoundsException if the index is not within the range
+ * <code>0 <= newIndex < this.getChildCount()</code>
+ */
+ public synchronized void removeAll() {
+ Iterator iter = this.children.iterator();
+ PermissionDataNodeImpl child = null;
+ while ( iter.hasNext() ) {
+ child = (PermissionDataNodeImpl) iter.next();
+ child.parent = null;
+ child.setExists(false);
+ iter.remove();
+ }
+ }
+
+ /**
+ * Remove from this node the child specified by the index, null the parent reference
+ * of the node, and mark the node as non-existant.
+ * @param index the index of the child to be removed
+ * @throws IndexOutOfBoundsException if the index is not within the range
+ * <code>0 <= newIndex < this.getChildCount()</code>
+ */
+ public synchronized void remove(int index ) {
+ PermissionDataNodeImpl child = (PermissionDataNodeImpl)
this.children.remove(index);
+ child.parent = null;
+ child.setExists(false);
+ }
+
+ /**
+ * Move the child to a new index under the same parent.
+ * @param child the child entity
+ * @param newIndex the location
+ * @throws IndexOutOfBoundsException if the index is not within the range
+ * <code>0 <= newIndex < this.getChildCount()</code>
+ */
+ public synchronized void moveChild( PermissionDataNodeImpl child, int newIndex ) {
+ //this.remove(child); // this marks it as non-existant, instead to ...
+ Assertion.assertTrue(child!=this,"The specified node may not be removed from
itself"); //$NON-NLS-1$
+ Assertion.isNotNull(child,"Unable to remove a null child reference");
//$NON-NLS-1$
+ int currentIndex = this.children.indexOf(child);
+ if ( currentIndex == newIndex ) {
+ return;
+ }
+ boolean found = this.children.remove(child);
+ Assertion.assertTrue(found,"The specified child was not found within this
node"); //$NON-NLS-1$
+ int correctIndex = newIndex;
+ if ( currentIndex < newIndex ) {
+ // Change the location, because they computed the newIndex based upon the
+ // list WITH the child, and we just removed the child (essentially
decrementing
+ // their index
+
+ --correctIndex;
+ }
+ this.children.add(correctIndex,child);
+ }
+
+ /**
+ * Insert the node as a child of this node. If the child already has a parent,
+ * this method removes the child from that parent.
+ * <b>Note:</b> this method does <i>NOT</i> verify that the
child's name is valid within this
+ * namespace
+ * @param child the child entity
+ * @param newIndex the location
+ * @throws IndexOutOfBoundsException if the index is not within the range
+ * <code>0 <= newIndex <= this.getChildCount()</code>
+ */
+ public synchronized void insert( PermissionDataNodeImpl child, int index ) {
+ Assertion.isNotNull(child,"The child reference may not be null");
//$NON-NLS-1$
+ Assertion.assertTrue(child != this,"The specified node may not be added to
itself"); //$NON-NLS-1$
+ Assertion.assertTrue(child.getParent() != this,"The specified node is
already a child of this entity"); //$NON-NLS-1$
+
+ this.children.add(index,child); // ensures index is valid, so do this
first
+ if ( child.parent != null ) {
+ child.parent.children.remove(child); // doesn't mark node as
non-existant
+ }
+ child.parent = this; // remove from parent
+ child.setExists(true); // ensure that child is marked as
exists
+
+ // Check if this node already contains a child that has the same
+ // name and type as the new child; if there is an existing child,
+ // come up with the next valid name ...
+ this.ensureNameIsValid();
+ }
+
+ /**
+ * Insert the node as a child of this node, and place it at the end of this
+ * node's list of children. If the child already has a parent,
+ * this method removes the child from that parent.
+ * <p>
+ * <b>Note:</b> this method does <i>NOT</i> verify that the
child's name is valid within this
+ * namespace
+ * @param child the child entity
+ */
+ public synchronized void add( PermissionDataNodeImpl child ) {
+ Assertion.isNotNull(child,"The child reference may not be null");
//$NON-NLS-1$
+ Assertion.assertTrue(child != this,"The specified node may not be added to
itself"); //$NON-NLS-1$
+ Assertion.assertTrue(child.getParent() != this,"The specified node is
already a child of this entity"); //$NON-NLS-1$
+ addChild(child,child.getType(),-1); // add at end
+ }
+
+ /**
+ * Insert the node as a child of this node, and place it at the end of this
+ * node's list of children. If the child already has a parent,
+ * this method removes the child from that parent.
+ * <p>
+ * <b>Note:</b> this method does <i>NOT</i> verify that the
child's name is valid within this
+ * namespace
+ * @param child the child entity
+ */
+ public synchronized void add( PermissionDataNodeImpl child, int index ) {
+ Assertion.isNotNull(child,"The child reference may not be null");
//$NON-NLS-1$
+ Assertion.assertTrue(child != this,"The specified node may not be added to
itself"); //$NON-NLS-1$
+ Assertion.assertTrue(child.getParent() != this,"The specified node is
already a child of this entity"); //$NON-NLS-1$
+ addChild(child,child.getType(),index);
+ }
+
+ protected synchronized void addChild( PermissionDataNodeImpl child, ObjectDefinition
childType, int index ) {
+ // Check if this node can add the new child to its list of children
+ if ( this.addChildIsValid(child) ) {
+ if ( index == -1 ) {
+ this.children.add(child); // Add at the end
+ } else {
+ this.children.add(index,child); // Add at index, may throw
IndexOutOfBoundsException
+ }
+ if ( child.parent != null ) {
+ child.parent.children.remove(child); // doesn't mark node as
non-existant
+ }
+ child.parent = this; // remove from parent
+ child.setExists(true); // ensure that child is marked as
exists
+
+ // Check if this node already contains a child that has the same
+ // name and type as the new child; if there is an existing child,
+ // come up with the next valid name ...
+ child.ensureNameIsValid();
+ }
+ }
+
+ public Object getPropertyValue(PropertyDefinition propertyDefn) {
+ Object result =
resolveTypeFromString(this.properties.get(propertyDefn),propertyDefn);
+ if ( result == null && propertyDefn.hasDefaultValue() ) {
+ result = propertyDefn.getDefaultValue();
+ }
+ if ( result == null ) {
+ return result;
+ }
+
+ // This is a check to verify that the types correspond to types and that we
+ // are no longer using Collection to hold multi-valued properties
+ if ( result instanceof Collection && propertyDefn.getPropertyType() !=
PropertyType.LIST ) {
+ throw new AssertionError("The property value is a Collection but the
PropertyType is a " + propertyDefn.getPropertyType().getDisplayName() );
//$NON-NLS-1$
+ }
+ if ( result instanceof Set && propertyDefn.getPropertyType() !=
PropertyType.SET ) {
+ throw new AssertionError("The property value is a Set but the
PropertyType is a " + propertyDefn.getPropertyType().getDisplayName() );
//$NON-NLS-1$
+ }
+
+ return result;
+ }
+
+ public Object setPropertyValue(PropertyDefinition propertyDefn,Object value) {
+ Object previous =
this.properties.put(propertyDefn,convertTypeToString(value,propertyDefn));
+ // Check if the value has changed. If the old and new value are both null
+ // we assume the property was not modified. If old or new value is not null
+ // and does not satisify the .equals check then the value is modified and the
+ // node is marked accordingly
+ if ( (previous != null && !previous.equals(value)) || (value != null
&& !value.equals(previous)) ) {
+ this.setModified(true,false);
+ }
+// if ( previous != value ) {
+// this.setModified(true,false);
+// }
+ return previous;
+ }
+
+ /**
+ * hook to allow some PropertyDefinition values to be converted from String values
+ * before they are sent to clients of this Editor. Subclasses may override
+ * this method to convert custom types.
+ */
+ protected Object resolveTypeFromString(Object value, PropertyDefinition def) {
+ Object result = value;
+ if ( PropertyType.BOOLEAN.equals(def.getPropertyType()) ) {
+ if ( value instanceof String ) {
+ if ( Boolean.TRUE.toString().equalsIgnoreCase((String) value) ) {
+ result = Boolean.TRUE;
+ } else {
+ result = Boolean.FALSE;
+ }
+ }
+ }
+ //TODO: handle other types
+ return result;
+ }
+
+ /**
+ * hook to allow some PropertyDefinition values to be converted non-string values
+ * into Strings before they are set on the PropertiedObject. Subclasses may
override
+ * this method to convert custom types.
+ */
+ protected Object convertTypeToString(Object value, PropertyDefinition def) {
+ Object result = value;
+ if ( PropertyType.BOOLEAN.equals(def.getPropertyType()) ) {
+ if ( value instanceof Boolean ) {
+ result = value.toString();
+ }
+ }
+ //TODO: handle other types
+ return result;
+ }
+
+ public Object removePropertyValue(PropertyDefinition propertyDefn) {
+ return this.properties.remove(propertyDefn);
+ }
+
+ public Map getProperties() {
+ return this.properties;
+ }
+
+ public void print( PrintStream stream ) {
+ Assertion.isNotNull(stream,"The stream reference may not be null");
//$NON-NLS-1$
+ printInfo(stream);
+ PermissionDataNodeImpl child = null;
+ Iterator iter = this.iterator();
+ while ( iter.hasNext() ) {
+ child = (PermissionDataNodeImpl) iter.next();
+ //child.print(stream);
+ child.printInfo(stream);
+ }
+ }
+
+ protected String getEntityForm() {
+ return "PermissionDataNodeImpl"; //$NON-NLS-1$
+ }
+
+ protected void printInfo( PrintStream stream ) {
+ // Stream will never be null
+ stream.println(" \"" + this.getFullName() +
"\" <" + this.getEntityForm() + "> (Type=" + this.getType()
+ ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ protected PermissionDataNodeImpl find( ObjectID globalUID ) {
+ Assertion.isNotNull(globalUID,"The ObjectID reference may not be
null"); //$NON-NLS-1$
+ if ( this.globalUID.equals(globalUID) ) {
+ return this;
+ }
+
+ // Go through the children and see if they contain the object ...
+ PermissionDataNodeImpl result = null;
+ PermissionDataNodeImpl child = null;
+ Iterator iter = this.iterator();
+ while ( iter.hasNext() ) {
+ child = (PermissionDataNodeImpl) iter.next();
+ result = child.find(globalUID);
+ if ( result != null ) {
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * This method is used to determine the property definitions for this object.
+ * By default, this method returns an empty list.
+ */
+ protected List getPropertyDefinitions() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * This method is used to determine which, if any, of the property definitions for
this object
+ * are used to access the name.
+ * By default, this method returns null, meaning there is no name property
definition.
+ */
+ protected PropertyDefinition getNamePropertyDefinition() {
+ return null;
+ }
+
+ /**
+ * This method is used to determine which, if any, of the property definitions for
this object
+ * are used to access the description.
+ * By default, this method returns null, meaning there is no description property
definition.
+ */
+ protected PropertyDefinition getDescriptionPropertyDefinition() {
+ return null;
+ }
+
+ /**
+ * This method is used to determine whether two child nodes under a single parent
+ * are allowed to have the same name. By default, this method returns
<code>true</code>.
+ */
+ protected boolean areDuplicateChildNamesAllowed() {
+ return true;
+ }
+
+ /**
+ * This method is used to determine the default name for a node when that node has no
name.
+ * By default, this method returns the name of the node's type.
+ */
+ protected String getDefaultName() {
+ return this.type.getName();
+ }
+
+ protected boolean isValidNewName(String newName) {
+ if ( newName == null || newName.length() == 0 ) {
+ return false;
+ }
+ if ( newName.equals(this.name) ) {
+ return true;
+ }
+ if ( this.parent != null ) {
+ if ( this.areDuplicateChildNamesAllowed() ) {
+ return true;
+ }
+ if ( this.parent.containsChildWithName(newName) ) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * This method is called prior to adding the specified child to this
+ * TreeNode allowing any subclass to provide specific behavior if necessary.
+ * This implementation returns true by default.
+ */
+ protected boolean addChildIsValid( PermissionDataNodeImpl child ) {
+ return true;
+ }
+
+ /**
+ * Set the name of the new node (before its been added as a sibling to the nodes
+ * in <code>siblings</code>
+ */
+ protected void ensureNameIsValid() {
+ if ( this.name.length() == 0 ) {
+ this.setNameOfNode( this.getDefaultName() );
+ }
+ if ( areDuplicateChildNamesAllowed() ) {
+ return; // nothing to rename !!!
+ }
+ if ( this.parent == null ) {
+ return;
+ }
+ List siblings = this.parent.getChildren();
+ if ( siblings.size() == 1 ) {
+ return;
+ }
+
+ // Determine if there is a conflict ...
+ boolean rename = false;
+ Iterator iter = siblings.iterator();
+ PermissionDataNodeImpl sibling = null;
+ while ( iter.hasNext() ) {
+ sibling = (PermissionDataNodeImpl) iter.next();
+ if ( sibling != this && sibling.getName().equals(this.name) ) {
+ rename = true;
+ break;
+ }
+ }
+
+ if ( !rename ) {
+//System.out.println("setValidName(" + newNode.getFullName() + ") is NOT
renaming");
+ return;
+ }
+
+//System.out.println("setValidName(" + newNode.getFullName() + ") IS
renaming");
+ String newName = null;
+ int suffix = 1;
+ while ( newName == null ) {
+ String potentialName = this.name + suffix;
+ iter = siblings.iterator();
+ while ( iter.hasNext() ) {
+ sibling = (PermissionDataNodeImpl) iter.next();
+//System.out.println("setValidName(" + newNode.getFullName() + ") :
comparing " + potentialName + " to " + sibling.getName() );
+ if ( sibling != this && sibling.getName().equals(potentialName) )
{
+ potentialName = null;
+//System.out.println("setValidName(" + newNode.getFullName() + ") :
breaking " );
+ break;
+ }
+ }
+ if ( potentialName != null ) {
+//System.out.println("setValidName(" + newNode.getFullName() + ") : new
name = " + potentialName );
+ newName = potentialName;
+ }
+ ++suffix;
+ }
+ this.setNameOfNode(newName);
+ }
+
}
Modified:
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java
===================================================================
---
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -53,8 +53,6 @@
this.importProperties = importProperties;
schema = new Schema();
schema.setName(modelName);
- schema.setPhysical(true);
-
schema.setPrimaryMetamodelUri("http://www.metamatrix.com/metamodels/...;
//$NON-NLS-1$
setUUID(schema);
store.addSchema(schema);
}
Modified:
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java
===================================================================
---
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -29,7 +29,7 @@
private boolean physical = true;
private boolean isVisible = true;
- private String primaryMetamodelUri;
+ private String primaryMetamodelUri =
"http://www.metamatrix.com/metamodels/Relational"; //$NON-NLS-1$
private Map<String, Table> tables = new LinkedHashMap<String, Table>();
private Map<String, ProcedureRecordImpl> procedures = new LinkedHashMap<String,
ProcedureRecordImpl>();
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/AuthorizationService.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/dqp/service/AuthorizationService.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/engine/src/main/java/com/metamatrix/dqp/service/AuthorizationService.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -31,7 +31,6 @@
import com.metamatrix.api.exception.security.AuthorizationException;
import com.metamatrix.api.exception.security.AuthorizationMgmtException;
import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.core.CoreConstants;
import com.metamatrix.platform.security.api.AuthorizationPolicy;
import com.metamatrix.platform.security.api.AuthorizationRealm;
import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
@@ -55,8 +54,6 @@
public static final int CONTEXT_DELETE = 3;
public static final int CONTEXT_PROCEDURE = 4;
- public static final String DEFAULT_WSDL_USERNAME =
CoreConstants.DEFAULT_ANON_USERNAME;
-
public static final String ENTITELEMENTS_ENABLED =
"auth.check_entitlements"; //$NON-NLS-1$
public static final String ADMIN_ROLES_FILE = "auth.adminRolesFile";
//$NON-NLS-1$
Modified:
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/engine/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -56,7 +56,6 @@
public static final String DOMAIN_NAME = "domainName"; //$NON-NLS-1$
public static final String DEFAULT_ADMIN_USERNAME = "admin"; //$NON-NLS-1$
- public static final String DEFAULT_WSDL_USERNAME =
CoreConstants.DEFAULT_ANON_USERNAME;
public static final String ADMIN_PASSWORD = "membership.superUserPassword";
//$NON-NLS-1$
public static final String ADMIN_USERNAME = "membership.superUser";
//$NON-NLS-1$
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedRequestWorkItem.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedRequestWorkItem.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedRequestWorkItem.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -51,7 +51,7 @@
@Override
protected void processNew() throws MetaMatrixComponentException,
MetaMatrixProcessingException {
request.initMetadata();
- request.validateEntitlement(originalCommand);
+ request.validateAccess(originalCommand);
this.request = null;
}
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -107,9 +107,7 @@
this.vdbName = workContext.getVdbName();
this.vdbVersion = workContext.getVdbVersion();
- QueryMetadataInterface md = metadataService.lookupMetadata(vdbName, vdbVersion);
- // Defect 15029 - Use the QueryMetadataWrapper to hide models with private
visibility when resolving the command.
- this.metadata = new QueryMetadataWrapper(md, vdbName, vdbVersion, vdbService);
+ this.metadata = metadataService.lookupMetadata(vdbName, vdbVersion);
// If multi-source, use the multi-source wrapper as well
Collection multiModels = vdbService.getMultiSourceModels(vdbName, vdbVersion);
Deleted:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/QueryMetadataWrapper.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/QueryMetadataWrapper.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/QueryMetadataWrapper.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -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 org.teiid.dqp.internal.process;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.BasicQueryMetadataWrapper;
-
-/**
- * This classs is a proxy to QueryMetadataInterface. It knows VDBService
- * and VNB name.
- */
-public class QueryMetadataWrapper extends BasicQueryMetadataWrapper{
- private String vdbName;
- private String vdbVersion;
- private VDBService vdbService;
-
- public QueryMetadataWrapper(QueryMetadataInterface actualMetadata, String vdbName,
String vdbVersion, VDBService vdbService){
- super(actualMetadata);
- this.vdbName = vdbName;
- this.vdbService = vdbService;
- this.vdbVersion = vdbVersion;
- }
-
- protected QueryMetadataInterface getActualMetadata() {
- return this.actualMetadata;
- }
- protected String getVdbName() {
- return this.vdbName;
- }
- protected VDBService getVdbService() {
- return this.vdbService;
- }
- protected String getVdbVersion() {
- return this.vdbVersion;
- }
-
- /**
- * @see
com.metamatrix.query.metadata.QueryMetadataInterface#getGroupsForPartialName(java.lang.String)
- */
- public Collection getGroupsForPartialName(String partialGroupName) throws
MetaMatrixComponentException, QueryMetadataException {
- Collection result = actualMetadata.getGroupsForPartialName(partialGroupName);
- if(result == null || result.isEmpty()){
- return result;
- }
- Collection filteredResult = new HashSet();
- Iterator iter = result.iterator();
- while(iter.hasNext()){
- String groupName = (String)iter.next();
- Object groupID = actualMetadata.getGroupID(groupName);
- Object modelID = actualMetadata.getModelID(groupID);
- String modelName = actualMetadata.getFullName(modelID);
- int visibility = vdbService.getModelVisibility(vdbName, vdbVersion, modelName);
- if(visibility == ModelInfo.PUBLIC){
- filteredResult.add(groupName);
- }
- }
- return filteredResult;
- }
-
-}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-11-30
15:24:24 UTC (rev 1605)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -37,7 +37,6 @@
import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
import org.teiid.dqp.internal.process.multisource.MultiSourcePlanToProcessConverter;
import org.teiid.dqp.internal.process.validator.AuthorizationValidationVisitor;
-import org.teiid.dqp.internal.process.validator.ModelVisibilityValidationVisitor;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
@@ -211,9 +210,6 @@
this.metadata = new TempMetadataAdapter(metadata, new TempMetadataStore());
- //wrap metadata in the wrapper that knows VDBService
- this.metadata = new QueryMetadataWrapper(this.metadata, this.vdbName,
this.vdbVersion, this.vdbService);
-
// Check for multi-source models and further wrap the metadata interface
List multiSourceModelList = vdbService.getMultiSourceModels(this.vdbName,
this.vdbVersion);
if(multiSourceModelList != null && multiSourceModelList.size() > 0) {
@@ -302,18 +298,12 @@
this.userCommand = (Command)command.clone();
}
- private void validateQuery(Command command, boolean validateVisibility)
+ private void validateQuery(Command command)
throws QueryValidatorException, MetaMatrixComponentException {
// Create generic sql validation visitor
AbstractValidationVisitor visitor = new ValidationVisitor();
validateWithVisitor(visitor, metadata, command, false);
-
- if (validateVisibility) {
- // Create model visibility validation visitor
- visitor = new ModelVisibilityValidationVisitor(this.vdbService, this.vdbName,
this.vdbVersion);
- validateWithVisitor(visitor, metadata, command, true);
- }
}
private Command parseCommand() throws QueryParserException {
@@ -452,7 +442,7 @@
createCommandContext();
- validateQuery(command, true);
+ validateQuery(command);
command = QueryRewriter.rewrite(command, null, metadata, context);
@@ -573,7 +563,7 @@
Command processingCommand = generatePlan();
- validateEntitlement(userCommand);
+ validateAccess(userCommand);
setSchemasForXMLPlan(userCommand, metadata);
@@ -594,10 +584,10 @@
referenceCheck(references);
- validateQuery(newCommand, isRootXQuery);
+ validateQuery(newCommand);
if (isRootXQuery) {
- validateEntitlement(newCommand);
+ validateAccess(newCommand);
}
CommandContext copy = (CommandContext) commandContext.clone();
@@ -610,28 +600,13 @@
return new QueryProcessor(plan, copy, bufferManager, processorDataManager);
}
- protected void validateEntitlement(Command command)
+ protected void validateAccess(Command command)
throws QueryValidatorException, MetaMatrixComponentException {
// Validate the query (may only want to validate entitlement)
- AuthorizationService authSvc = (AuthorizationService) this.env
- .findService(DQPServiceNames.AUTHORIZATION_SERVICE);
- if (authSvc != null) {
- // See if entitlement checking is turned on
- if (authSvc.checkingEntitlements()) {
- AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(
- this.workContext.getConnectionID(), authSvc);
- validateWithVisitor(visitor, this.metadata, command, true);
- } else if (workContext.getUserName().equals(
- AuthorizationService.DEFAULT_WSDL_USERNAME)) {
- if (command.getType() == Command.TYPE_STORED_PROCEDURE &&
-
AuthorizationValidationVisitor.GET_UPDATED_CHARACTER_VDB_RESOURCE.contains(((StoredProcedure)
command).getProcedureName())) {
- // do nothing... this is valid
- } else {
- // Throw an exception since the WSDL user is trying to do something other than
access the VDB resources
- final String message =
DQPPlugin.Util.getString("Request.wsdl_user_not_authorized"); //$NON-NLS-1$
- throw new QueryValidatorException(message);
- }
- }
- }
+ AuthorizationService authSvc = (AuthorizationService)
this.env.findService(DQPServiceNames.AUTHORIZATION_SERVICE);
+
+ // See if entitlement checking is turned on
+ AuthorizationValidationVisitor visitor = new
AuthorizationValidationVisitor(this.workContext.getConnectionID(), authSvc,
this.vdbService, this.vdbName, this.vdbVersion);
+ validateWithVisitor(visitor, this.metadata, command, true);
}
}
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -30,15 +30,16 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.teiid.dqp.internal.process.multisource.MultiSourceElement;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.common.vdb.api.ModelInfo;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.service.AuthorizationService;
+import com.metamatrix.dqp.service.VDBService;
import com.metamatrix.query.function.FunctionLibrary;
import com.metamatrix.query.metadata.TempMetadataID;
import com.metamatrix.query.resolver.util.ResolverUtil;
@@ -58,66 +59,82 @@
public class AuthorizationValidationVisitor extends AbstractValidationVisitor {
- /**
- * This virtual procedure must be accessible to all users in order to read the WSDL
- * for web services.
- */
- public final static String GET_UPDATED_CHARACTER_VDB_RESOURCE =
"System.getUpdatedCharacterVDBResource"; //$NON-NLS-1$
-
- /**
- * Set of procedures which must be available to all users.
- */
- private static Set globallyAccessibleProcedures = new HashSet();
-
private String connectionID;
private AuthorizationService authInterface;
-
-
- static {
- globallyAccessibleProcedures.add(GET_UPDATED_CHARACTER_VDB_RESOURCE);
- }
-
-
+ private VDBService vdbService;
+ private String vdbName;
+ private String vdbVersion;
+
public AuthorizationValidationVisitor(
String connectionID,
- AuthorizationService authInterface) {
- super();
-
+ AuthorizationService authInterface,
+ VDBService vdbService,
+ String vdbName,
+ String vdbVersion) {
this.connectionID = connectionID;
this.authInterface = authInterface;
+ this.vdbService = vdbService;
+ this.vdbName = vdbName;
+ this.vdbVersion = vdbVersion;
}
// ############### Visitor methods for language objects ##################
+
+ @Override
+ public void visit(GroupSymbol obj) {
+ try {
+ Object modelID = getMetadata().getModelID(obj.getMetadataID());
+ this.validateModelVisibility(modelID, obj);
+ } catch(QueryMetadataException e) {
+ handleException(e, obj);
+ } catch(MetaMatrixComponentException e) {
+ handleException(e, obj);
+ }
+ }
public void visit(Delete obj) {
- validateEntitlements(obj);
+ if (this.authInterface != null && this.authInterface.checkingEntitlements())
{
+ validateEntitlements(obj);
+ }
}
public void visit(Insert obj) {
- validateEntitlements(obj);
+ if (this.authInterface != null && this.authInterface.checkingEntitlements())
{
+ validateEntitlements(obj);
+ }
}
public void visit(Query obj) {
- validateEntitlements(obj);
+ if (this.authInterface != null && this.authInterface.checkingEntitlements())
{
+ validateEntitlements(obj);
+ }
}
public void visit(Update obj) {
- validateEntitlements(obj);
+ if (this.authInterface != null && this.authInterface.checkingEntitlements())
{
+ validateEntitlements(obj);
+ }
}
public void visit(StoredProcedure obj) {
- validateEntitlements(obj);
+ this.validateModelVisibility(obj.getModelID(), obj.getGroup());
+ if (this.authInterface != null && this.authInterface.checkingEntitlements())
{
+ validateEntitlements(obj);
+ }
}
public void visit(Function obj) {
if (FunctionLibrary.LOOKUP.equalsIgnoreCase(obj.getName())) {
try {
- List<Symbol> symbols = new LinkedList<Symbol>();
ResolverUtil.ResolvedLookup lookup = ResolverUtil.resolveLookup(obj,
this.getMetadata());
- symbols.add(lookup.getGroup());
- symbols.add(lookup.getKeyElement());
- symbols.add(lookup.getReturnElement());
- validateEntitlements(symbols, AuthorizationService.ACTION_READ,
AuthorizationService.CONTEXT_QUERY);
+
validateModelVisibility(getMetadata().getModelID(lookup.getGroup().getMetadataID()),
lookup.getGroup());
+ if (this.authInterface != null &&
this.authInterface.checkingEntitlements()) {
+ List<Symbol> symbols = new LinkedList<Symbol>();
+ symbols.add(lookup.getGroup());
+ symbols.add(lookup.getKeyElement());
+ symbols.add(lookup.getReturnElement());
+ validateEntitlements(symbols, AuthorizationService.ACTION_READ,
AuthorizationService.CONTEXT_QUERY);
+ }
} catch (MetaMatrixComponentException e) {
handleException(e, obj);
} catch (MetaMatrixProcessingException e) {
@@ -207,31 +224,10 @@
validateEntitlements(entitledObjects, AuthorizationService.ACTION_READ,
AuthorizationService.CONTEXT_QUERY);
}
-
/**
- * Add a procedure to the list of globally
- * @param name
- * @since 4.2
- */
- public static void addGloballyAccessibleProcedure(String name) {
- globallyAccessibleProcedures.add(name);
- }
-
- public static void removeGloballyAccessibleProcedure(String name) {
- globallyAccessibleProcedures.remove(name);
- }
-
-
- /**
* Validate query entitlements
*/
protected void validateEntitlements(StoredProcedure obj) {
- //Skip entitlement checking for any globally available procedures.
- if (globallyAccessibleProcedures.contains(obj.getProcedureName())) {
- return;
- }
-
-
List symbols = new ArrayList(1);
symbols.add(obj.getGroup());
validateEntitlements(symbols, AuthorizationService.ACTION_READ,
AuthorizationService.CONTEXT_PROCEDURE);
@@ -308,4 +304,19 @@
}
+ protected void validateModelVisibility(Object modelID, GroupSymbol group) {
+ if(modelID instanceof TempMetadataID){
+ return;
+ }
+ try {
+ String modelName = getMetadata().getFullName(modelID);
+ int visibility = this.vdbService.getModelVisibility(this.vdbName, this.vdbVersion,
modelName);
+ if(visibility != ModelInfo.PUBLIC) {
+ handleValidationError(DQPPlugin.Util.getString("ERR.018.005.0088",
getMetadata().getFullName(group.getMetadataID()))); //$NON-NLS-1$
+ }
+ } catch (MetaMatrixComponentException e) {
+ handleException(e, group);
+ }
+ }
+
}
Deleted:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/ModelVisibilityValidationVisitor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/ModelVisibilityValidationVisitor.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/ModelVisibilityValidationVisitor.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -1,138 +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.dqp.internal.process.validator;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
-import com.metamatrix.query.validator.AbstractValidationVisitor;
-
-/**
- */
-public class ModelVisibilityValidationVisitor extends AbstractValidationVisitor {
-
- private VDBService vdbService;
- private String vdbName;
- private String vdbVersion;
-
- /**
- *
- */
- public ModelVisibilityValidationVisitor(VDBService vdbService, String vdbName, String
vdbVersion ) {
- super();
-
- this.vdbService = vdbService;
- this.vdbName = vdbName;
- this.vdbVersion = vdbVersion;
- }
-
- // ############### Visitor methods for language objects ##################
-
- public void visit(Delete obj) {
- validateModelVisibility(obj);
- }
-
- public void visit(Insert obj) {
- validateModelVisibility(obj);
- }
-
- public void visit(Query obj) {
- validateModelVisibility(obj);
- }
-
- public void visit(Update obj) {
- validateModelVisibility(obj);
- }
-
- public void visit(StoredProcedure obj) {
- validateModelVisibility(obj);
- }
-
- public void visit(Function obj) {
- if (FunctionLibrary.LOOKUP.equalsIgnoreCase(obj.getName())) {
- try {
- ResolverUtil.ResolvedLookup resolvedLookup = ResolverUtil.resolveLookup(obj,
getMetadata());
-
validateModelVisibility(getMetadata().getModelID(resolvedLookup.getGroup().getMetadataID()),
resolvedLookup.getGroup());
- } catch (QueryResolverException e) {
- handleException(e, obj);
- } catch (MetaMatrixComponentException e) {
- handleException(e, obj);
- }
- }
- }
-
- // ######################### Validation methods #########################
-
- protected void validateModelVisibility(Command obj) {
- // first get list of groups from command
- Collection groups = GroupCollectorVisitor.getGroups(obj, true);
-
- try {
- // collect models used by this command
- Iterator groupIter = groups.iterator();
- while(groupIter.hasNext()) {
- GroupSymbol group = (GroupSymbol) groupIter.next();
- Object modelID = null;
- if(obj instanceof StoredProcedure){
- modelID = ((StoredProcedure)obj).getModelID();
- }else{
- modelID = getMetadata().getModelID(group.getMetadataID());
- }
- if(modelID instanceof TempMetadataID){
- return;
- }
- validateModelVisibility(modelID, group);
- }
- } catch(QueryMetadataException e) {
- handleException(e, obj);
- } catch(MetaMatrixComponentException e) {
- handleException(e, obj);
- }
- }
-
- protected void validateModelVisibility(Object modelID, GroupSymbol group) throws
QueryMetadataException, MetaMatrixComponentException {
- String modelName = getMetadata().getFullName(modelID);
- int visibility = this.vdbService.getModelVisibility(this.vdbName, this.vdbVersion,
modelName);
- if(visibility != ModelInfo.PUBLIC) {
- handleValidationError(DQPPlugin.Util.getString("ERR.018.005.0088",
getMetadata().getFullName(group.getMetadataID()))); //$NON-NLS-1$
- }
- }
-}
Modified: trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java 2009-11-30
15:24:24 UTC (rev 1605)
+++ trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -37,7 +37,6 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.metadata.runtime.api.MetadataSource;
-import com.metamatrix.query.QueryPlugin;
/**
* Aggregates the metadata from multiple stores.
@@ -83,44 +82,42 @@
* @param partialGroupName
* @return
*/
- public Collection<String> getGroupsForPartialName(String partialGroupName) {
- List<String> result = new LinkedList<String>();
+ public Collection<Table> getGroupsForPartialName(String partialGroupName) {
+ List<Table> result = new LinkedList<Table>();
for (Schema schema : getSchemas().values()) {
for (Table t : schema.getTables().values()) {
String fullName = t.getFullName();
if (fullName.regionMatches(true, fullName.length() - partialGroupName.length(),
partialGroupName, 0, partialGroupName.length())) {
- result.add(fullName);
+ result.add(t);
}
}
}
return result;
}
- public ProcedureRecordImpl getStoredProcedure(String name)
+ public Collection<ProcedureRecordImpl> getStoredProcedure(String name)
throws MetaMatrixComponentException, QueryMetadataException {
+ List<ProcedureRecordImpl> result = new LinkedList<ProcedureRecordImpl>();
int index = name.indexOf(TransformationMetadata.DELIMITER_STRING);
if (index > -1) {
String schema = name.substring(0, index);
- ProcedureRecordImpl result =
getSchema(schema).getProcedures().get(name.substring(index + 1));
- if (result != null) {
+ ProcedureRecordImpl proc = getSchema(schema).getProcedures().get(name.substring(index
+ 1));
+ if (proc != null) {
+ result.add(proc);
return result;
}
}
- ProcedureRecordImpl result = null;
//assume it's a partial name
name = TransformationMetadata.DELIMITER_STRING + name;
for (Schema schema : getSchemas().values()) {
for (ProcedureRecordImpl p : schema.getProcedures().values()) {
String fullName = p.getFullName();
if (fullName.regionMatches(true, fullName.length() - name.length(), name, 0,
name.length())) {
- if (result != null) {
- throw new
QueryMetadataException(QueryPlugin.Util.getString("ambiguous_procedure",
name.substring(1))); //$NON-NLS-1$
- }
- result = p;
+ result.add(p);
}
}
}
- if (result == null) {
+ if (result.isEmpty()) {
throw new
QueryMetadataException(name+TransformationMetadata.NOT_EXISTS_MESSAGE);
}
return result;
Modified: trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java 2009-11-30
15:24:24 UTC (rev 1605)
+++ trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -26,7 +26,6 @@
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@@ -53,11 +52,14 @@
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.common.properties.UnmodifiableProperties;
import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.vdb.api.ModelInfo;
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.core.util.LRUCache;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.dqp.DQPPlugin;
+import com.metamatrix.dqp.service.VDBService;
import com.metamatrix.metadata.runtime.api.MetadataSourceUtil;
+import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.mapping.relational.QueryNode;
import com.metamatrix.query.mapping.xml.MappingDocument;
import com.metamatrix.query.mapping.xml.MappingLoader;
@@ -83,20 +85,28 @@
private static UnmodifiableProperties EMPTY_PROPS = new UnmodifiableProperties(new
Properties());
private final CompositeMetadataStore store;
+ private String vdbVersion;
+ private VDBService vdbService;
/*
* TODO: move caching to jboss cache structure
*/
private final Map<String, Object> metadataCache =
Collections.synchronizedMap(new LRUCache<String, Object>(500));
- private final Map<String, String> partialNameToFullNameCache =
Collections.synchronizedMap(new LRUCache<String, String>(1000));
- private final Map<String, StoredProcedureInfo> procedureCache =
Collections.synchronizedMap(new LRUCache<String, StoredProcedureInfo>(200));
+ private final Map<String, Collection<Table>> partialNameToFullNameCache =
Collections.synchronizedMap(new LRUCache<String, Collection<Table>>(1000));
+ private final Map<String, Collection<StoredProcedureInfo>> procedureCache
= Collections.synchronizedMap(new LRUCache<String,
Collection<StoredProcedureInfo>>(200));
/**
* TransformationMetadata constructor
* @param context Object containing the info needed to lookup metadta.
*/
public TransformationMetadata(final CompositeMetadataStore store) {
+ this(store, null, null);
+ }
+
+ public TransformationMetadata(final CompositeMetadataStore store, VDBService service,
String vdbVersion) {
ArgCheck.isNotNull(store);
this.store = store;
+ this.vdbService = service;
+ this.vdbVersion = vdbVersion;
}
//==================================================================================
@@ -124,20 +134,27 @@
throws MetaMatrixComponentException, QueryMetadataException {
ArgCheck.isNotEmpty(partialGroupName);
- String groupName = this.partialNameToFullNameCache.get(partialGroupName);
+ Collection<Table> matches =
this.partialNameToFullNameCache.get(partialGroupName);
- if (groupName != null) {
- return Arrays.asList(groupName);
+ if (matches == null) {
+ String partialName = DELIMITER_CHAR + partialGroupName.toLowerCase();
+
+ matches = getMetadataStore().getGroupsForPartialName(partialName);
+
+ this.partialNameToFullNameCache.put(partialGroupName, matches);
}
- String partialName = DELIMITER_CHAR + partialGroupName.toLowerCase();
-
- Collection result = getMetadataStore().getGroupsForPartialName(partialName);
-
- if (result.size() == 1) {
- this.partialNameToFullNameCache.put(partialGroupName,
(String)result.iterator().next());
- }
- return result;
+ if (matches.isEmpty()) {
+ return Collections.emptyList();
+ }
+
+ Collection<String> filteredResult = new ArrayList<String>(matches.size());
+ for (Table table : matches) {
+ if (vdbService == null ||
vdbService.getModelVisibility(getVirtualDatabaseName(), vdbVersion,
table.getParent().getName()) == ModelInfo.PUBLIC) {
+ filteredResult.add(table.getFullName());
+ }
+ }
+ return filteredResult;
}
/* (non-Javadoc)
@@ -244,64 +261,80 @@
throws MetaMatrixComponentException, QueryMetadataException {
ArgCheck.isNotEmpty(fullyQualifiedProcedureName);
String lowerGroupName = fullyQualifiedProcedureName.toLowerCase();
- StoredProcedureInfo procInfo = this.procedureCache.get(lowerGroupName);
+ Collection<StoredProcedureInfo> results =
this.procedureCache.get(lowerGroupName);
- if (procInfo != null) {
- return procInfo;
- }
-
- ProcedureRecordImpl procRecord =
getMetadataStore().getStoredProcedure(lowerGroupName);
+ if (results == null) {
+ Collection<ProcedureRecordImpl> procRecords =
getMetadataStore().getStoredProcedure(lowerGroupName);
+ results = new ArrayList<StoredProcedureInfo>(procRecords.size());
+ for (ProcedureRecordImpl procRecord : procRecords) {
+ String procedureFullName = procRecord.getFullName();
- String procedureFullName = procRecord.getFullName();
+ // create the storedProcedure info object that would hold procedure's
metadata
+ StoredProcedureInfo procInfo = new StoredProcedureInfo();
+ procInfo.setProcedureCallableName(procedureFullName);
+ procInfo.setProcedureID(procRecord);
- // create the storedProcedure info object that would hold procedure's
metadata
- procInfo = new StoredProcedureInfo();
- procInfo.setProcedureCallableName(procedureFullName);
- procInfo.setProcedureID(procRecord);
+ // modelID for the procedure
+ procInfo.setModelID(procRecord.getSchema());
- // modelID for the procedure
- procInfo.setModelID(procRecord.getSchema());
+ // get the parameter metadata info
+ for (ProcedureParameter paramRecord : procRecord.getParameters()) {
+ String runtimeType = paramRecord.getRuntimeType();
+ int direction =
this.convertParamRecordTypeToStoredProcedureType(paramRecord.getType());
+ // create a parameter and add it to the procedure object
+ SPParameter spParam = new SPParameter(paramRecord.getPosition(),
direction, paramRecord.getName());
+ spParam.setMetadataID(paramRecord);
+ spParam.setClassType(DataTypeManager.getDataTypeClass(runtimeType));
+ procInfo.addParameter(spParam);
+ }
- // get the parameter metadata info
- for (ProcedureParameter paramRecord : procRecord.getParameters()) {
- String runtimeType = paramRecord.getRuntimeType();
- int direction =
this.convertParamRecordTypeToStoredProcedureType(paramRecord.getType());
- // create a parameter and add it to the procedure object
- SPParameter spParam = new SPParameter(paramRecord.getPosition(), direction,
paramRecord.getName());
- spParam.setMetadataID(paramRecord);
- spParam.setClassType(DataTypeManager.getDataTypeClass(runtimeType));
- procInfo.addParameter(spParam);
- }
+ // if the procedure returns a resultSet, obtain resultSet metadata
+ if(procRecord.getResultSet() != null) {
+ ColumnSet<ProcedureRecordImpl> resultRecord =
procRecord.getResultSet();
+ // resultSet is the last parameter in the procedure
+ int lastParamIndex = procInfo.getParameters().size() + 1;
+ SPParameter param = new SPParameter(lastParamIndex,
SPParameter.RESULT_SET, resultRecord.getName());
+ param.setClassType(java.sql.ResultSet.class);
+ param.setMetadataID(resultRecord);
- // if the procedure returns a resultSet, obtain resultSet metadata
- if(procRecord.getResultSet() != null) {
- ColumnSet<ProcedureRecordImpl> resultRecord =
procRecord.getResultSet();
- // resultSet is the last parameter in the procedure
- int lastParamIndex = procInfo.getParameters().size() + 1;
- SPParameter param = new SPParameter(lastParamIndex, SPParameter.RESULT_SET,
resultRecord.getName());
- param.setClassType(java.sql.ResultSet.class);
- param.setMetadataID(resultRecord);
+ for (Column columnRecord : resultRecord.getColumns()) {
+ String colType = columnRecord.getRuntimeType();
+ param.addResultSetColumn(columnRecord.getFullName(),
DataTypeManager.getDataTypeClass(colType), columnRecord);
+ }
- for (Column columnRecord : resultRecord.getColumns()) {
- String colType = columnRecord.getRuntimeType();
- param.addResultSetColumn(columnRecord.getFullName(),
DataTypeManager.getDataTypeClass(colType), columnRecord);
- }
+ procInfo.addParameter(param);
+ }
- procInfo.addParameter(param);
+ // if this is a virtual procedure get the procedure plan
+ if(procRecord.isVirtual()) {
+ QueryNode queryNode = new QueryNode(procedureFullName,
procRecord.getQueryPlan());
+ procInfo.setQueryPlan(queryNode);
+ }
+
+ //subtract 1, to match up with the server
+ procInfo.setUpdateCount(procRecord.getUpdateCount() -1);
+ results.add(procInfo);
+ }
+ this.procedureCache.put(lowerGroupName, results);
}
-
- // if this is a virtual procedure get the procedure plan
- if(procRecord.isVirtual()) {
- QueryNode queryNode = new QueryNode(procedureFullName,
procRecord.getQueryPlan());
- procInfo.setQueryPlan(queryNode);
- }
- //subtract 1, to match up with the server
- procInfo.setUpdateCount(procRecord.getUpdateCount() -1);
-
- this.procedureCache.put(lowerGroupName, procInfo);
+ StoredProcedureInfo result = null;
+
+ for (StoredProcedureInfo storedProcedureInfo : results) {
+ Schema schema = (Schema)storedProcedureInfo.getModelID();
+ if(vdbService == null || vdbService.getModelVisibility(getVirtualDatabaseName(),
vdbVersion, schema.getName()) == ModelInfo.PUBLIC){
+ if (result != null) {
+ throw new
QueryMetadataException(QueryPlugin.Util.getString("ambiguous_procedure",
fullyQualifiedProcedureName)); //$NON-NLS-1$
+ }
+ result = storedProcedureInfo;
+ }
+ }
+
+ if (result == null) {
+ throw new QueryMetadataException(fullyQualifiedProcedureName+NOT_EXISTS_MESSAGE);
+ }
- return procInfo;
+ return result;
}
/**
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2009-11-30
15:24:24 UTC (rev 1605)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -226,11 +226,6 @@
helpTestVisibilityFails(xquery);
}
- @Test public void testResolvingVisibility() throws Exception {
- String sql = "SELECT * FROM SmallA"; //$NON-NLS-1$
- helpExecute(sql, "a"); //$NON-NLS-1$
- }
-
///////////////////////////Helper method///////////////////////////////////
private ResultsMessage helpExecute(String sql, String userName) throws Exception {
return helpExecute(sql, userName, 1, false);
Modified:
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -126,19 +126,6 @@
assertEquals(0, metadata.length);
}
- public void testDefect15029() throws Exception {
- String sql = "SELECT * FROM g1"; //$NON-NLS-1$
- QueryMetadataInterface metadata =
FakeMetadataFactory.examplePrivatePhysicalModel();
-
- MetadataResult response = helpTestQuery(metadata, sql);
-
- Map[] md = response.getColumnMetadata();
- assertNotNull(md);
- assertEquals(1, md.length);
- assertEquals("e1", md[0].get(ResultsMetadataConstants.ELEMENT_NAME));
//$NON-NLS-1$
- assertEquals("vm1.g1", md[0].get(ResultsMetadataConstants.GROUP_NAME));
//$NON-NLS-1$
- }
-
private MetadataResult helpTestQuery(QueryMetadataInterface metadata, String sql)
throws Exception {
FakeVDBService vdbService = new FakeVDBService();
vdbService.addModel("MyVDB", "1", "pm1",
ModelInfo.PRIVATE, false); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2009-11-30
15:24:24 UTC (rev 1605)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -123,7 +123,7 @@
request.initialize(message, environment, null, null, null, false, null,
workContext, 101024);
request.initMetadata();
- request.validateEntitlement(command);
+ request.validateAccess(command);
}
Modified:
trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -27,6 +27,8 @@
import java.util.Iterator;
import java.util.Set;
+import org.mockito.Mockito;
+import org.teiid.dqp.internal.process.Request;
import org.teiid.dqp.internal.process.validator.AuthorizationValidationVisitor;
import junit.framework.TestCase;
@@ -34,8 +36,12 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryParserException;
import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.api.exception.query.QueryValidatorException;
+import com.metamatrix.common.vdb.api.ModelInfo;
import com.metamatrix.dqp.service.AuthorizationService;
import com.metamatrix.dqp.service.FakeAuthorizationService;
+import com.metamatrix.dqp.service.FakeVDBService;
+import com.metamatrix.dqp.service.VDBService;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.resolver.QueryResolver;
@@ -119,7 +125,7 @@
Command command = parser.parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
- AuthorizationValidationVisitor visitor = new
AuthorizationValidationVisitor(CONN_ID, svc);
+ AuthorizationValidationVisitor visitor = new
AuthorizationValidationVisitor(CONN_ID, svc, Mockito.mock(VDBService.class),
"foo", "1"); //$NON-NLS-1$ //$NON-NLS-2$
ValidatorReport report = Validator.validate(command, metadata, visitor, true);
if(report.hasItems()) {
ValidatorFailure firstFailure = (ValidatorFailure)
report.getItems().iterator().next();
@@ -215,14 +221,6 @@
helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm3.g2 FROM
pm2.g1", FakeMetadataFactory.example1Cached(), new String[] {"pm3.g2.e1",
"pm3.g2.e2"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public void testProcGloballyAccessible() throws Exception {
-
AuthorizationValidationVisitor.addGloballyAccessibleProcedure("pm1.sq2");
//$NON-NLS-1$
- helpTest(exampleAuthSvc1(), "EXEC pm1.sq2('xyz')",
FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
-
-
AuthorizationValidationVisitor.removeGloballyAccessibleProcedure("pm1.sq2");
//$NON-NLS-1$
- helpTest(exampleAuthSvc1(), "EXEC pm1.sq2('xyz')",
FakeMetadataFactory.example1Cached(), new String[] {"pm1.sq2"});
//$NON-NLS-1$//$NON-NLS-2$
- }
-
public void testTempTableSelectInto() throws Exception {
helpTest(exampleAuthSvc1(), "SELECT e1 INTO #temp FROM pm1.g1",
FakeMetadataFactory.example1Cached(), new String[] {}); //$NON-NLS-1$
}
@@ -242,4 +240,31 @@
public void testXMLInAccessible() throws Exception {
helpTest(exampleAuthSvc1(), "select * from xmltest.doc1",
FakeMetadataFactory.example1Cached(), new String[] {"xmltest.doc1"});
//$NON-NLS-1$ //$NON-NLS-2$
}
+
+ private void helpTestLookupVisibility(boolean visible) throws QueryParserException,
QueryValidatorException, MetaMatrixComponentException {
+ FakeVDBService vdbService = new FakeVDBService();
+ String vdbName = "foo"; //$NON-NLS-1$
+ String vdbVersion = "1"; //$NON-NLS-1$
+ String modelName = "pm1"; //$NON-NLS-1$
+ vdbService.addModel(vdbName, vdbVersion, modelName,
visible?ModelInfo.PUBLIC:ModelInfo.PRIVATE, false);
+ AuthorizationValidationVisitor mvvv = new AuthorizationValidationVisitor(CONN_ID,
Mockito.mock(AuthorizationService.class), vdbService, vdbName, vdbVersion);
+
+ String sql = "select lookup('pm1.g1', 'e1', 'e2',
1)"; //$NON-NLS-1$
+ Command command = QueryParser.getQueryParser().parseCommand(sql);
+ Request.validateWithVisitor(mvvv, FakeMetadataFactory.example1Cached(), command,
true);
+ }
+
+ public void testLookupVisibility() throws Exception {
+ helpTestLookupVisibility(true);
+ }
+
+ public void testLookupVisibilityFails() throws Exception {
+ try {
+ helpTestLookupVisibility(false);
+ fail("expected exception"); //$NON-NLS-1$
+ } catch (QueryValidatorException e) {
+ assertEquals("Group does not exist: pm1.g1", e.getMessage()); //$NON-NLS-1$
+ }
+ }
+
}
Deleted:
trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestModelVisibilityValidationVisitor.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestModelVisibilityValidationVisitor.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestModelVisibilityValidationVisitor.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -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 org.teiid.dqp.internal.process.validator;
-
-import org.teiid.dqp.internal.process.Request;
-import org.teiid.dqp.internal.process.validator.ModelVisibilityValidationVisitor;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.dqp.service.FakeVDBService;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestModelVisibilityValidationVisitor extends TestCase {
-
- private void helpTestLookupVisibility(boolean visible) throws QueryParserException,
QueryValidatorException, MetaMatrixComponentException {
- FakeVDBService vdbService = new FakeVDBService();
- String vdbName = "foo"; //$NON-NLS-1$
- String vdbVersion = "1"; //$NON-NLS-1$
- String modelName = "pm1"; //$NON-NLS-1$
- vdbService.addModel(vdbName, vdbVersion, modelName,
visible?ModelInfo.PUBLIC:ModelInfo.PRIVATE, false);
- ModelVisibilityValidationVisitor mvvv = new
ModelVisibilityValidationVisitor(vdbService, vdbName, vdbVersion);
-
- String sql = "select lookup('pm1.g1', 'e1', 'e2',
1)"; //$NON-NLS-1$
- Command command = QueryParser.getQueryParser().parseCommand(sql);
- Request.validateWithVisitor(mvvv, FakeMetadataFactory.example1Cached(), command,
true);
- }
-
- public void testLookupVisibility() throws Exception {
- helpTestLookupVisibility(true);
- }
-
- public void testLookupVisibilityFails() throws Exception {
- try {
- helpTestLookupVisibility(false);
- fail("expected exception"); //$NON-NLS-1$
- } catch (QueryValidatorException e) {
- assertEquals("Group does not exist: pm1.g1", e.getMessage()); //$NON-NLS-1$
- }
- }
-
-}
Deleted: trunk/engine/src/test/java/org/teiid/metadata/TestCompositeMetadataStore.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/metadata/TestCompositeMetadataStore.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/engine/src/test/java/org/teiid/metadata/TestCompositeMetadataStore.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -1,59 +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.metadata;
-
-import static org.junit.Assert.*;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.teiid.connector.metadata.runtime.Datatype;
-import org.teiid.connector.metadata.runtime.MetadataFactory;
-
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.metadata.runtime.api.MetadataSource;
-
-public class TestCompositeMetadataStore {
-
- @Test public void testAmbiguousProc() throws Exception {
- Map<String, Datatype> datatypes = new HashMap<String, Datatype>();
- datatypes.put(DataTypeManager.DefaultDataTypes.STRING, new Datatype());
- MetadataFactory mf = new MetadataFactory("x", datatypes, new Properties());
//$NON-NLS-1$
- mf.addProcedure("y"); //$NON-NLS-1$
- MetadataFactory mf1 = new MetadataFactory("x1", datatypes, new Properties());
//$NON-NLS-1$
- mf1.addProcedure("y"); //$NON-NLS-1$
- CompositeMetadataStore cms = new
CompositeMetadataStore(Arrays.asList(mf.getMetadataStore(), mf1.getMetadataStore()),
Mockito.mock(MetadataSource.class));
- try {
- cms.getStoredProcedure("y"); //$NON-NLS-1$
- fail("expected exception"); //$NON-NLS-1$
- } catch (QueryMetadataException e) {
- assertEquals("Procedure 'y' is ambiguous, use the fully qualified name
instead", e.getMessage()); //$NON-NLS-1$
- }
- }
-
-}
Copied: trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java
(from rev 1603,
trunk/engine/src/test/java/org/teiid/metadata/TestCompositeMetadataStore.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java
(rev 0)
+++
trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -0,0 +1,86 @@
+/*
+ * 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.metadata;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.connector.metadata.runtime.Datatype;
+import org.teiid.connector.metadata.runtime.MetadataFactory;
+
+import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.vdb.api.ModelInfo;
+import com.metamatrix.dqp.service.VDBService;
+import com.metamatrix.metadata.runtime.api.MetadataSource;
+
+public class TestTransformationMetadata {
+
+ @Test public void testAmbiguousProc() throws Exception {
+ Map<String, Datatype> datatypes = new HashMap<String, Datatype>();
+ datatypes.put(DataTypeManager.DefaultDataTypes.STRING, new Datatype());
+ MetadataFactory mf = new MetadataFactory("x", datatypes, new Properties());
//$NON-NLS-1$
+ mf.addProcedure("y"); //$NON-NLS-1$
+ MetadataFactory mf1 = new MetadataFactory("x1", datatypes, new Properties());
//$NON-NLS-1$
+ mf1.addProcedure("y"); //$NON-NLS-1$
+ CompositeMetadataStore cms = new
CompositeMetadataStore(Arrays.asList(mf.getMetadataStore(), mf1.getMetadataStore()),
Mockito.mock(MetadataSource.class));
+ TransformationMetadata tm = new TransformationMetadata(cms);
+ try {
+ tm.getStoredProcedureInfoForProcedure("y"); //$NON-NLS-1$
+ fail("expected exception"); //$NON-NLS-1$
+ } catch (QueryMetadataException e) {
+ assertEquals("Procedure 'y' is ambiguous, use the fully qualified name
instead", e.getMessage()); //$NON-NLS-1$
+ }
+ }
+
+ @Test public void testAmbiguousTableWithPrivateModel() throws Exception {
+ Map<String, Datatype> datatypes = new HashMap<String, Datatype>();
+ datatypes.put(DataTypeManager.DefaultDataTypes.STRING, new Datatype());
+ MetadataFactory mf = new MetadataFactory("x", datatypes, new Properties());
//$NON-NLS-1$
+ mf.addTable("y"); //$NON-NLS-1$
+ MetadataFactory mf1 = new MetadataFactory("x1", datatypes, new Properties());
//$NON-NLS-1$
+ mf1.addTable("y"); //$NON-NLS-1$
+ MetadataSource ms = Mockito.mock(MetadataSource.class);
+ Mockito.stub(ms.getName()).toReturn("foo"); //$NON-NLS-1$
+ CompositeMetadataStore cms = new
CompositeMetadataStore(Arrays.asList(mf.getMetadataStore(), mf1.getMetadataStore()), ms);
+ TransformationMetadata tm = new TransformationMetadata(cms);
+ Collection result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$
+ assertEquals(2, result.size());
+
+ VDBService vdbService = Mockito.mock(VDBService.class);
+ Mockito.stub(vdbService.getModelVisibility("foo", "1",
"x1")).toReturn((int)ModelInfo.PRIVATE); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
+ Mockito.stub(vdbService.getModelVisibility("foo", "1",
"x")).toReturn((int)ModelInfo.PUBLIC); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
+ tm = new TransformationMetadata(cms, vdbService, "1"); //$NON-NLS-1$
+ result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$
+ assertEquals(1, result.size());
+
+ }
+
+}
Property changes on:
trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java
===================================================================
---
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -24,7 +24,6 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -38,7 +37,6 @@
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.common.vdb.api.SystemVdbUtility;
import com.metamatrix.common.vdb.api.VDBArchive;
import com.metamatrix.common.vdb.api.VDBDefn;
import com.metamatrix.core.util.StringUtil;
@@ -99,18 +97,6 @@
return vdb;
}
- private ModelInfo getModel(VDBDefn vdb, String modelName) {
- Collection c = vdb.getModels();
- Iterator it = c.iterator();
- while (it.hasNext()) {
- ModelInfo model = (ModelInfo)it.next();
- if (model.getName().equals(modelName)) {
- return model;
- }
- }
- return null;
- }
-
/**
* This should changed to connectorBindingNames.
* @see com.metamatrix.dqp.service.VDBService#getConnectorBindings(java.lang.String,
java.lang.String, java.lang.String)
@@ -153,14 +139,14 @@
throws MetaMatrixComponentException {
// If this is any of the Public System Models, like JDBC,ODBC system models
- if(SystemVdbUtility.isSystemModelWithSystemTableType(modelName)){
+ if(VDBArchive.isSystemModelWithSystemTableType(modelName)){
return ModelInfo.PUBLIC;
}
VDBArchive vdb = getVDB(vdbName, vdbVersion);
VDBDefn def = vdb.getConfigurationDef();
- ModelInfo model = getModel(def, modelName);
+ ModelInfo model = def.getModel(modelName);
if(model != null) {
return model.getVisibility();
}
@@ -179,14 +165,14 @@
String modelName = StringUtil.getFirstToken(StringUtil.getLastToken(pathInVDB,
"/"), "."); //$NON-NLS-1$ //$NON-NLS-2$
// If this is any of the Public System Models, like JDBC,ODBC system models
- if(SystemVdbUtility.isSystemModelWithSystemTableType(modelName)){
+ if(VDBArchive.isSystemModelWithSystemTableType(modelName)){
return ModelInfo.PUBLIC;
}
VDBArchive vdb = getVDB(vdbName, vdbVersion);
VDBDefn def = vdb.getConfigurationDef();
- ModelInfo model = getModel(def, modelName);
+ ModelInfo model = def.getModel(modelName);
if(model != null) {
return model.getVisibility();
}
Modified:
trunk/runtime/src/main/java/com/metamatrix/platform/security/membership/service/MembershipServiceImpl.java
===================================================================
---
trunk/runtime/src/main/java/com/metamatrix/platform/security/membership/service/MembershipServiceImpl.java 2009-11-30
15:24:24 UTC (rev 1605)
+++
trunk/runtime/src/main/java/com/metamatrix/platform/security/membership/service/MembershipServiceImpl.java 2009-11-30
17:12:55 UTC (rev 1606)
@@ -58,6 +58,7 @@
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.common.util.crypto.CryptoException;
import com.metamatrix.common.util.crypto.CryptoUtil;
+import com.metamatrix.core.CoreConstants;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
@@ -334,7 +335,7 @@
return new FailedAuthenticationToken();
}
- if (isWsdlUser(username)) {
+ if (isAnonUser(username)) {
// No need to check credentials. There is no password for the wsdl user.
return new SuccessfulAuthenticationToken(trustedPayload, username);
}
@@ -493,7 +494,7 @@
return new BasicMetaMatrixPrincipal(name,
MetaMatrixPrincipal.TYPE_ADMIN,Collections.EMPTY_SET);
}
- if (isWsdlUser(name)) {
+ if (isAnonUser(name)) {
return new BasicMetaMatrixPrincipal(name,
MetaMatrixPrincipal.TYPE_USER,Collections.EMPTY_SET);
}
}
@@ -645,8 +646,8 @@
return adminUsername.equalsIgnoreCase(username);
}
- public boolean isWsdlUser(String username) {
- return DEFAULT_WSDL_USERNAME.equalsIgnoreCase(username);
+ public boolean isAnonUser(String username) {
+ return CoreConstants.DEFAULT_ANON_USERNAME.equalsIgnoreCase(username);
}
/**