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
466d0b4e
Commit
466d0b4e
authored
Nov 16, 2016
by
Raimbek Egemberdiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: AsFormData перегружал методы AsFormDataContainer
parent
9debbcab
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
103 additions
and
12 deletions
+103
-12
build.gradle
build.gradle
+1
-2
src/main/java/kz/arta/synergy/api/RestHttpQuery.java
src/main/java/kz/arta/synergy/api/RestHttpQuery.java
+22
-1
src/main/java/kz/arta/synergy/api/asforms/AsFormService.java
src/main/java/kz/arta/synergy/api/asforms/AsFormService.java
+9
-0
src/main/java/kz/arta/synergy/api/asforms/converter/DefaultAsFormConverter.java
...synergy/api/asforms/converter/DefaultAsFormConverter.java
+1
-1
src/main/java/kz/arta/synergy/api/asforms/converter/components/AbstractComponentConverter.java
...orms/converter/components/AbstractComponentConverter.java
+2
-2
src/main/java/kz/arta/synergy/api/asforms/pojo/AsFormDataContainer.java
...kz/arta/synergy/api/asforms/pojo/AsFormDataContainer.java
+6
-6
src/main/java/kz/arta/synergy/api/pojo/SynergyFile.java
src/main/java/kz/arta/synergy/api/pojo/SynergyFile.java
+44
-0
src/main/java/kz/arta/synergy/api/services/StorageService.java
...ain/java/kz/arta/synergy/api/services/StorageService.java
+18
-0
No files found.
build.gradle
View file @
466d0b4e
...
...
@@ -11,9 +11,8 @@ repositories {
def
jacksonVersion
=
'1.9.2'
dependencies
{
// compile group: 'cglib', name: 'cglib', version: '3.2.4'
testCompile
group:
'org.testng'
,
name:
'testng'
,
version:
'6.8'
testCompile
group:
'org.mockito'
,
name:
'mockito-all'
,
version:
'1.
9.5
'
testCompile
group:
'org.mockito'
,
name:
'mockito-all'
,
version:
'1.
10.19
'
compile
group:
'com.google.guava'
,
name:
'guava'
,
version:
'19.0'
compile
(
group:
'org.codehaus.jackson'
,
name:
'jackson-core-asl'
,
version:
jacksonVersion
,
transitive:
false
)
compile
(
group:
'org.codehaus.jackson'
,
name:
'jackson-mapper-asl'
,
version:
jacksonVersion
,
transitive:
false
)
...
...
src/main/java/kz/arta/synergy/api/RestHttpQuery.java
View file @
466d0b4e
...
...
@@ -26,7 +26,7 @@ public class RestHttpQuery {
this
.
context
=
context
;
}
p
ublic
String
doQuery
(
Query
query
)
throws
IOException
{
p
rivate
HttpURLConnection
doQueryAndReturnConnection
(
Query
query
)
throws
IOException
{
URL
url
=
new
URL
(
context
.
getAddress
()
+
makeQuery
(
query
.
getUrl
(),
query
.
getQueryParams
()));
HttpURLConnection
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
conn
.
setConnectTimeout
(
TIMEOUT
);
...
...
@@ -56,8 +56,29 @@ public class RestHttpQuery {
request
.
flush
();
request
.
close
();
}
return
conn
;
}
public
String
doQuery
(
Query
query
)
throws
IOException
{
HttpURLConnection
conn
=
doQueryAndReturnConnection
(
query
);
return
readStringReturn
(
conn
);
}
public
byte
[]
doQueryAndReturnBytes
(
Query
query
)
throws
IOException
{
HttpURLConnection
conn
=
doQueryAndReturnConnection
(
query
);
InputStream
is
=
conn
.
getInputStream
();
ByteArrayOutputStream
buffer
=
new
ByteArrayOutputStream
();
int
nRead
;
byte
[]
data
=
new
byte
[
16384
];
while
((
nRead
=
is
.
read
(
data
,
0
,
data
.
length
))
!=
-
1
)
{
buffer
.
write
(
data
,
0
,
nRead
);
}
buffer
.
flush
();
return
buffer
.
toByteArray
();
}
private
String
makeQuery
(
String
query
,
Map
<
String
,
?>
params
)
{
...
...
src/main/java/kz/arta/synergy/api/asforms/AsFormService.java
View file @
466d0b4e
...
...
@@ -149,4 +149,13 @@ public class AsFormService {
public
<
T
extends
AsForm
>
AsFormWrapper
toAsfData
(
T
asForm
)
{
return
asFormConverter
.
toAsfData
(
asForm
);
}
public
byte
[]
printForm
(
String
dataUUID
,
String
format
)
throws
IOException
{
Query
query
=
Query
.
newInstance
()
.
url
(
"/rest/api/asforms/template/print/form"
)
.
queryParam
(
"dataUUID"
,
dataUUID
)
.
queryParam
(
"format"
,
format
);
return
restHttpQuery
.
doQueryAndReturnBytes
(
query
);
}
}
src/main/java/kz/arta/synergy/api/asforms/converter/DefaultAsFormConverter.java
View file @
466d0b4e
...
...
@@ -21,7 +21,7 @@ import java.util.Map;
*/
public
class
DefaultAsFormConverter
implements
AsFormConverter
{
Map
<
Class
<?
extends
Annotation
>,
ComponentConverter
>
componentConverters
=
new
HashMap
<>();
private
final
Map
<
Class
<?
extends
Annotation
>,
ComponentConverter
>
componentConverters
=
new
HashMap
<>();
public
DefaultAsFormConverter
()
{
registerConverter
(
Cmp
.
class
,
new
CommonConverter
());
...
...
src/main/java/kz/arta/synergy/api/asforms/converter/components/AbstractComponentConverter.java
View file @
466d0b4e
...
...
@@ -107,9 +107,9 @@ public abstract class AbstractComponentConverter implements ComponentConverter {
private
String
getValueForClassField
(
Field
field
,
AsFormDataContainer
asfData
,
String
cmpId
)
{
if
(
hasKeyValueAnnotation
(
field
))
{
return
asfData
.
getKey
(
cmpId
);
return
asfData
.
getKey
FromInnerData
(
cmpId
);
}
return
asfData
.
getValue
(
cmpId
);
return
asfData
.
getValue
FromInnerData
(
cmpId
);
}
private
String
getNumberValueForField
(
AsFormDataContainer
asfData
,
Field
field
,
String
cmpId
)
{
...
...
src/main/java/kz/arta/synergy/api/asforms/pojo/AsFormDataContainer.java
View file @
466d0b4e
...
...
@@ -31,7 +31,7 @@ public class AsFormDataContainer {
return
null
;
}
public
String
getValue
(
String
cmpId
)
{
public
String
getValue
FromInnerData
(
String
cmpId
)
{
AsFormData
data
=
getData
(
cmpId
);
if
(
data
!=
null
)
{
return
data
.
getValue
();
...
...
@@ -39,15 +39,15 @@ public class AsFormDataContainer {
return
null
;
}
public
String
getValue
(
String
cmpId
,
String
defaultValue
)
{
String
value
=
getValue
(
cmpId
);
public
String
getValue
FromInnerData
(
String
cmpId
,
String
defaultValue
)
{
String
value
=
getValue
FromInnerData
(
cmpId
);
if
(
value
==
null
)
{
return
defaultValue
;
}
return
value
;
}
public
String
getKey
(
String
cmpId
)
{
public
String
getKey
FromInnerData
(
String
cmpId
)
{
AsFormData
data
=
getData
(
cmpId
);
if
(
data
!=
null
)
{
return
data
.
getKey
();
...
...
@@ -55,8 +55,8 @@ public class AsFormDataContainer {
return
null
;
}
public
String
getKey
(
String
cmpId
,
String
defaultKey
)
{
String
key
=
getKey
(
cmpId
);
public
String
getKey
FromInnerData
(
String
cmpId
,
String
defaultKey
)
{
String
key
=
getKey
FromInnerData
(
cmpId
);
if
(
key
==
null
)
{
return
defaultKey
;
}
...
...
src/main/java/kz/arta/synergy/api/pojo/SynergyFile.java
0 → 100644
View file @
466d0b4e
package
kz.arta.synergy.api.pojo
;
import
org.codehaus.jackson.annotate.JsonIgnoreProperties
;
import
org.codehaus.jackson.annotate.JsonProperty
;
/**
* @author raimbek
* @since 03.08.2016
*/
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
SynergyFile
{
private
String
identifier
;
private
String
name
;
@JsonProperty
(
"is_folder"
)
private
boolean
isFolder
;
public
SynergyFile
()
{
}
public
String
getIdentifier
()
{
return
identifier
;
}
public
void
setIdentifier
(
String
identifier
)
{
this
.
identifier
=
identifier
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
boolean
isFolder
()
{
return
isFolder
;
}
public
void
setIsFolder
(
boolean
isFolder
)
{
this
.
isFolder
=
isFolder
;
}
}
src/main/java/kz/arta/synergy/api/services/StorageService.java
View file @
466d0b4e
...
...
@@ -4,10 +4,13 @@ import kz.arta.synergy.api.JsonUtils;
import
kz.arta.synergy.api.Query
;
import
kz.arta.synergy.api.QueryContext
;
import
kz.arta.synergy.api.RestHttpQuery
;
import
kz.arta.synergy.api.pojo.SynergyFile
;
import
kz.arta.synergy.api.services.storage.Attachment
;
import
kz.arta.synergy.api.services.storage.AttachmentList
;
import
org.codehaus.jackson.type.TypeReference
;
import
java.io.IOException
;
import
java.util.List
;
/**
* Created by: Abzal Kultayev
...
...
@@ -73,4 +76,19 @@ public class StorageService {
return
JsonUtils
.
read
(
restHttpQuery
.
doQuery
(
query
),
AttachmentList
.
class
);
}
/**
* Получит список файлов в папке
* @param parentID id родительской папки, если не передано,
* будет возвращено корневые папки
* @return список файлов
* @throws IOException
*/
public
List
<
SynergyFile
>
storageList
(
String
parentID
)
throws
IOException
{
Query
query
=
Query
.
newInstance
()
.
url
(
"/rest/api/storage/list"
);
if
(
parentID
!=
null
)
{
query
.
queryParam
(
"parentID"
,
parentID
);
}
return
JsonUtils
.
read
(
restHttpQuery
.
doQuery
(
query
),
new
TypeReference
<
List
<
SynergyFile
>>()
{});
}
}
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