Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
synergy-api-util
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Raimbek Egemberdiev
synergy-api-util
Commits
a132f0a8
Commit
a132f0a8
authored
Nov 14, 2016
by
Abzal Kultayev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TASK #CMER] Сохранение файлов в реестр Документы-Услуги 2 работают теперь
parent
7592ec7c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
159 additions
and
0 deletions
+159
-0
src/main/java/kz/arta/synergy/api/services/StorageService.java
...ain/java/kz/arta/synergy/api/services/StorageService.java
+39
-0
src/main/java/kz/arta/synergy/api/services/storage/Attachment.java
...java/kz/arta/synergy/api/services/storage/Attachment.java
+87
-0
src/main/java/kz/arta/synergy/api/services/storage/AttachmentList.java
.../kz/arta/synergy/api/services/storage/AttachmentList.java
+11
-0
src/test/java/kz/arta/synergy/api/services/StorageServiceTest.java
...java/kz/arta/synergy/api/services/StorageServiceTest.java
+22
-0
No files found.
src/main/java/kz/arta/synergy/api/services/StorageService.java
View file @
a132f0a8
...
@@ -4,6 +4,8 @@ import kz.arta.synergy.api.JsonUtils;
...
@@ -4,6 +4,8 @@ import kz.arta.synergy.api.JsonUtils;
import
kz.arta.synergy.api.Query
;
import
kz.arta.synergy.api.Query
;
import
kz.arta.synergy.api.QueryContext
;
import
kz.arta.synergy.api.QueryContext
;
import
kz.arta.synergy.api.RestHttpQuery
;
import
kz.arta.synergy.api.RestHttpQuery
;
import
kz.arta.synergy.api.services.storage.Attachment
;
import
kz.arta.synergy.api.services.storage.AttachmentList
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -34,4 +36,41 @@ public class StorageService {
...
@@ -34,4 +36,41 @@ public class StorageService {
return
JsonUtils
.
getValueByKey
(
result
,
"file"
);
return
JsonUtils
.
getValueByKey
(
result
,
"file"
);
}
}
/**
* Метод добавляет вложение к документу из временного файла, загруженного на сервер с помощью API метода rest/api/storage/start_upload
* @param documentID идентификатор документа
* @param filename название файла
* @param filepath путь до файла на сервере
* @return errorCode и errorMessage
* @throws IOException при проблеммах с сетью
*/
public
String
createAttachment
(
String
documentID
,
String
filename
,
String
filepath
)
throws
IOException
{
Query
query
=
Query
.
newInstance
()
.
methodPost
()
.
url
(
"/rest/api/docflow/doc/attachment/create"
)
.
formParam
(
"fileName"
,
filename
)
.
formParam
(
"filePath"
,
filepath
)
.
formParam
(
"path"
,
"ase:workContainer"
)
.
formParam
(
"documentID"
,
documentID
);
return
restHttpQuery
.
doQuery
(
query
);
}
public
Attachment
createAndGetAttachment
(
String
documentID
,
String
filename
,
String
filepath
)
throws
IOException
{
String
attachment
=
createAttachment
(
documentID
,
filename
,
filepath
);
if
(!
JsonUtils
.
getValueByKey
(
attachment
,
"errorCode"
).
equals
(
"0"
))
{
throw
new
IOException
(
"Attachment was not created"
);
}
AttachmentList
lastAttachments
=
getLastAttachments
(
documentID
);
return
lastAttachments
.
get
(
0
);
}
public
AttachmentList
getLastAttachments
(
String
documentID
)
throws
IOException
{
Query
query
=
Query
.
newInstance
()
.
url
(
"/rest/api/docflow/doc/last_attachments"
)
.
queryParam
(
"documentID"
,
documentID
);
return
JsonUtils
.
read
(
restHttpQuery
.
doQuery
(
query
),
AttachmentList
.
class
);
}
}
}
src/main/java/kz/arta/synergy/api/services/storage/Attachment.java
0 → 100644
View file @
a132f0a8
package
kz.arta.synergy.api.services.storage
;
import
org.codehaus.jackson.annotate.JsonIgnoreProperties
;
import
org.codehaus.jackson.annotate.JsonProperty
;
/**
* Created by: Abzal Kultayev
* Date: 14.11.16
* Time: 13:19
*/
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
Attachment
{
private
String
uuid
;
private
String
dataUUID
;
private
boolean
mobile
;
private
String
name
;
@JsonProperty
(
"is_editable"
)
private
boolean
isEditable
;
@JsonProperty
(
"created_label"
)
private
String
createdLabel
;
private
String
created
;
private
String
icon
;
public
String
getUuid
()
{
return
uuid
;
}
public
void
setUuid
(
String
uuid
)
{
this
.
uuid
=
uuid
;
}
public
String
getDataUUID
()
{
return
dataUUID
;
}
public
void
setDataUUID
(
String
dataUUID
)
{
this
.
dataUUID
=
dataUUID
;
}
public
boolean
isMobile
()
{
return
mobile
;
}
public
void
setMobile
(
boolean
mobile
)
{
this
.
mobile
=
mobile
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
boolean
isEditable
()
{
return
isEditable
;
}
public
void
setEditable
(
boolean
editable
)
{
isEditable
=
editable
;
}
public
String
getCreatedLabel
()
{
return
createdLabel
;
}
public
void
setCreatedLabel
(
String
createdLabel
)
{
this
.
createdLabel
=
createdLabel
;
}
public
String
getCreated
()
{
return
created
;
}
public
void
setCreated
(
String
created
)
{
this
.
created
=
created
;
}
public
String
getIcon
()
{
return
icon
;
}
public
void
setIcon
(
String
icon
)
{
this
.
icon
=
icon
;
}
}
src/main/java/kz/arta/synergy/api/services/storage/AttachmentList.java
0 → 100644
View file @
a132f0a8
package
kz.arta.synergy.api.services.storage
;
import
java.util.ArrayList
;
/**
* Created by: Abzal Kultayev
* Date: 14.11.16
* Time: 13:36
*/
public
class
AttachmentList
extends
ArrayList
<
Attachment
>
{
}
src/test/java/kz/arta/synergy/api/services/StorageServiceTest.java
View file @
a132f0a8
package
kz.arta.synergy.api.services
;
package
kz.arta.synergy.api.services
;
import
kz.arta.synergy.api.QueryContext
;
import
kz.arta.synergy.api.QueryContext
;
import
kz.arta.synergy.api.services.storage.Attachment
;
import
kz.arta.synergy.api.services.storage.AttachmentList
;
import
org.testng.annotations.Test
;
import
org.testng.annotations.Test
;
import
static
org
.
testng
.
Assert
.*;
import
static
org
.
testng
.
Assert
.*;
...
@@ -12,10 +14,30 @@ import static org.testng.Assert.*;
...
@@ -12,10 +14,30 @@ import static org.testng.Assert.*;
*/
*/
public
class
StorageServiceTest
{
public
class
StorageServiceTest
{
StorageService
service
=
StorageService
.
newInstance
(
new
QueryContext
(
"http://192.168.3.233:8080/Synergy"
,
"NppAdmin"
,
"123456"
));
StorageService
service
=
StorageService
.
newInstance
(
new
QueryContext
(
"http://192.168.3.233:8080/Synergy"
,
"NppAdmin"
,
"123456"
));
private
String
documentID
=
"05647530-a72f-11e6-bfd9-00163ebf20cd"
;
@Test
@Test
public
void
testStartUploadFile
()
throws
Exception
{
public
void
testStartUploadFile
()
throws
Exception
{
String
tempFileName
=
service
.
startUploadFile
();
String
tempFileName
=
service
.
startUploadFile
();
assertNotNull
(
tempFileName
);
assertNotNull
(
tempFileName
);
}
}
@Test
public
void
testCreateAttachment
()
throws
Exception
{
String
tempFileName
=
service
.
startUploadFile
();
String
attachment
=
service
.
createAttachment
(
documentID
,
"FILENAME.PDF"
,
tempFileName
);
assertEquals
(
attachment
,
""
);
}
@Test
public
void
testLastAttachments
()
throws
Exception
{
AttachmentList
attachmentList
=
service
.
getLastAttachments
(
documentID
);
assertNotNull
(
attachmentList
);
}
@Test
public
void
testCreateAndGetAttachment
()
throws
Exception
{
String
tempFileName
=
service
.
startUploadFile
();
Attachment
attachment
=
service
.
createAndGetAttachment
(
documentID
,
"Filename.pdf"
,
tempFileName
);
assertNotNull
(
attachment
);
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment