Package org.apache.qpid.server.model

Examples of org.apache.qpid.server.model.VirtualHost


        {
            security = _broker.getSecurityManager();
        }
        else
        {
            VirtualHost virtualHost = _broker.findVirtualHostByName(vhost);
            if (virtualHost == null)
            {
                throw new IllegalArgumentException("Virtual host with name '" + vhost + "' is not found.");
            }
            security = virtualHost.getSecurityManager();
        }

        methodName = getMethodName(method, args);
        Operation operation = (isAccessMethod(methodName) || impact == MBeanOperationInfo.INFO) ? Operation.ACCESS : Operation.UPDATE;
        security.authoriseMethod(operation, type, methodName);
View Full Code Here


            names.addAll(Arrays.asList(path.split("/")));
        }
        String vhostName = names.get(0);
        String queueName = names.get(1);

        VirtualHost vhost = null;

        for(VirtualHost vh : getBroker().getVirtualHosts())
        {
            if(vh.getName().equals(vhostName))
            {
View Full Code Here

            names.addAll(Arrays.asList(path.split("/")));
        }
        String vhostName = names.get(0);
        String queueName = names.get(1);

        VirtualHost vhost = null;

        for(VirtualHost vh : getBroker().getVirtualHosts())
        {
            if(vh.getName().equals(vhostName))
            {
View Full Code Here

            Map<String,Object> providedObject = mapper.readValue(request.getInputStream(), LinkedHashMap.class);

            String destQueueName = (String) providedObject.get("destinationQueue");
            Boolean move = (Boolean) providedObject.get("move");

            final VirtualHost vhost = sourceQueue.getParent(VirtualHost.class);

            boolean isMoveTransaction = move != null && Boolean.valueOf(move);

            // FIXME: added temporary authorization check until we introduce management layer
            // and review current ACL rules to have common rules for all management interfaces
            String methodName = isMoveTransaction? "moveMessages":"copyMessages";
            if (isQueueUpdateMethodAuthorized(methodName, vhost.getName()))
            {
                final Queue destinationQueue = getQueueFromVirtualHost(destQueueName, vhost);
                final List messageIds = new ArrayList((List) providedObject.get("messages"));
                QueueEntryTransaction txn =
                        isMoveTransaction
                                ? new MoveTransaction(sourceQueue, messageIds, destinationQueue)
                                : new CopyTransaction(sourceQueue, messageIds, destinationQueue);
                vhost.executeTransaction(txn);
                response.setStatus(HttpServletResponse.SC_OK);
            }
            else
            {
                response.setStatus(HttpServletResponse.SC_FORBIDDEN);
View Full Code Here

    protected void doDeleteWithSubjectAndActor(HttpServletRequest request, HttpServletResponse response)
    {

        final Queue sourceQueue = getQueueFromRequest(request);

        final VirtualHost vhost = sourceQueue.getParent(VirtualHost.class);


        final List<Long> messageIds = new ArrayList<Long>();
        for(String idStr : request.getParameterValues("id"))
        {
            messageIds.add(Long.valueOf(idStr));
        }

        // FIXME: added temporary authorization check until we introduce management layer
        // and review current ACL rules to have common rules for all management interfaces
        if (isQueueUpdateMethodAuthorized("deleteMessages", vhost.getName()))
        {
            vhost.executeTransaction(new DeleteTransaction(sourceQueue, messageIds));
            response.setStatus(HttpServletResponse.SC_OK);
        }
        else
        {
            response.setStatus(HttpServletResponse.SC_FORBIDDEN);
View Full Code Here

        return count.longValue();
    }

    public VirtualHost getVirtualHost()
    {
        VirtualHost virtualHost = mock(VirtualHost.class);
        when(virtualHost.getName()).thenReturn(getName());
        when(virtualHost.getId()).thenReturn(UUID.randomUUID());
        return virtualHost;
    }
View Full Code Here

        when(mockExchange2.getName()).thenReturn("exchange2");

        Exchange mockExchange3 = mock(Exchange.class);
        when(mockExchange3.getName()).thenReturn("exchange3");

        VirtualHost mockVirtualHost = mock(VirtualHost.class);
        when(mockVirtualHost.getExchanges()).thenReturn(Arrays.asList(new Exchange[] {mockExchange1, mockExchange2, mockExchange3}));
        when(_mockQueue.getParent(VirtualHost.class)).thenReturn(mockVirtualHost);

        _queueMBean.setAlternateExchange("exchange2");
        verify(_mockQueue).setAttributes(Collections.<String,Object>singletonMap(Queue.ALTERNATE_EXCHANGE, "exchange2"));
    }
View Full Code Here

    public void testSetAlternateExchangeWithUnknownExchangeName() throws Exception
    {
        Exchange mockExchange = mock(Exchange.class);
        when(mockExchange.getName()).thenReturn("exchange1");

        VirtualHost mockVirtualHost = mock(VirtualHost.class);
        when(mockVirtualHost.getExchanges()).thenReturn(Collections.singletonList(mockExchange));
        when(_mockQueue.getParent(VirtualHost.class)).thenReturn(mockVirtualHost);
        doThrow(new IllegalArgumentException()).when(_mockQueue).setAttributes(
                eq(Collections.<String, Object>singletonMap(Queue.ALTERNATE_EXCHANGE, "notknown")));
        try
        {
View Full Code Here

        when(_mockVirtualHostMBean.getRegistry()).thenReturn(_mockManagedObjectRegistry);

        _mockQueue1 = createMockQueue(QUEUE1_NAME);
        _mockQueue2 = createMockQueue(QUEUE2_NAME);

        VirtualHost mockVirtualHost = mock(VirtualHost.class);
        when(mockVirtualHost.getQueues()).thenReturn(Arrays.asList(new Queue[] {_mockQueue1, _mockQueue2}));
        when(mockVirtualHost.getChildByName(eq(Queue.class), eq(QUEUE1_NAME))).thenReturn(_mockQueue1);
        when(mockVirtualHost.getChildByName(eq(Queue.class), eq(QUEUE2_NAME))).thenReturn(_mockQueue2);

        when(_mockExchange.getParent(VirtualHost.class)).thenReturn(mockVirtualHost);

        _exchangeMBean = new ExchangeMBean(_mockExchange, _mockVirtualHostMBean);
View Full Code Here

        String vhostName = "HouseKeepingTaskTestVhost";

        String expectedThreadNameDuringExecution = vhostName + ":" + "ThreadNameRememberingTask";

        VirtualHost virtualHost = mock(VirtualHost.class);
        when(virtualHost.getName()).thenReturn(vhostName);
        ThreadNameRememberingTask testTask = new ThreadNameRememberingTask(virtualHost);

        testTask.run();

        assertEquals("Thread name should have been set during execution", expectedThreadNameDuringExecution, testTask.getThreadNameDuringExecution());
View Full Code Here

TOP

Related Classes of org.apache.qpid.server.model.VirtualHost

Copyright © 2018 www.massapicom. 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.