Examples of BaseEntitySearchResultHandler


Examples of org.apache.jetspeed.security.mapping.impl.BaseEntitySearchResultHandler

            {
                if (logger.isDebugEnabled())
                {
                    logger.debug("Synchronizing all "+type+" entities");
                }
                BaseEntitySearchResultHandler handler = new BaseEntitySearchResultHandler()
                {
                    @Override
                    protected boolean processSearchResult(Entity entity, int pageSize, int pageIndex, int index)
                    {
                        try
                        {
                            synchronizeEntity(entity, processing, processed);
                        }
                        catch (SecurityException e)
                        {
                            setFeedback(e);
                            return false;
                        }
                        return true;
                    }
                };
                securityEntityManager.getAllEntities(type,handler);
                if (handler.getFeedback() != null)
                {
                    throw (SecurityException)handler.getFeedback();
                }
            }
        }
        finally
        {
View Full Code Here

Examples of org.apache.jetspeed.security.mapping.impl.BaseEntitySearchResultHandler

        setSynchronizing(true);
        try
        {
            final Map<String,Set<String>> processing = new HashMap<String,Set<String>>();
            final Map<String,Map<String,String>> processed = new HashMap<String,Map<String,String>>();
            BaseEntitySearchResultHandler handler = new BaseEntitySearchResultHandler()
            {
                @Override
                protected boolean processSearchResult(Entity entity, int pageSize, int pageIndex, int index)
                {
                    try
                    {
                        synchronizeEntity(entity, processing, processed);
                    }
                    catch (SecurityException e)
                    {
                        setFeedback(e);
                        return false;
                    }
                    return true;
                }
            };
            securityEntityManager.getAllEntities(type, handler);
            if (handler.getFeedback() != null)
            {
                throw (SecurityException)handler.getFeedback();
            }
        }
        finally
        {
            setSynchronizing(false);
View Full Code Here

Examples of org.apache.jetspeed.security.mapping.impl.BaseEntitySearchResultHandler

            if (relationTypeForThisEntity.getFromEntityType().equals(entity.getType()))
            {
                final String toEntityType = relationTypeForThisEntity.getToEntityType();
                final Map<String,String> processedToType = processed.containsKey(toEntityType) ? processed.get(toEntityType) : new HashMap<String,String>();
                final Set<String> processingToType = processing.containsKey(toEntityType) ? processing.get(toEntityType) : null;
                BaseEntitySearchResultHandler handler = new BaseEntitySearchResultHandler()
                {
                    @Override
                    protected boolean processSearchResult(Entity relatedEntity, int pageSize, int pageIndex, int index)
                    {
                        try
                        {
                            JetspeedPrincipal principal = null;
                            if (processingToType != null && processingToType.contains(relatedEntity.getId()))
                            {
                                // TODO: throw proper security exception type
                                throw new IllegalStateException("Circular relationship detected for Entity type "+toEntityType+" id: "+relatedEntity.getId());
                            }
                            else if (processedToType != null && processedToType.containsKey(relatedEntity.getId()))
                            {
                                String principalName = processed.get(relatedEntity.getType()).get(relatedEntity.getId());
                                principal = principalName != null ? getJetspeedPrincipal(relatedEntity.getType(),principalName) : null;
                            }
                            else
                            {
                                Set<String> processingFromType = processing.get(entity.getType());
                                if (processingFromType == null)
                                {
                                    processingFromType = new HashSet<String>();
                                    processing.put(entity.getType(), processingFromType);
                                }
                                processingFromType.add(entity.getId());
                                principal = synchronizeEntity(relatedEntity, processing, processed);
                            }
                            if (principal != null)
                            {
                                toAssociations.add(new JetspeedPrincipalAssociationReference(JetspeedPrincipalAssociationReference.Type.TO, principal, relationTypeForThisEntity.getRelationType()));
                            }
                        }
                        catch (SecurityException e)
                        {
                            setFeedback(e);
                            return false;
                        }
                        return true;
                    }
                };
                securityEntityManager.getRelatedEntitiesFrom(entity, relationTypeForThisEntity, handler);
                if (handler.getFeedback() != null)
                {
                    throw (SecurityException)handler.getFeedback();
                }
               
                Set<String> processingFromType = processing.get(entity.getType());
                if (processingFromType != null)
                {
View Full Code Here

Examples of org.apache.jetspeed.security.mapping.impl.BaseEntitySearchResultHandler

            feedbackLogger.info("Synchronizing all entities");
            final Map<String,Set<String>> processing = new HashMap<String,Set<String>>();
            final Map<String,Map<String,String>> processed = new HashMap<String,Map<String,String>>();
            for (final String type : securityEntityManager.getSupportedEntityTypes())
            {
                BaseEntitySearchResultHandler handler = new BaseEntitySearchResultHandler()
                {
                    @Override
                    protected boolean processSearchResult(Entity entity, int pageSize, int pageIndex, int index)
                    {
                        try
                        {
                            if (feedbackAfterSyncCount > 0 && index % feedbackAfterSyncCount == 0)
                            {
                                feedbackLogger.info("Synchronizing {}s - processed: {}", type, index);
                            }
                            synchronizeEntity(entity, processing, processed);
                        }
                        catch (SecurityException e)
                        {
                            setFeedback(e);
                            return false;
                        }
                        return true;
                    }
                };
                feedbackLogger.info("Synchronizing all {}s", type);
                securityEntityManager.getAllEntities(type,handler);
                if (handler.getFeedback() != null)
                {
                    feedbackLogger.error("Synchronizing {}s aborted. Processed: {}", type, handler.getSize());
                    throw (SecurityException)handler.getFeedback();
                }
                feedbackLogger.info("Synchronizing {}s done. Processed: {}", type, handler.getSize());
            }
            feedbackLogger.info("Synchronizing all entities done.");
        }
        finally
        {
View Full Code Here

Examples of org.apache.jetspeed.security.mapping.impl.BaseEntitySearchResultHandler

        setSynchronizing(true);
        try
        {
            final Map<String,Set<String>> processing = new HashMap<String,Set<String>>();
            final Map<String,Map<String,String>> processed = new HashMap<String,Map<String,String>>();
            BaseEntitySearchResultHandler handler = new BaseEntitySearchResultHandler()
            {
                @Override
                protected boolean processSearchResult(Entity entity, int pageSize, int pageIndex, int index)
                {
                    try
                    {
                        if (feedbackAfterSyncCount > 0 && index % feedbackAfterSyncCount == 0)
                        {
                            feedbackLogger.info("Synchronizing {}s - processed: {}", type, index);
                        }
                        synchronizeEntity(entity, processing, processed);
                    }
                    catch (SecurityException e)
                    {
                        if (abortOnError)
                        {
                            feedbackLogger.error("Failed to synchronize {}: {}", type, entity.getInternalId());
                            setFeedback(e);
                            return false;
                        }
                        feedbackLogger.warn("Failed to synchronize {}: {}", type, entity.getInternalId());
                        logger.error("Failed to synchronize "+type+": "+entity, e);
                        return true;
                    }
                    return true;
                }
            };
            feedbackLogger.info("Synchronizing {}s", type);
            securityEntityManager.getAllEntities(type, handler);
            if (handler.getFeedback() != null)
            {
                feedbackLogger.error("Synchronizing {}s aborted. Processed: {}", type, handler.getSize());
                throw (SecurityException)handler.getFeedback();
            }
            feedbackLogger.info("Synchronizing {}s done. Processed: {}", type, handler.getSize());
        }
        finally
        {
            setSynchronizing(false);
        }
View Full Code Here

Examples of org.apache.jetspeed.security.mapping.impl.BaseEntitySearchResultHandler

            if (relationTypeForThisEntity.getFromEntityType().equals(entity.getType()))
            {
                final String toEntityType = relationTypeForThisEntity.getToEntityType();
                final Map<String,String> processedToType = processed.containsKey(toEntityType) ? processed.get(toEntityType) : new HashMap<String,String>();
                final Set<String> processingToType = processing.containsKey(toEntityType) ? processing.get(toEntityType) : null;
                BaseEntitySearchResultHandler handler = new BaseEntitySearchResultHandler()
                {
                    @Override
                    protected boolean processSearchResult(Entity relatedEntity, int pageSize, int pageIndex, int index)
                    {
                        try
                        {
                            JetspeedPrincipal principal = null;
                            if (processingToType != null && processingToType.contains(relatedEntity.getId()))
                            {
                                // TODO: throw proper security exception type
                                throw new IllegalStateException("Circular relationship detected for Entity type "+toEntityType+" id: "+relatedEntity.getId());
                            }
                            else if (processedToType != null && processedToType.containsKey(relatedEntity.getId()))
                            {
                                String principalName = processed.get(relatedEntity.getType()).get(relatedEntity.getId());
                                principal = principalName != null ? getJetspeedPrincipal(relatedEntity.getType(),principalName) : null;
                            }
                            else
                            {
                                Set<String> processingFromType = processing.get(entity.getType());
                                if (processingFromType == null)
                                {
                                    processingFromType = new HashSet<String>();
                                    processing.put(entity.getType(), processingFromType);
                                }
                                processingFromType.add(entity.getId());
                                principal = synchronizeEntity(relatedEntity, processing, processed);
                            }
                            if (principal != null)
                            {
                                toAssociations.add(new JetspeedPrincipalAssociationReference(JetspeedPrincipalAssociationReference.Type.TO, principal, relationTypeForThisEntity.getRelationType()));
                            }
                        }
                        catch (SecurityException e)
                        {
                            setFeedback(e);
                            return false;
                        }
                        return true;
                    }
                };
                securityEntityManager.getRelatedEntitiesFrom(entity, relationTypeForThisEntity, handler);
                if (handler.getFeedback() != null)
                {
                    throw (SecurityException)handler.getFeedback();
                }
               
                Set<String> processingFromType = processing.get(entity.getType());
                if (processingFromType != null)
                {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.