Search in sources :

Example 71 with Stack

use of java.util.Stack in project OpenAM by OpenRock.

the class EntityManager method execute.

/**
     * This method will use methods provided by ConfigManager to get "Structure
     * Template" information from the DIT. It will use this information to
     * create the "Structural Entity".
     * 
     * @param principal
     *            The Principal.
     * @param pObject
     *            The persistent object for which the entities apply.
     * @param pGUID
     *            The guid of the parent object.
     * @throws UMSException
     *             if an exception occurs.
     */
public void execute(java.security.Principal principal, PersistentObject pObject, Guid pGUID) throws UMSException {
    String className;
    HashMap hm = null;
    Set set = null;
    Iterator iter = null;
    Attr attr = null;
    AttrSet attrSet = null;
    String[] attrValues;
    if (pObject == null) {
        String msg = i18n.getString(IUMSConstants.PERSISTENT_OBJECT_PARAM_NULL);
        throw new UMSException(msg);
    }
    _principal = principal;
    _pObject = pObject;
    _stack = new Stack();
    className = _pObject.getClass().getName();
    _parentObject = _pObject;
    if (debug.messageEnabled()) {
        debug.message("GETTING ENTITY FOR:CLASS:" + className + ",PARENT:" + pGUID.getDn());
    }
    try {
        set = _configManager.getEntity(pGUID, className);
        if (!set.isEmpty()) {
            if (set.size() > 1) {
                attrSet = findEntity(_pObject, set);
            } else {
                Iterator it = set.iterator();
                if (it.hasNext())
                    attrSet = (AttrSet) it.next();
            }
        } else
            return;
        if (attrSet == null) {
            String[] args = new String[1];
            args[0] = className;
            String msg = i18n.getString(IUMSConstants.STRUCTURE_TEMPLATE_ATTRSET_NULL, args);
            throw new UMSException(msg);
        }
    } catch (ConfigManagerException cme) {
        String[] args = new String[1];
        args[0] = cme.getMessage();
        String msg = i18n.getString(IUMSConstants.CONFIG_MGR_ERROR, args);
        throw new UMSException(msg);
    }
    if (debug.messageEnabled()) {
        debug.message("ENTITY ATTRSET:" + attrSet);
    }
    attr = attrSet.getAttribute(ENTITY_CHILDNODE);
    if (attr == null) {
        return;
    }
    attrValues = attr.getStringValues();
    for (int i = 0; i < attrValues.length; i++) {
        hm = new HashMap();
        hm.put(attrValues[i], _parentObject.getGuid());
        _stack.push(hm);
    }
    while (!_stack.empty()) {
        hm = (HashMap) _stack.pop();
        set = hm.keySet();
        iter = set.iterator();
        String childNodeName = (String) iter.next();
        Guid parentGuid = (Guid) hm.get(childNodeName);
        try {
            Set childSet = _configManager.getEntity(pGUID, childNodeName);
            if (!childSet.isEmpty()) {
                iter = childSet.iterator();
                if (iter.hasNext())
                    attrSet = (AttrSet) iter.next();
            }
            if (childSet.isEmpty() | attrSet == null)
                return;
        } catch (ConfigManagerException cme) {
            String[] args = new String[1];
            args[0] = cme.getMessage();
            String msg = i18n.getString(IUMSConstants.CONFIG_MGR_ERROR, args);
            throw new UMSException(msg);
        }
        // Create Object
        //
        PersistentObject pObj = createObject(attrSet, parentGuid, pGUID);
        attr = attrSet.getAttribute(ENTITY_CHILDNODE);
        if (attr != null) {
            attrValues = attr.getStringValues();
            for (int j = 0; j < attrValues.length; j++) {
                hm = new HashMap();
                hm.put(attrValues[j], pObj.getGuid());
                _stack.push(hm);
            }
        }
    }
}
Also used : AttrSet(com.iplanet.services.ldap.AttrSet) Set(java.util.Set) HashMap(java.util.HashMap) Attr(com.iplanet.services.ldap.Attr) AttrSet(com.iplanet.services.ldap.AttrSet) Stack(java.util.Stack) Iterator(java.util.Iterator)

Example 72 with Stack

use of java.util.Stack in project OpenAM by OpenRock.

the class ResourceManager method removeRuleFromResourceTree.

