Rev 1276 | Rev 1278 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1276 | Rev 1277 | ||
---|---|---|---|
Line 92... | Line 92... | ||
92 | $res_iri = OIDplus::db()->query("select name from ###iri where oid = ?", array($id)); |
92 | $res_iri = OIDplus::db()->query("select name from ###iri where oid = ?", array($id)); |
93 | while ($row_iri = $res_iri->fetch_array()) { |
93 | while ($row_iri = $res_iri->fetch_array()) { |
94 | $output['iris'][] = $row_iri['name']; |
94 | $output['iris'][] = $row_iri['name']; |
95 | } |
95 | } |
96 | 96 | ||
- | 97 | $output['status'] = 0/*OK*/; |
|
97 | $res['status_bits'] = []; |
98 | $output['status_bits'] = []; |
98 | 99 | ||
99 | http_response_code(200); |
100 | http_response_code(200); |
100 | $output['status'] = 0/*OK*/; |
- | |
101 | return $output; |
101 | return $output; |
102 | } else if ($requestMethod == "PUT"/*Replace*/) { |
102 | } else if ($requestMethod == "PUT"/*Replace*/) { |
103 | $obj = OIDplusObject::parse($id); |
103 | $obj = OIDplusObject::parse($id); |
104 | if (!$obj) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!', 'PUT', $id), null, 400); |
104 | if (!$obj) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!', 'PUT', $id), null, 400); |
105 | 105 | ||
Line 113... | Line 113... | ||
113 | $params['asn1ids'] = $json_in['asn1ids'] ?? array(); |
113 | $params['asn1ids'] = $json_in['asn1ids'] ?? array(); |
114 | $params['iris'] = $json_in['iris'] ?? array(); |
114 | $params['iris'] = $json_in['iris'] ?? array(); |
115 | 115 | ||
116 | if (OIDplusObject::exists($id)) { |
116 | if (OIDplusObject::exists($id)) { |
117 | // TODO: Problem: The superior RA cannot set title/description, so they cannot perform the PUT command! |
117 | // TODO: Problem: The superior RA cannot set title/description, so they cannot perform the PUT command! |
118 | $res = self::action('Update', $params); |
118 | $output = self::action('Update', $params); |
119 | } else { |
119 | } else { |
120 | $params['parent'] = $obj->getParent(); |
120 | $params['parent'] = $obj->getParent(); |
121 | $params['id_fully_qualified'] = true; |
121 | $params['id_fully_qualified'] = true; |
122 | $res = self::action('Insert', $params); |
122 | $output = self::action('Insert', $params); |
123 | } |
123 | } |
124 | 124 | ||
125 | $res['status_bits'] = []; |
125 | $output['status_bits'] = []; |
126 | if (($res['status'] & 1) == 1) $res['status_bits'][1] = 'RA is not registered, but it can be invited'; |
126 | if (($output['status'] & 1) == 1) $output['status_bits'][1] = 'RA is not registered, but it can be invited'; |
127 | if (($res['status'] & 2) == 2) $res['status_bits'][2] = 'RA is not registered and it cannot be invited'; |
127 | if (($output['status'] & 2) == 2) $output['status_bits'][2] = 'RA is not registered and it cannot be invited'; |
128 | if (($res['status'] & 4) == 4) $res['status_bits'][4] = 'OID is a well-known OID, so RA, ASN.1, and IRI identifiers were reset'; |
128 | if (($output['status'] & 4) == 4) $output['status_bits'][4] = 'OID is a well-known OID, so RA, ASN.1, and IRI identifiers were reset'; |
129 | if (($res['status'] & 8) == 8) $res['status_bits'][8] = 'User has write rights to the freshly created OID'; |
129 | if (($output['status'] & 8) == 8) $output['status_bits'][8] = 'User has write rights to the freshly created OID'; |
130 | 130 | ||
131 | http_response_code(200); |
131 | http_response_code(200); |
132 | return $res; |
132 | return $output; |
133 | } else if ($requestMethod == "POST"/*Insert*/) { |
133 | } else if ($requestMethod == "POST"/*Insert*/) { |
134 | $params = $json_in; |
134 | $params = $json_in; |
135 | $obj = OIDplusObject::parse($id); |
135 | $obj = OIDplusObject::parse($id); |
136 | if (!$obj) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!', 'GET', $id), null, 400); |
136 | if (!$obj) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!', 'GET', $id), null, 400); |
137 | $params['parent'] = $obj->getParent(); |
137 | $params['parent'] = $obj->getParent(); |
138 | $params['id_fully_qualified'] = true; |
138 | $params['id_fully_qualified'] = true; |
139 | $params['id'] = $id; |
139 | $params['id'] = $id; |
140 | $res = self::action('Insert', $params); |
140 | $output = self::action('Insert', $params); |
141 | 141 | ||
142 | $res['status_bits'] = []; |
142 | $output['status_bits'] = []; |
143 | if (($res['status'] & 1) == 1) $res['status_bits'][1] = 'RA is not registered, but it can be invited'; |
143 | if (($output['status'] & 1) == 1) $output['status_bits'][1] = 'RA is not registered, but it can be invited'; |
144 | if (($res['status'] & 2) == 2) $res['status_bits'][2] = 'RA is not registered and it cannot be invited'; |
144 | if (($output['status'] & 2) == 2) $output['status_bits'][2] = 'RA is not registered and it cannot be invited'; |
145 | if (($res['status'] & 4) == 4) $res['status_bits'][4] = 'OID is a well-known OID, so RA, ASN.1, and IRI identifiers were reset'; |
145 | if (($output['status'] & 4) == 4) $output['status_bits'][4] = 'OID is a well-known OID, so RA, ASN.1, and IRI identifiers were reset'; |
146 | if (($res['status'] & 8) == 8) $res['status_bits'][8] = 'User has write rights to the freshly created OID'; |
146 | if (($output['status'] & 8) == 8) $output['status_bits'][8] = 'User has write rights to the freshly created OID'; |
147 | 147 | ||
148 | http_response_code(200); |
148 | http_response_code(200); |
149 | return $res; |
149 | return $output; |
150 | } else if ($requestMethod == "PATCH"/*Modify*/) { |
150 | } else if ($requestMethod == "PATCH"/*Modify*/) { |
151 | $params = $json_in; |
151 | $params = $json_in; |
152 | $params['id'] = $id; |
152 | $params['id'] = $id; |
153 | $res = self::action('Update', $params); |
153 | $output = self::action('Update', $params); |
154 | 154 | ||
155 | $res['status_bits'] = []; |
155 | $output['status_bits'] = []; |
156 | if (($res['status'] & 1) == 1) $res['status_bits'][1] = 'RA is not registered, but it can be invited'; |
156 | if (($output['status'] & 1) == 1) $output['status_bits'][1] = 'RA is not registered, but it can be invited'; |
157 | if (($res['status'] & 2) == 2) $res['status_bits'][2] = 'RA is not registered and it cannot be invited'; |
157 | if (($output['status'] & 2) == 2) $output['status_bits'][2] = 'RA is not registered and it cannot be invited'; |
158 | if (($res['status'] & 4) == 4) $res['status_bits'][4] = 'OID is a well-known OID, so RA, ASN.1, and IRI identifiers were reset'; |
158 | if (($output['status'] & 4) == 4) $output['status_bits'][4] = 'OID is a well-known OID, so RA, ASN.1, and IRI identifiers were reset'; |
159 | if (($res['status'] & 8) == 8) $res['status_bits'][8] = 'User has write rights to the freshly created OID'; |
159 | if (($output['status'] & 8) == 8) $output['status_bits'][8] = 'User has write rights to the freshly created OID'; |
160 | 160 | ||
161 | http_response_code(200); |
161 | http_response_code(200); |
162 | return $res; |
162 | return $output; |
163 | } else if ($requestMethod == "DELETE"/*Delete*/) { |
163 | } else if ($requestMethod == "DELETE"/*Delete*/) { |
164 | $params = $json_in; |
164 | $params = $json_in; |
165 | $params['id'] = $id; |
165 | $params['id'] = $id; |
166 | $res = self::action('Delete', $params); |
166 | $output = self::action('Delete', $params); |
167 | 167 | ||
168 | $res['status_bits'] = []; |
168 | $output['status_bits'] = []; |
169 | 169 | ||
170 | http_response_code(200); |
170 | http_response_code(200); |
171 | return $res; |
171 | return $output; |
172 | } else { |
172 | } else { |
173 | //throw new OIDplusException(_L("Not implemented"), null, 501); |
173 | //throw new OIDplusException(_L("Not implemented"), null, 501); |
174 | throw new OIDplusException(_L("Unsupported request method"), null, 400); |
174 | throw new OIDplusException(_L("Unsupported request method"), null, 400); |
175 | } |
175 | } |
176 | } else { |
176 | } else { |