Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
Import registry records
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
develop
Import registry records
Commits
9032954f
Commit
9032954f
authored
Sep 23, 2019
by
Alina Habibulina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[
#1
] Version 1
parent
84852be4
Pipeline
#183
failed with stages
Changes
9
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
56 additions
and
47 deletions
+56
-47
build.gradle
build.gradle
+12
-10
settings.gradle
settings.gradle
+1
-1
src/main/java/kz/arta/ext/sap/service/Activator.java
src/main/java/kz/arta/ext/sap/service/Activator.java
+1
-1
src/main/java/kz/arta/ext/sap/service/SecurityInterceptor.java
...ain/java/kz/arta/ext/sap/service/SecurityInterceptor.java
+3
-2
src/main/java/kz/arta/ext/sap/util/DateFormat.java
src/main/java/kz/arta/ext/sap/util/DateFormat.java
+0
-3
src/main/java/kz/arta/ext/sap/util/HTTPRequestUtils.java
src/main/java/kz/arta/ext/sap/util/HTTPRequestUtils.java
+23
-15
src/main/java/kz/arta/ext/sap/util/ImportBean.java
src/main/java/kz/arta/ext/sap/util/ImportBean.java
+11
-12
src/main/webapp/WEB-INF/jboss-all.xml
src/main/webapp/WEB-INF/jboss-all.xml
+5
-0
src/main/webapp/WEB-INF/jboss-web.xml
src/main/webapp/WEB-INF/jboss-web.xml
+0
-3
No files found.
build.gradle
View file @
9032954f
apply
plugin:
'war'
apply
plugin:
'war'
sourceCompatibility
=
1.7
sourceCompatibility
=
1.8
version
=
'1.0'
task
wrapper
(
type:
Wrapper
)
{
task
wrapper
(
type:
Wrapper
)
{
gradleVersion
=
'4.6'
gradleVersion
=
'4.6'
...
@@ -13,21 +12,24 @@ repositories {
...
@@ -13,21 +12,24 @@ repositories {
}
}
dependencies
{
dependencies
{
providedCompile
(
group:
'org.slf4j'
,
name:
'slf4j-api'
,
version:
'1.6.1'
,
transitive:
false
)
providedCompile
(
group:
'org.codehaus.jackson'
,
name:
'jackson-core-asl'
,
version:
'1.9.2
'
,
transitive:
false
)
compile
(
group:
'org.slf4j'
,
name:
'slf4j-api'
,
version:
'1.7.25
'
,
transitive:
false
)
providedCompile
(
group:
'org.codehaus.jackson'
,
name:
'jackson-mapper-asl'
,
version:
'1.9.2'
,
transitive:
false
)
compile
'org.apache.httpcomponents:httpclient:4.5.1'
compile
'org.apache.httpcomponents:httpclient:4.5.1'
providedCompile
(
group:
'org.jboss.resteasy'
,
name:
'resteasy-jaxrs'
,
version:
'2.3.3.Final'
,
transitive:
false
)
compile
group:
'org.jboss.resteasy'
,
name:
'resteasy-jaxrs'
,
version:
'3.8.0.Final'
// https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-multipart-provider
// https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-multipart-provider
compile
group:
'org.jboss.resteasy'
,
name:
'resteasy-multipart-provider'
,
version:
'
2.3.3
.Final'
compile
group:
'org.jboss.resteasy'
,
name:
'resteasy-multipart-provider'
,
version:
'
3.8.0
.Final'
// https://mvnrepository.com/artifact/commons-io/commons-io
// https://mvnrepository.com/artifact/commons-io/commons-io
compile
group:
'commons-io'
,
name:
'commons-io'
,
version:
'2.6'
compile
group:
'commons-io'
,
name:
'commons-io'
,
version:
'2.6'
providedCompile
'org.jboss.spec:jboss-javaee-6.0:3.0.3.Final'
compile
(
'org.jboss.spec:jboss-javaee-7.0:1.1.1.Final'
)
// https://mvnrepository.com/artifact/org.apache.poi/poi
// https://mvnrepository.com/artifact/org.apache.poi/poi
providedCompile
group:
'org.jboss.spec.javax.ejb'
,
name:
'jboss-ejb-api_3.2_spec'
,
version:
'1.0.
1
.Final'
providedCompile
group:
'org.jboss.spec.javax.ejb'
,
name:
'jboss-ejb-api_3.2_spec'
,
version:
'1.0.
2
.Final'
compile
group:
'org.apache.poi'
,
name:
'poi'
,
version:
'3.9'
compile
group:
'org.apache.poi'
,
name:
'poi'
,
version:
'3.9'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
// https://mvnrepository.com/artifact/com.google.code.gson/gson
compile
group:
'com.google.code.gson'
,
name:
'gson'
,
version:
'2.7'
compile
group:
'com.google.code.gson'
,
name:
'gson'
,
version:
'2.7'
// https://mvnrepository.com/artifact/joda-time/joda-time
// https://mvnrepository.com/artifact/joda-time/joda-time
compile
group:
'joda-time'
,
name:
'joda-time'
,
version:
'2.3'
compile
group:
'joda-time'
,
name:
'joda-time'
,
version:
'2.10.3'
// https://mvnrepository.com/artifact/org.json/json
compile
group:
'org.json'
,
name:
'json'
,
version:
'20180813'
}
}
\ No newline at end of file
settings.gradle
View file @
9032954f
rootProject
.
name
=
'
registry-
import'
rootProject
.
name
=
'import'
src/main/java/kz/arta/ext/sap/service/Activator.java
View file @
9032954f
...
@@ -3,6 +3,6 @@ package kz.arta.ext.sap.service;
...
@@ -3,6 +3,6 @@ package kz.arta.ext.sap.service;
import
javax.ws.rs.ApplicationPath
;
import
javax.ws.rs.ApplicationPath
;
import
javax.ws.rs.core.Application
;
import
javax.ws.rs.core.Application
;
@ApplicationPath
(
"
import
"
)
@ApplicationPath
(
"
api
"
)
public
class
Activator
extends
Application
{
public
class
Activator
extends
Application
{
}
}
src/main/java/kz/arta/ext/sap/service/SecurityInterceptor.java
View file @
9032954f
...
@@ -3,7 +3,7 @@ package kz.arta.ext.sap.service;
...
@@ -3,7 +3,7 @@ package kz.arta.ext.sap.service;
import
org.jboss.resteasy.annotations.interception.Precedence
;
import
org.jboss.resteasy.annotations.interception.Precedence
;
import
org.jboss.resteasy.annotations.interception.ServerInterceptor
;
import
org.jboss.resteasy.annotations.interception.ServerInterceptor
;
import
org.jboss.resteasy.core.Headers
;
import
org.jboss.resteasy.core.Headers
;
import
org.jboss.resteasy.core.ResourceMethod
;
import
org.jboss.resteasy.core.ResourceMethod
Invoker
;
import
org.jboss.resteasy.core.ServerResponse
;
import
org.jboss.resteasy.core.ServerResponse
;
import
org.jboss.resteasy.spi.Failure
;
import
org.jboss.resteasy.spi.Failure
;
import
org.jboss.resteasy.spi.HttpRequest
;
import
org.jboss.resteasy.spi.HttpRequest
;
...
@@ -32,8 +32,9 @@ public class SecurityInterceptor implements PreProcessInterceptor {
...
@@ -32,8 +32,9 @@ public class SecurityInterceptor implements PreProcessInterceptor {
@Context
@Context
HttpServletResponse
response
;
HttpServletResponse
response
;
@Override
@Override
public
ServerResponse
preProcess
(
HttpRequest
httpRequest
,
ResourceMethod
resourceM
ethod
)
throws
Failure
,
WebApplicationException
{
public
ServerResponse
preProcess
(
HttpRequest
request
,
ResourceMethodInvoker
m
ethod
)
throws
Failure
,
WebApplicationException
{
return
null
;
return
null
;
}
}
}
}
src/main/java/kz/arta/ext/sap/util/DateFormat.java
View file @
9032954f
package
kz.arta.ext.sap.util
;
package
kz.arta.ext.sap.util
;
import
org.apache.http.annotation.ThreadSafe
;
import
java.util.Date
;
import
java.util.Date
;
@ThreadSafe
public
interface
DateFormat
{
public
interface
DateFormat
{
Date
parse
(
String
text
)
throws
Exception
;
Date
parse
(
String
text
)
throws
Exception
;
Date
parseStrict
(
String
text
)
throws
Exception
;
Date
parseStrict
(
String
text
)
throws
Exception
;
...
...
src/main/java/kz/arta/ext/sap/util/HTTPRequestUtils.java
View file @
9032954f
package
kz.arta.ext.sap.util
;
package
kz.arta.ext.sap.util
;
import
com.sun.org.apache.xerces.internal.impl.dv.util.Base64
;
import
com.sun.org.apache.xerces.internal.impl.dv.util.Base64
;
import
org.apache.commons.httpclient.UsernamePasswordCredentials
;
import
org.apache.commons.httpclient.methods.PostMethod
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.impl.client.DefaultHttpClient
;
import
org.apache.http.impl.client.DefaultHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
javax.ejb.TransactionAttribute
;
import
javax.ejb.TransactionAttribute
;
import
javax.ejb.TransactionAttributeType
;
import
javax.ejb.TransactionAttributeType
;
...
@@ -46,21 +44,31 @@ public class HTTPRequestUtils {
...
@@ -46,21 +44,31 @@ public class HTTPRequestUtils {
@TransactionAttribute
(
TransactionAttributeType
.
REQUIRES_NEW
)
@TransactionAttribute
(
TransactionAttributeType
.
REQUIRES_NEW
)
public
static
String
sendPost
(
String
url
,
String
json
,
String
login
,
String
password
)
throws
Exception
{
public
static
String
sendPost
(
String
url
,
String
json
,
String
login
,
String
password
)
throws
Exception
{
HttpClient
client
=
new
DefaultHttpClient
();
HttpPost
request
=
new
HttpPost
(
url
);
PostMethod
postMethod
=
new
PostMethod
(
url
);
String
usernameColonPassword
=
login
+
":"
+
password
;
org
.
apache
.
commons
.
httpclient
.
HttpClient
client
=
new
org
.
apache
.
commons
.
httpclient
.
HttpClient
();
String
basicAuthPayload
=
"Basic "
+
Base64
.
encode
(
usernameColonPassword
.
getBytes
(
"UTF-8"
));
UsernamePasswordCredentials
creds
=
new
UsernamePasswordCredentials
(
login
,
password
);
request
.
addHeader
(
"Authorization"
,
basicAuthPayload
);
client
.
getParams
().
setAuthenticationPreemptive
(
true
);
client
.
getState
().
setCredentials
(
org
.
apache
.
commons
.
httpclient
.
auth
.
AuthScope
.
ANY
,
creds
);
postMethod
.
setRequestHeader
(
"Content-type"
,
"application/json; charset=utf-8"
);
postMethod
.
setRequestBody
(
json
);
client
.
executeMethod
(
postMethod
);
String
answer
=
postMethod
.
getResponseBodyAsString
();
postMethod
.
releaseConnection
();
return
answer
;
request
.
setHeader
(
"Content-type"
,
"application/json; charset=utf-8"
);
StringEntity
entity
=
new
StringEntity
(
json
);
request
.
setEntity
(
entity
);
client
.
execute
(
request
);
HttpResponse
response
=
client
.
execute
(
request
);
BufferedReader
rd
=
new
BufferedReader
(
new
InputStreamReader
(
response
.
getEntity
().
getContent
()));
StringBuffer
result
=
new
StringBuffer
();
String
line
=
""
;
while
((
line
=
rd
.
readLine
())
!=
null
)
{
result
.
append
(
line
);
}
}
return
result
.
toString
();
}
}
}
src/main/java/kz/arta/ext/sap/util/ImportBean.java
View file @
9032954f
...
@@ -3,6 +3,7 @@ package kz.arta.ext.sap.util;
...
@@ -3,6 +3,7 @@ package kz.arta.ext.sap.util;
import
com.google.gson.*
;
import
com.google.gson.*
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.ss.usermodel.*
;
import
org.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -115,24 +116,22 @@ public class ImportBean {
...
@@ -115,24 +116,22 @@ public class ImportBean {
//добавляем поля в json
//добавляем поля в json
//ПОКА ЧТО Я НЕ РЕАЛИЗОВАЛА ИХ ПАРСИНГ И ФОРМАТИРОВАНИЕ
//ПОКА ЧТО Я НЕ РЕАЛИЗОВАЛА ИХ ПАРСИНГ И ФОРМАТИРОВАНИЕ
jsonData
+=
"{ \"id\": \""
+
ff
.
getCode
()
+
"\", \"type\": \""
+
ff
.
getType
()
+
"\""
;
jsonData
+=
"{ \"id\": "
+
JSONObject
.
quote
(
ff
.
getCode
())
+
", \"type\": "
+
JSONObject
.
quote
(
ff
.
getType
());
//jsonData += "{ \"id\": \"" + ff.getCode() + "\", \"type\": \"" + ff.getType() + "\", \"value\": \"" + ff.getValue() + "\"";
//если это словарь и не чек бокс, нужно просто задать ему значение key
//если это словарь и не чек бокс, нужно просто задать ему значение key
if
(
ff
.
getType
().
equals
(
FormFieldType
.
LISTBOX
.
value
)){
if
(
ff
.
getType
().
equals
(
FormFieldType
.
LISTBOX
.
value
)){
jsonData
+=
", \"key\":
\""
+
ff
.
getKey
()
+
"\", \"value\": \""
+
ff
.
getValue
()
+
"\""
;
jsonData
+=
", \"key\":
"
+
JSONObject
.
quote
(
ff
.
getKey
())
+
", \"value\": "
+
JSONObject
.
quote
(
ff
.
getValue
())
;
}
else
if
(
ff
.
getType
().
equals
(
FormFieldType
.
RADIO
.
value
)){
}
else
if
(
ff
.
getType
().
equals
(
FormFieldType
.
RADIO
.
value
)){
jsonData
+=
", \"key\":
\""
+
ff
.
getValue
()
+
"\", \"value\": \""
+
ff
.
getKey
()
+
"\""
;
jsonData
+=
", \"key\":
"
+
JSONObject
.
quote
(
ff
.
getValue
())
+
", \"value\": "
+
JSONObject
.
quote
(
ff
.
getKey
())
;
}
else
if
(
ff
.
getType
().
equals
(
FormFieldType
.
CHECKBOX
.
value
)){
}
else
if
(
ff
.
getType
().
equals
(
FormFieldType
.
CHECKBOX
.
value
)){
jsonData
+=
", \"values\": ["
;
jsonData
+=
", \"values\": ["
;
for
(
String
key
:
ff
.
getKeys
()){
for
(
String
key
:
ff
.
getKeys
()){
jsonData
+=
"\""
+
key
+
"\""
;
jsonData
+=
JSONObject
.
quote
(
key
)
;
if
(
key
!=
ff
.
getKeys
().
get
(
ff
.
getKeys
().
size
()
-
1
)){
if
(
key
!=
ff
.
getKeys
().
get
(
ff
.
getKeys
().
size
()
-
1
)){
jsonData
+=
", "
;
jsonData
+=
", "
;
...
@@ -141,7 +140,7 @@ public class ImportBean {
...
@@ -141,7 +140,7 @@ public class ImportBean {
jsonData
+=
"], \"keys\": ["
;
jsonData
+=
"], \"keys\": ["
;
for
(
String
val
:
ff
.
getValues
()){
for
(
String
val
:
ff
.
getValues
()){
jsonData
+=
"\""
+
val
+
"\""
;
jsonData
+=
JSONObject
.
quote
(
val
)
;
if
(
val
!=
ff
.
getValues
().
get
(
ff
.
getValues
().
size
()
-
1
)){
if
(
val
!=
ff
.
getValues
().
get
(
ff
.
getValues
().
size
()
-
1
)){
jsonData
+=
", "
;
jsonData
+=
", "
;
...
@@ -153,27 +152,27 @@ public class ImportBean {
...
@@ -153,27 +152,27 @@ public class ImportBean {
}
else
if
(
ff
.
getType
().
equals
(
FormFieldType
.
NUMERICINPUT
.
value
)){
}
else
if
(
ff
.
getType
().
equals
(
FormFieldType
.
NUMERICINPUT
.
value
)){
jsonData
+=
", \"key\":
\""
+
ff
.
getValue
()
+
"\", \"value\": \""
+
ff
.
getValue
()
+
"\""
;
jsonData
+=
", \"key\":
"
+
JSONObject
.
quote
(
ff
.
getValue
())
+
", \"value\": "
+
JSONObject
.
quote
(
ff
.
getValue
())
;
}
else
if
(
ff
.
getType
().
equals
(
FormFieldType
.
REGLINK
.
value
)){
}
else
if
(
ff
.
getType
().
equals
(
FormFieldType
.
REGLINK
.
value
)){
if
(
ff
.
getKey
()
!=
null
)
{
if
(
ff
.
getKey
()
!=
null
)
{
jsonData
+=
", \"key\":
\""
+
ff
.
getKey
()
+
"\", \"value\": \""
+
ff
.
getValue
()
+
"\", \"valueID\": \""
+
ff
.
getKey
()
+
"\""
;
jsonData
+=
", \"key\":
"
+
JSONObject
.
quote
(
ff
.
getKey
())
+
", \"value\": "
+
JSONObject
.
quote
(
ff
.
getValue
())
+
", \"valueID\": "
+
JSONObject
.
quote
(
ff
.
getKey
())
;
}
}
}
else
if
(
ff
.
getType
().
equals
(
FormFieldType
.
ENTITY
.
value
)){
}
else
if
(
ff
.
getType
().
equals
(
FormFieldType
.
ENTITY
.
value
)){
jsonData
+=
", \"value\":
\""
+
ff
.
getValue
()
+
"\""
;
jsonData
+=
", \"value\":
"
+
JSONObject
.
quote
(
ff
.
getValue
())
;
}
else
if
(
ff
.
getType
().
equals
(
FormFieldType
.
DATE
.
value
)){
}
else
if
(
ff
.
getType
().
equals
(
FormFieldType
.
DATE
.
value
)){
String
value
=
formatDate
(
ff
.
getDateFormat
(),
ff
.
getKey
());
String
value
=
formatDate
(
ff
.
getDateFormat
(),
ff
.
getKey
());
jsonData
+=
", \"key\":
\""
+
ff
.
getKey
()
+
"\", \"value\": \""
+
value
+
"\""
;
jsonData
+=
", \"key\":
"
+
JSONObject
.
quote
(
ff
.
getKey
())
+
", \"value\": "
+
JSONObject
.
quote
(
value
)
;
}
else
{
//если текстовое поле
}
else
{
//если текстовое поле
jsonData
+=
", \"value\":
\""
+
ff
.
getValue
()
+
"\""
;
jsonData
+=
", \"value\":
"
+
JSONObject
.
quote
(
ff
.
getValue
())
;
}
}
...
...
src/main/webapp/WEB-INF/jboss-all.xml
0 → 100644
View file @
9032954f
<jboss
umlns=
"urn:jboss:1.0"
>
<jboss-deployment-dependencies
xmlns=
"urn:jboss:deployment-dependencies:1.0"
>
<dependency
name=
"Synergy.ear"
/>
</jboss-deployment-dependencies>
</jboss>
\ No newline at end of file
src/main/webapp/WEB-INF/jboss-web.xml
deleted
100644 → 0
View file @
84852be4
<jboss-web>
<context-root>
import
</context-root>
</jboss-web>
\ 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