001/* 002 * Copyright (C) 2014 Jörg Prante 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.xbib.elasticsearch.action.plugin.jdbc.state.delete; 017 018import org.elasticsearch.action.ActionRequestValidationException; 019import org.elasticsearch.action.support.master.AcknowledgedRequest; 020import org.elasticsearch.common.io.stream.StreamInput; 021import org.elasticsearch.common.io.stream.StreamOutput; 022 023import java.io.IOException; 024 025import static org.elasticsearch.action.ValidateActions.addValidationError; 026 027public class DeleteRiverStateRequest extends AcknowledgedRequest<DeleteRiverStateRequest> { 028 029 private String riverName; 030 031 private String riverType; 032 033 public DeleteRiverStateRequest setRiverName(String riverName) { 034 this.riverName = riverName; 035 return this; 036 } 037 038 public String getRiverName() { 039 return riverName; 040 } 041 042 public DeleteRiverStateRequest setRiverType(String riverType) { 043 this.riverType = riverType; 044 return this; 045 } 046 047 public String getRiverType() { 048 return riverType; 049 } 050 051 @Override 052 public ActionRequestValidationException validate() { 053 ActionRequestValidationException validationException = null; 054 if (riverName == null) { 055 validationException = addValidationError("name is missing", null); 056 } 057 if (riverType == null) { 058 validationException = addValidationError("type is missing", null); 059 } 060 return validationException; 061 } 062 063 @Override 064 public void readFrom(StreamInput in) throws IOException { 065 super.readFrom(in); 066 readTimeout(in); 067 this.riverName = in.readString(); 068 } 069 070 @Override 071 public void writeTo(StreamOutput out) throws IOException { 072 super.writeTo(out); 073 writeTimeout(out); 074 out.writeString(riverName); 075 } 076}