Clover coverage report -
Coverage timestamp: Mon May 5 2008 11:56:20 GMT-05:00
file stats: LOC: 66   Methods: 2
NCLOC: 20   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
GetDataItem.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.FileNotFoundException;
 20    import org.proteomecommons.tranche.remote.RemoteUtil;
 21    import org.proteomecommons.tranche.remote.Token;
 22    import org.proteomecommons.tranche.util.BigHash;
 23   
 24    /**
 25    * A server item for getting data off the DFS.
 26    *
 27    * @author Jayson Falkner - jfalkner@umich.edu
 28    * @version %I%, %G%
 29    * @since 1.0
 30    */
 31    public class GetDataItem extends ServerItem {
 32    /**
 33    * @param server the server received
 34    * @since 1.0
 35    */
 36  380 public GetDataItem(Server server) {
 37  380 super(Token.GET_DATA_STRING, server);
 38    }
 39   
 40    /**
 41    * @param in the input stream
 42    * @param out the output stream
 43    * @throws Exception if any exception occurs
 44    * @since 1.0
 45    */
 46  567 public void doAction(java.io.InputStream in, java.io.OutputStream out) throws Exception {
 47    // get the hash
 48  567 byte[] bytes = RemoteUtil.getBytes(in);
 49    // convert to a hash
 50  567 BigHash hash = BigHash.createFromBytes(bytes);
 51    // get the input stream
 52  567 try {
 53    // write out the end
 54  567 RemoteUtil.writeData(server.dfs.getData(hash), out);
 55   
 56    // Log the transaction
 57  553 server.submitter.logGetData(hash,this.clientIP);
 58   
 59    } catch (Exception e){
 60    // System.out.println("*** GetDataItem Error ***\n");
 61    // e.printStackTrace(System.out);
 62    //
 63  14 RemoteUtil.writeError(e.getMessage(), out);
 64    }
 65    }
 66    }