Module: UU::OS::Attachment
- Extended by:
- Attachment
- Included in:
- Attachment
- Defined in:
- uu_os-0.29.16/lib/uu/os/attachment.rb,
uu_os-0.29.16/lib/uu/os/attachment/stream_wrapper.rb,
uu_os-0.29.16/lib/uu/os/attachment/attachment_create.rb,
uu_os-0.29.16/lib/uu/os/attachment/attachment_check_in.rb,
uu_os-0.29.16/lib/uu/os/attachment/attachment_check_out.rb,
uu_os-0.29.16/lib/uu/os/attachment/attachment_attributes.rb,
uu_os-0.29.16/lib/uu/os/attachment/attachment_set_attributes.rb,
uu_os-0.29.16/lib/uu/os/attachment/attachment_delete_version.rb,
uu_os-0.29.16/lib/uu/os/attachment/attachment_get_version_data.rb,
uu_os-0.29.16/lib/uu/os/attachment/attachment_get_version_list.rb,
uu_os-0.29.16/lib/uu/os/attachment/attachment_version_attributes.rb,
uu_os-0.29.16/lib/uu/os/attachment/attachment_get_attachment_list.rb,
uu_os-0.29.16/lib/uu/os/attachment/attachment_get_version_attributes.rb
Overview
Module Attachment.
Defined Under Namespace
Classes: AttachmentAttributes, AttachmentCheckIn, AttachmentCheckOut, AttachmentCreate, AttachmentDeleteVersion, AttachmentGetAttachmentList, AttachmentGetVersionAttributes, AttachmentGetVersionData, AttachmentGetVersionList, AttachmentSetAttributes, AttachmentVersionAttributes, StreamWrapper
Constant Summary
- PATH =
Service path
'ues/core/attachment/UESAttachment'
Instance Method Summary (collapse)
-
- (Object) check_in(attachment_uri, attachment = nil)
Updates the attached file in the system and unlocks it by default.
-
- (UU::OS::REST::BinaryValue) check_out(attachment_uri, options = nil)
Locks the attachment specified by the attachment_uri attribute.
-
- (UU::OS::UESURI) create(artifact_uri, attachment = nil)
Creates a new attachment to the specified artifact.
-
- (Object) delete(attachment_uri)
Deletes the specified attachment.
-
- (Object) delete_version(attachment_uri, version = nil)
Deletes an attachment version from the system.
-
- (UU::OS::REST::BinaryValue) get_attachment_data(attachment_uri)
Returns stream handler containing data content of the attachment.
-
- (UU::OS::REST::ResultList<Attachment::AttachmentGetAttachmentList, Attachment::AttachmentAttributes>) get_attachment_list(artifact_uri, criteria = nil)
Retrieves a result list of attachments for the artifact specified by the artifact_uri parameter.
-
- (AttachmentAttributes) get_attributes(attachment_uri)
Returns attributes representing the attachment specified by the attachment_uri attribute.
-
- (AttachmentVersionAttributes) get_version_attributes(attachment_uri, version = nil)
The uuCommand returns attributes of given attachment version.
-
- (UU::OS::REST::BinaryValue) get_version_data(attachment_uri, version)
Retrieves the data of the specified attachment version.
-
- (Array) get_version_list(attachment_uri, criteria = nil)
The uuCommand returns a list of the specified attachment's versions.
-
- (Object) set_attributes(attachment_uri, attachment = nil)
Updates basic attributes of an attachment.
Instance Method Details
- (Object) check_in(attachment_uri, attachment = nil)
Updates the attached file in the system and unlocks it by default. The command succeeds if the attachment is unlocked or if it is locked by the current user. Otherwise, the command fails. At the very least, attachment data and the filename have to be specified in this command. The data are streamed.
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'uu_os-0.29.16/lib/uu/os/attachment.rb', line 138 def check_in(, = nil) svc = UU::OS::REST::RemoteClient.new(Attachment) payload = Attachment::AttachmentCheckIn.new() ############### ##IMPORTANT!!## ############### # Attachment.create and check_in are a special case. Unlike other commands that upload bigger data (Sheet.check_in etc.), these # don't do it directly by calling the REST api and sending the whole payload to it. Instead we first try to take the data # and upload them to UDS binary store. If that succeeds, only the resulting UDS uri is sent as attachment data so the attachment # command retrieves the actual data server-side from the UDS service. But should the uds upload fail, we need to send the data # the usual way. But some types of stream cant be re-used so we have to make a backup of them so in case of the UDS failure, there # is something to send again. ############### blob_uri = handle_input_data(payload) # Blob uri wasnt supplied, we need prepare backup before we proceed with UDS upload backup = backup_if_necessary(payload) if blob_uri.nil? # Upload data by uds (unless user has supplied his uds uri) blob_uri = upload_to_uds(payload.data, backup) unless blob_uri UU::OS::QoS::QoSHandler.auto_retry do payload = prepare_payload_for_upload(payload,blob_uri,backup) begin svc.post('checkIn', , payload) ensure silent_cleanup(backup,blob_uri) end end end |
- (UU::OS::REST::BinaryValue) check_out(attachment_uri, options = nil)
Locks the attachment specified by the attachment_uri attribute. If the operation is successful or if the attachment is already locked by the current user, attachment stream handler or nil is returned depending on the options set in the attribute options. If the attachment cannot be locked because the attachment is locked by another user, the command will fail.
118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'uu_os-0.29.16/lib/uu/os/attachment.rb', line 118 def check_out(, = nil) svc = UU::OS::REST::RemoteClient.new(Attachment) dto = Attachment::AttachmentCheckOut.new() payload = dto.to_json UU::OS::QoS::QoSHandler.auto_retry do if dto.return_stream_handler == TRUE return svc.post_binary('checkOut', , payload) else svc.post('checkOut', , payload) return nil end end end |
- (UU::OS::UESURI) create(artifact_uri, attachment = nil)
Creates a new attachment to the specified artifact. At the very least, attachment data and filename have to be specified in this command. The data are streamed.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'uu_os-0.29.16/lib/uu/os/attachment.rb', line 37 def create(artifact_uri, = nil) svc = UU::OS::REST::RemoteClient.new(Attachment) payload = Attachment::AttachmentCreate.new() ############### ##IMPORTANT!!## ############### # Attachment.create and check_in are a special case. Unlike other commands that upload bigger data (Sheet.check_in etc.), these # don't do it directly by calling the REST api and sending the whole payload to it. Instead we first try to take the data # and upload them to UDS binary store. If that succeeds, only the resulting UDS uri is sent as attachment data so the attachment # command retrieves the actual data server-side from the UDS service. But should the uds upload fail, we need to send the data # the usual way. But some types of stream cant be re-used so we have to make a backup of them so in case of the UDS failure, there # is something to send again. ############### blob_uri = handle_input_data(payload) # Blob uri wasnt supplied, we need prepare backup before we proceed with UDS upload backup = backup_if_necessary(payload) if blob_uri.nil? # Upload data by uds (unless user has supplied his uds uri) blob_uri = upload_to_uds(payload.data, backup) unless blob_uri UU::OS::QoS::QoSHandler.auto_retry do payload = prepare_payload_for_upload(payload,blob_uri,backup) begin res = svc.post('create', artifact_uri, payload) return UU::OS::UESURI.new(res) ensure silent_cleanup(backup,blob_uri) end end end |
- (Object) delete(attachment_uri)
Deletes the specified attachment.
189 190 191 192 193 194 |
# File 'uu_os-0.29.16/lib/uu/os/attachment.rb', line 189 def delete() svc = UU::OS::REST::RemoteClient.new(Attachment) UU::OS::QoS::QoSHandler.auto_retry do svc.post('delete', ) end end |
- (Object) delete_version(attachment_uri, version = nil)
Deletes an attachment version from the system.
220 221 222 223 224 225 226 227 |
# File 'uu_os-0.29.16/lib/uu/os/attachment.rb', line 220 def delete_version(, version = nil) svc = UU::OS::REST::RemoteClient.new(Attachment) payload = UU::OS::Attachment::AttachmentDeleteVersion.new(version).to_json UU::OS::QoS::QoSHandler.auto_retry do svc.post('deleteVersion', , payload) end end |
- (UU::OS::REST::BinaryValue) get_attachment_data(attachment_uri)
Returns stream handler containing data content of the attachment. If the attachment is locked by the same user, command returns data of the private version. If the attachment is locked by another user (or if the attachment is unlocked), command returns data of the public version. Command does not change the state of the attachment or its lock in the system.
179 180 181 182 183 184 |
# File 'uu_os-0.29.16/lib/uu/os/attachment.rb', line 179 def () svc = UU::OS::REST::RemoteClient.new(Attachment) UU::OS::QoS::QoSHandler.auto_retry do return svc.get_binary('getAttachmentData', ) end end |
- (UU::OS::REST::ResultList<Attachment::AttachmentGetAttachmentList, Attachment::AttachmentAttributes>) get_attachment_list(artifact_uri, criteria = nil)
Retrieves a result list of attachments for the artifact specified by the artifact_uri parameter. The resulting attachment list is filtered according to the criteria provided by the criteria attribute. These criteria specify the page to return and name and code filters. The list is sorted (ascending) according to the attachment name and code.
97 98 99 100 101 102 103 104 105 106 107 |
# File 'uu_os-0.29.16/lib/uu/os/attachment.rb', line 97 def (artifact_uri, criteria = nil) svc = UU::OS::REST::RemoteClient.new(Attachment) dto = Attachment::AttachmentGetAttachmentList.new(criteria) svc.add_parameter('pageIndex', dto.page_index) svc.add_parameter('pageSize', dto.page_size) svc.add_parameter('query', dto.query) UU::OS::QoS::QoSHandler.auto_retry do res = svc.get('getAttachmentList', artifact_uri) return UU::OS::REST::ResultList.new(Attachment::AttachmentGetAttachmentList, Attachment::AttachmentAttributes, res) end end |
- (AttachmentAttributes) get_attributes(attachment_uri)
Returns attributes representing the attachment specified by the attachment_uri attribute. If the attachment is locked by the current user, this command returns attributes of the private version. If the attachment is locked by another user (or if the attachment is unlocked), the command returns attributes of the public version. The command does not change the state of the attachment or its lock in the system.
80 81 82 83 84 85 86 |
# File 'uu_os-0.29.16/lib/uu/os/attachment.rb', line 80 def get_attributes() svc = UU::OS::REST::RemoteClient.new(Attachment) UU::OS::QoS::QoSHandler.auto_retry do res = svc.get('getAttributes', ) return Attachment::AttachmentAttributes.new(res) end end |
- (AttachmentVersionAttributes) get_version_attributes(attachment_uri, version = nil)
The uuCommand returns attributes of given attachment version.
262 263 264 265 266 267 268 269 270 271 |
# File 'uu_os-0.29.16/lib/uu/os/attachment.rb', line 262 def get_version_attributes(, version = nil) svc = UU::OS::REST::RemoteClient.new(Attachment) dto = UU::OS::Attachment::AttachmentGetVersionAttributes.new(version) svc.add_parameter('versionId', dto.version_id) UU::OS::QoS::QoSHandler.auto_retry do res = svc.get('getVersionAttributes', ) return Attachment::AttachmentVersionAttributes.new(res) end end |
- (UU::OS::REST::BinaryValue) get_version_data(attachment_uri, version)
Retrieves the data of the specified attachment version.
240 241 242 243 244 245 246 247 248 |
# File 'uu_os-0.29.16/lib/uu/os/attachment.rb', line 240 def get_version_data(, version) svc = UU::OS::REST::RemoteClient.new(Attachment) dto = UU::OS::Attachment::AttachmentGetVersionData.new(version) svc.add_parameter('versionId', dto.version_id) UU::OS::QoS::QoSHandler.auto_retry do result = svc.get_binary('getVersionData', ) return result end end |
- (Array) get_version_list(attachment_uri, criteria = nil)
The uuCommand returns a list of the specified attachment's versions.
284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'uu_os-0.29.16/lib/uu/os/attachment.rb', line 284 def get_version_list(, criteria = nil) svc = UU::OS::REST::RemoteClient.new(Attachment) dto = UU::OS::Attachment::AttachmentGetVersionList.new(criteria) svc.add_parameter('pageIndex', dto.page_index) svc.add_parameter('pageSize', dto.page_size) svc.add_parameter('query', dto.query) UU::OS::QoS::QoSHandler.auto_retry do res = svc.get('getVersionList', ) return UU::OS::REST::ResultList.new(Attachment::AttachmentGetVersionList, Attachment::AttachmentVersionAttributes, res) end end |
- (Object) set_attributes(attachment_uri, attachment = nil)
Updates basic attributes of an attachment.
202 203 204 205 206 207 208 209 |
# File 'uu_os-0.29.16/lib/uu/os/attachment.rb', line 202 def set_attributes(, = nil) svc = UU::OS::REST::RemoteClient.new(Attachment) payload = UU::OS::Attachment::AttachmentSetAttributes.new().to_json UU::OS::QoS::QoSHandler.auto_retry do res = svc.post('setAttributes', , payload) return UU::OS::UESURI.new(res) end end |