Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
Component Sharing
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gagandeep Singh Bhatia
Component Sharing
Commits
d2653030
Commit
d2653030
authored
May 13, 2024
by
Sonawane Amol Madhjuar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
25a6ac9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
182 additions
and
0 deletions
+182
-0
Amol/Proteus_Lib_Jar/Framework6M/DocumentViewerServiceUtility.java
...eus_Lib_Jar/Framework6M/DocumentViewerServiceUtility.java
+182
-0
No files found.
Amol/Proteus_Lib_Jar/Framework6M/DocumentViewerServiceUtility.java
0 → 100644
View file @
d2653030
package
ibase
.
webitm
.
utility
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.rmi.RemoteException
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.Statement
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.xml.parsers.DocumentBuilderFactory
;
import
ibase.system.config.ConnDriver
;
import
ibase.utility.BaseLogger
;
import
ibase.utility.UserInfoBean
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
org.json.JSONException
;
import
java.io.StringReader
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.xml.parsers.DocumentBuilder
;
import
javax.xml.parsers.ParserConfigurationException
;
import
org.xml.sax.SAXException
;
import
org.w3c.dom.Document
;
import
org.w3c.dom.Element
;
import
org.w3c.dom.Node
;
import
org.w3c.dom.NodeList
;
import
org.xml.sax.InputSource
;
public
class
DocumentViewerServiceUtility
extends
RestAPIServiceUtility
{
/*
* Params: objName refID This will contain logic to first get doc ID's against
* the objName and refID via getDocumentData's method
*
*/
public
byte
[]
getPreviewImage
(
String
objName
,
String
refId
,
String
tokenIDfromHeader
)
{
BaseLogger
.
log
(
"3"
,
null
,
null
,
" getPreviewImage method call: "
);
UserInfoBean
userInfo
=
null
;
if
(
userInfo
==
null
)
{
APIUtility
apiUtility
=
new
APIUtility
();
userInfo
=
apiUtility
.
createUserInfoFromJWTToken
(
tokenIDfromHeader
);
BaseLogger
.
log
(
"3"
,
null
,
null
,
"USER_INFO created from TOKEN: ["
+
userInfo
+
"]"
);
}
DocumentHandlerServiceUtility
documentHandlerServiceUtility
=
new
DocumentHandlerServiceUtility
();
String
responseData
=
null
;
String
refCol
=
""
;
String
dataFormat
=
"xml"
;
byte
[]
byteArray
=
null
;
try
{
responseData
=
new
String
(
documentHandlerServiceUtility
.
documentGetData
(
objName
,
refId
,
refCol
,
dataFormat
,
tokenIDfromHeader
));
BaseLogger
.
log
(
"3"
,
null
,
null
,
"responseData ==> "
+
responseData
);
List
<
String
>
docIds
=
new
ArrayList
<>();
try
{
DocumentBuilderFactory
factory
=
DocumentBuilderFactory
.
newInstance
();
DocumentBuilder
builder
=
factory
.
newDocumentBuilder
();
InputSource
is
=
new
InputSource
(
new
StringReader
(
responseData
));
Document
doc
=
builder
.
parse
(
is
);
NodeList
docIdNodes
=
doc
.
getElementsByTagName
(
"Document_Id"
);
// Extract Document_Id values
for
(
int
i
=
0
;
i
<
docIdNodes
.
getLength
();
i
++)
{
Node
docIdNode
=
docIdNodes
.
item
(
i
);
if
(
docIdNode
.
getNodeType
()
==
Node
.
ELEMENT_NODE
)
{
Element
docIdElement
=
(
Element
)
docIdNode
;
String
docId
=
docIdElement
.
getTextContent
();
docIds
.
add
(
docId
);
BaseLogger
.
log
(
"3"
,
null
,
null
,
"DocumentViewerServlet docIDs : ["
+
docIds
+
"]"
);
}
}
}
catch
(
ParserConfigurationException
|
SAXException
|
IOException
e
)
{
BaseLogger
.
log
(
"3"
,
null
,
null
,
"Error parsing XML response: "
+
e
.
getMessage
());
e
.
printStackTrace
();
}
for
(
String
docId
:
docIds
)
{
try
{
BaseLogger
.
log
(
"3"
,
null
,
null
,
"DocumentViewerServlet :: docID ["
+
docId
+
"]"
);
byteArray
=
getPreviewImageAgainstDocId
(
docId
,
userInfo
);
}
catch
(
Exception
ex
)
{
BaseLogger
.
log
(
"3"
,
null
,
null
,
"Exception in DocumentViewerServlet :: handleDocument() : "
+
ex
);
ex
.
printStackTrace
();
}
}
}
catch
(
Exception
e
)
{
BaseLogger
.
log
(
"3"
,
null
,
null
,
"Exception :: "
+
e
);
e
.
printStackTrace
();
}
return
byteArray
;
}
private
byte
[]
getPreviewImageAgainstDocId
(
String
docId
,
UserInfoBean
userInfo
)
{
BaseLogger
.
log
(
"3"
,
null
,
null
,
"getPreviewImageAgainstDocId Service Called"
);
byte
[]
byteArray
=
null
;
try
{
BaseLogger
.
log
(
"3"
,
null
,
null
,
"DocumentViewerServlet :: handleDocument() : GET_VIDEO_FRAME : docID ["
+
docId
+
"]"
);
if
(
docId
==
null
||
""
.
equals
(
docId
.
trim
()))
byteArray
=
new
byte
[]
{
0
};
else
{
byteArray
=
getVideoFrame
(
docId
,
userInfo
);
byteArray
=
(
byteArray
==
null
)
?
new
byte
[]
{
0
}
:
byteArray
;
}
}
catch
(
Exception
ex
)
{
BaseLogger
.
log
(
"3"
,
null
,
null
,
"Exception in DocumentViewerServlet :: handleDocument() : "
+
ex
);
ex
.
printStackTrace
();
}
BaseLogger
.
log
(
"3"
,
null
,
null
,
"byteArray:: "
+
byteArray
);
return
byteArray
;
}
// getPreviewImageAgainstDocId(List docId's)
private
byte
[]
getVideoFrame
(
String
docId
,
UserInfoBean
userInfo
)
{
BaseLogger
.
log
(
"3"
,
null
,
null
,
"getVideoFrame() Called"
);
Connection
conn
=
null
;
Statement
st
=
null
;
ResultSet
rs
=
null
;
InputStream
inputStream
=
null
;
byte
[]
iconByteArray
=
{
0
};
BaseLogger
.
log
(
"3"
,
null
,
null
,
" getVideoFrame method call: "
);
try
{
String
sql
=
"SELECT ICON FROM DOC_CONTENTS WHERE DOC_ID = "
+
docId
;
BaseLogger
.
log
(
"3"
,
userInfo
,
null
,
"DocumentViewerServlet :: getVideoFrame() : sql ["
+
sql
+
"]"
);
String
transDB
=
userInfo
.
getTransDB
();
conn
=
new
ConnDriver
().
getConnectDB
(
transDB
);
st
=
conn
.
createStatement
();
rs
=
st
.
executeQuery
(
sql
);
if
(
rs
.
next
())
{
inputStream
=
rs
.
getBinaryStream
(
1
);
if
(
inputStream
!=
null
)
{
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
int
i
=
0
;
while
((
i
=
inputStream
.
read
())
!=
-
1
)
byteArrayOutputStream
.
write
(
i
);
iconByteArray
=
byteArrayOutputStream
.
toByteArray
();
}
}
}
catch
(
Exception
ex
)
{
BaseLogger
.
log
(
"3"
,
userInfo
,
null
,
"Exception in DocumentViewerServlet :: getVideoFrame() : "
+
ex
);
}
finally
{
try
{
if
(
conn
!=
null
)
conn
.
close
();
if
(
st
!=
null
)
st
.
close
();
if
(
rs
!=
null
)
rs
.
close
();
}
catch
(
Exception
ex
)
{
}
}
return
iconByteArray
;
}
}
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