private void removeRuleFromResourceTree(String policyName, String resourceName, String serviceTypeName, ServiceType st) throws PolicyException, SSOException {
    if (resourceName == null || resourceName.length() == 0) {
        resourceName = EMPTY_RESOURCE_NAME;
    }
    ServiceConfig resources = getResourcesServiceConfig(false);
    if (resources == null) {
        return;
    }
    ServiceConfig leafConfig = null;
    try {
        leafConfig = resources.getSubConfig(serviceTypeName);
    } catch (SMSException e1) {
        throw new PolicyException(e1);
    }
    if (leafConfig == null) {
        // no resource node for this service type
        return;
    }
    // else, see if the attribute is there and non-empty
    Map existingAttrs = null;
    existingAttrs = leafConfig.getAttributes();
    if ((existingAttrs == null) || (!existingAttrs.containsKey(RESOURCES_XML))) {
        return;
    }
    // else, need to look into the attribute
    int n = existingAttrs.size();
    Set existingRes = (Set) existingAttrs.get(RESOURCES_XML);
    if (existingRes.isEmpty()) {
        return;
    }
    // else, the attribute really contains something
    Object[] retVal = getXMLRootNode(existingRes);
    Node rootNode = (Node) retVal[0];
    boolean modified = matchAndRemoveReferenceNode(rootNode, resourceName, policyName, st, new Stack());
    if (!modified) {
        return;
    }
    if (!rootNode.hasChildNodes()) {
        try {
            leafConfig.removeAttribute(RESOURCES_XML);
            if (n == 1) {
                resources.removeSubConfig(serviceTypeName);
            }
            return;
        } catch (SMSException e3) {
            throw new PolicyException(e3);
        }
    }
    // finally reset the modified xml content
    String modifiedResourcesXml = SMSSchema.nodeToString(rootNode);
    Map modifiedAttrs = new HashMap();
    Set modifiedSet = new HashSet();
    modifiedSet.add(modifiedResourcesXml);
    modifiedAttrs.put(RESOURCES_XML, modifiedSet);
    try {
        leafConfig.setAttributes(modifiedAttrs);
    } catch (SMSException e4) {
        throw new PolicyException(e4);
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) HashMap(java.util.HashMap) Node(org.w3c.dom.Node) Stack(java.util.Stack) ServiceConfig(com.sun.identity.sm.ServiceConfig) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 73 with Stack

use of java.util.Stack in project android_frameworks_base by ResurrectionRemix.

the class NotificationHeaderViewWrapper method updateCropToPaddingForImageViews.

/**
     * Since we are deactivating the clipping when transforming the ImageViews don't get clipped
     * anymore during these transitions. We can avoid that by using
     * {@link ImageView#setCropToPadding(boolean)} on all ImageViews.
     */
private void updateCropToPaddingForImageViews() {
    Stack<View> stack = new Stack<>();
    stack.push(mView);
    while (!stack.isEmpty()) {
        View child = stack.pop();
        if (child instanceof ImageView) {
            ((ImageView) child).setCropToPadding(true);
        } else if (child instanceof ViewGroup) {
            ViewGroup group = (ViewGroup) child;
            for (int i = 0; i < group.getChildCount(); i++) {
                stack.push(group.getChildAt(i));
            }
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TransformableView(com.android.systemui.statusbar.TransformableView) NotificationPanelView(com.android.systemui.statusbar.phone.NotificationPanelView) View(android.view.View) NotificationHeaderView(android.view.NotificationHeaderView) Stack(java.util.Stack)

Example 74 with Stack

use of java.util.Stack in project pcgen by PCGen.

the class IfCommandTest method testIf04.

/* Test the case where the condition is a true boolean */
public void testIf04() {
    final PostfixMathCommandI c = new IfCommand();
    final Stack<Boolean> s = new Stack<>();
    s.push(true);
    s.push(false);
    s.push(true);
    runIf(s, c);
    final Boolean result = s.pop();
    is(result, eq(false), "if (true,false,true) returns false");
}
Also used : PostfixMathCommandI(org.nfunk.jep.function.PostfixMathCommandI) Stack(java.util.Stack)

Example 75 with Stack

use of java.util.Stack in project pcgen by PCGen.

the class IfCommandTest method testIf02.

/* Test the case where the condition is a non zero double */
public void testIf02() {
    final PostfixMathCommandI c = new IfCommand();
    final Stack<Double> s = new Stack<>();
    s.push(1.0);
    s.push(1.0);
    s.push(2.0);
    runIf(s, c);
    final Double result = s.pop();
    is(result, eq(1.0, 0.1), "if (1.0,1.0,2.0) returns 1.0");
}
Also used : PostfixMathCommandI(org.nfunk.jep.function.PostfixMathCommandI) Stack(java.util.Stack)

Aggregations

Stack (java.util.Stack)245 HashSet (java.util.HashSet)42 ArrayList (java.util.ArrayList)37 File (java.io.File)23 IOException (java.io.IOException)22 View (android.view.View)18 Test (org.junit.Test)18 ViewGroup (android.view.ViewGroup)14 HashMap (java.util.HashMap)14 Set (java.util.Set)12 LinkedList (java.util.LinkedList)11 List (java.util.List)11 ImageView (android.widget.ImageView)10 Map (java.util.Map)10 Document (org.w3c.dom.Document)10 TestInputHandler (org.apache.maven.plugins.repository.testutil.TestInputHandler)9 PostfixMathCommandI (org.nfunk.jep.function.PostfixMathCommandI)9 DocumentBuilder (javax.xml.parsers.DocumentBuilder)8 NotificationPanelView (com.android.systemui.statusbar.phone.NotificationPanelView)7 TreeSet (java.util.TreeSet)7