|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| HasMetaDataItem.java | 100% | 100% | 100% | 100% |
|
||||||||||||||
| 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 org.proteomecommons.tranche.remote.RemoteUtil; | |
| 20 | import org.proteomecommons.tranche.remote.Token; | |
| 21 | import org.proteomecommons.tranche.util.BigHash; | |
| 22 | ||
| 23 | /** | |
| 24 | * @author Jayson Falkner - jfalkner@umich.edu | |
| 25 | * @version %I%, %G% | |
| 26 | * @since 1.0 | |
| 27 | */ | |
| 28 | public class HasMetaDataItem extends ServerItem { | |
| 29 | /** | |
| 30 | * @param server the server received | |
| 31 | * @since 1.0 | |
| 32 | */ | |
| 33 | 380 | public HasMetaDataItem(Server server) { |
| 34 | 380 | super(Token.HAS_META_STRING, server); |
| 35 | } | |
| 36 | ||
| 37 | /** | |
| 38 | * @param in the input stream | |
| 39 | * @param out the output stream | |
| 40 | * @throws Exception if any exception occurs | |
| 41 | * @since 1.0 | |
| 42 | */ | |
| 43 | 2117 | public void doAction(java.io.InputStream in, java.io.OutputStream out) throws Exception { |
| 44 | // get the hash | |
| 45 | 2117 | byte[] bytes = RemoteUtil.getBytes(in); |
| 46 | // convert to a hash | |
| 47 | 2117 | BigHash hash = BigHash.createFromBytes(bytes); |
| 48 | // write out the end | |
| 49 | 2117 | boolean hasData = server.dfs.hasMetaData(hash); |
| 50 | 2115 | if (hasData) { |
| 51 | 764 | RemoteUtil.writeLine(Token.OK_STRING, out); |
| 52 | } else { | |
| 53 | 1351 | RemoteUtil.writeLine(Token.NO_STRING, out); |
| 54 | } | |
| 55 | } | |
| 56 | } |
|
||||||||||