1 /*
2 * This file is part of Waarp Project (named also Waarp or GG).
3 *
4 * Copyright (c) 2019, Waarp SAS, and individual contributors by the @author
5 * tags. See the COPYRIGHT.txt in the distribution for a full listing of
6 * individual contributors.
7 *
8 * All Waarp Project is free software: you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY
14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * Waarp . If not, see <http://www.gnu.org/licenses/>.
19 */
20 package org.waarp.openr66.protocol.localhandler.packet.json;
21
22 import org.waarp.openr66.protocol.localhandler.packet.LocalPacketFactory;
23
24 /**
25 * Information (on request or on filesystem) JSON packet
26 */
27 public class InformationJsonPacket extends JsonPacket {
28
29 protected boolean isIdRequest;
30 protected long id;
31 protected boolean isTo;
32 protected byte request;
33 protected String rulename;
34 protected String filename;
35
36 /**
37 * Empty constructor
38 */
39 public InformationJsonPacket() {
40
41 }
42
43 /**
44 * Constructor for Transfer Request Information
45 *
46 * @param id
47 * @param isTo
48 * @param remoteHost
49 */
50 public InformationJsonPacket(final long id, final boolean isTo,
51 final String remoteHost) {
52 setId(id);
53 setTo(isTo);
54 setRulename(remoteHost);
55 setIdRequest(true);
56 setRequestUserPacket();
57 }
58
59 /**
60 * Constructor for File information
61 *
62 * @param request InformationPacket.ASKENUM ordinal (converted to
63 * byte)
64 * @param rulename
65 * @param filename
66 */
67 public InformationJsonPacket(final byte request, final String rulename,
68 final String filename) {
69 setRequest(request);
70 setFilename(filename);
71 setRulename(rulename);
72 setIdRequest(false);
73 setRequestUserPacket();
74 }
75
76 /**
77 * @return the isIdRequest
78 */
79 public final boolean isIdRequest() {
80 return isIdRequest;
81 }
82
83 /**
84 * @param isIdRequest the isIdRequest to True for Transfer Request,
85 * else
86 * for File listing
87 */
88 public final void setIdRequest(final boolean isIdRequest) {
89 this.isIdRequest = isIdRequest;
90 }
91
92 /**
93 * @return the id
94 */
95 public final long getId() {
96 return id;
97 }
98
99 /**
100 * @param id the id to set
101 */
102 public final void setId(final long id) {
103 this.id = id;
104 }
105
106 /**
107 * @return the isTo for Transfer, determine the way of the transfer as
108 * requester/requested (isTo true/false)
109 */
110 public final boolean isTo() {
111 return isTo;
112 }
113
114 /**
115 * @param isTo the isTo to set
116 */
117 public final void setTo(final boolean isTo) {
118 this.isTo = isTo;
119 }
120
121 /**
122 * @return the request
123 */
124 public final byte getRequest() {
125 return request;
126 }
127
128 /**
129 * @param request the request to set
130 */
131 public final void setRequest(final byte request) {
132 this.request = request;
133 }
134
135 /**
136 * @return the rulename
137 */
138 public final String getRulename() {
139 return rulename;
140 }
141
142 /**
143 * @param rulename the rulename to set (if Transfer and Json
144 * requester/requested (isTo true/false))
145 */
146 public final void setRulename(final String rulename) {
147 this.rulename = rulename;
148 }
149
150 /**
151 * @return the filename
152 */
153 public final String getFilename() {
154 return filename;
155 }
156
157 /**
158 * @param filename the filename to set
159 */
160 public final void setFilename(final String filename) {
161 this.filename = filename;
162 }
163
164 @Override
165 public final void setRequestUserPacket() {
166 setRequestUserPacket(LocalPacketFactory.INFORMATIONPACKET);
167 }
168 }