Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2014 Red Hat, Inc.. All rights reserved. This program and the accompanying materials are made available under the terms of the GNU Public License v3.0 which accompanies this distribution, and is available at http://www.gnu.org/licenses/gpl.html Contributors: Red Hat, Inc. - initial API and implementation /
package org.commonjava.aprox.core.bind.vertx.admin;
import static org.commonjava.aprox.bind.vertx.util.ResponseUtils.formatResponse;
@Handles( prefix = "/admin/replicate" )
public class ReplicationHandler
    implements RequestHandler
    private final Logger logger = LoggerFactory.getLoggergetClass() );
    @Inject
    @Inject
    private ObjectMapper serializer;
    @Routes( { @Route( method = ., contentType = . ) } )
    public void replicatefinal Buffer bufferfinal HttpServerRequest request )
    {
        final String json = buffer.getString( 0, buffer.length() );
        try
        {
            final ReplicationDTO dto = .readValuejsonReplicationDTO.class );
            final Set<StoreKeyreplicated = .replicatedtorequest.params()
                                                                               .get..key() ) );
            final Map<StringObjectparams = new LinkedHashMap<StringObject>();
            params.put"replicationCount"replicated.size() );
            params.put"items"replicated );
            Respond.torequest )
                   .jsonEntityparams )
                   .send();
        }
        catch ( final AproxWorkflowException e )
        {
            .error( String.format"Replication failed: %s"e.getMessage() ), e );
            formatResponseerequest );
        }
        catch ( final JsonProcessingException e )
        {
            Respond.torequest )
                   .serverErrore"Failed to deserialize/serialize JSON."true )
                   .send();
        }
        catch ( final IOException e )
        {
            Respond.torequest )
                   .serverErrore"Failed to read JSON content from request body."true )
                   .send();
        }
    }
New to GrepCode? Check out our FAQ X