Clover coverage report -
Coverage timestamp: Mon May 5 2008 11:56:20 GMT-05:00
file stats: LOC: 69   Methods: 2
NCLOC: 22   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
GetConfigurationItem.java - 100% 100% 100%
coverage
 1    /*
 2    * Copyright 2005 The Regents of the University of Michigan
 3    *
 4    * Licensed under the Apache License, Version 2.0 (the "License");
 5    * you may not use this file except in compliance with the License.
 6    * You may obtain a copy of the License at
 7    *
 8    * http://www.apache.org/licenses/LICENSE-2.0
 9    *
 10    * Unless required by applicable law or agreed to in writing, software
 11    * distributed under the License is distributed on an "AS IS" BASIS,
 12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13    * See the License for the specific language governing permissions and
 14    * limitations under the License.
 15    */
 16   
 17    package org.proteomecommons.tranche.server;
 18   
 19    import java.io.ByteArrayOutputStream;
 20    import org.proteomecommons.tranche.Signature;
 21    import org.proteomecommons.tranche.remote.RemoteUtil;
 22    import org.proteomecommons.tranche.remote.Token;
 23    import org.proteomecommons.tranche.util.Configuration;
 24    import org.proteomecommons.tranche.util.ConfigurationUtil;
 25   
 26    /**
 27    * A server item for getting data off the DFS.
 28    *
 29    * @author Jayson Falkner - jfalkner@umich.edu
 30    * @version %I%, %G%
 31    * @since 1.0
 32    */
 33    public class GetConfigurationItem extends ServerItem {
 34    /**
 35    * @param server the server received
 36    * @since 1.0
 37    */
 38  380 public GetConfigurationItem(Server server) {
 39  380 super(Token.GET_CONFIGURATION_STRING, server);
 40    }
 41   
 42    /**
 43    * @param in the input stream
 44    * @param out the output stream
 45    * @throws Exception if any exception occurs
 46    * @since 1.0
 47    */
 48  224 public void doAction(java.io.InputStream in, java.io.OutputStream out) throws Exception {
 49    // get the hash
 50  224 byte[] bytes = RemoteUtil.getBytes(in);
 51    // get the signature
 52  224 Signature sig = RemoteUtil.readSignature(in);
 53   
 54    // execute it
 55  224 Configuration config = server.dfs.getConfiguration(sig, bytes);
 56   
 57    // add the number of currently connected users
 58  224 config.setValue("currentlyConnectedUsers", Integer.toString(server.currentlyConnectedUsers));
 59   
 60    // Log the transaction
 61  224 server.submitter.logGetConfiguration(this.clientIP);
 62   
 63    // serialize to a byte array
 64  224 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 65  224 ConfigurationUtil.write(config, baos);
 66    // write out the bytes
 67  224 RemoteUtil.writeData(baos.toByteArray(), out);
 68    }
 69    }