Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abook_check
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abook_android
abook_check
Commits
b613c708
Commit
b613c708
authored
Apr 13, 2026
by
Kang Donghun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#73114 作業同期 ContentRefresher修正
parent
56511aac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
26 deletions
+108
-26
ABVJE_BL/src/jp/agentec/abook/abv/bl/download/ContentRefresher.java
+53
-26
ABVJE_BL/src/jp/agentec/abook/abv/bl/logic/ContractLogic.java
+55
-0
No files found.
ABVJE_BL/src/jp/agentec/abook/abv/bl/download/ContentRefresher.java
View file @
b613c708
package
jp
.
agentec
.
abook
.
abv
.
bl
.
download
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
jp.agentec.abook.abv.bl.acms.client.AcmsClient
;
...
...
@@ -312,18 +316,21 @@ import jp.agentec.adf.util.DateTimeUtil;
// sppDeviceDtoを登録
List
<
SppDeviceDto
>
sppDeviceDtoList
=
json
.
sppDeviceDtoList
;
if
(
CollectionUtil
.
isNotEmpty
(
sppDeviceDtoList
))
{
// ローカルに保存されてるID
リストを取得(登録・更新の判定のため
)
// ローカルに保存されてるID
(contains/remove を O(1) に
)
List
<
Integer
>
localSppDeviceIdList
=
sppDeviceDao
.
getSppDeviceIdList
();
Set
<
Integer
>
localSppDeviceIds
=
new
HashSet
<
Integer
>();
if
(
CollectionUtil
.
isNotEmpty
(
localSppDeviceIdList
))
{
localSppDeviceIds
.
addAll
(
localSppDeviceIdList
);
}
for
(
SppDeviceDto
sppDeviceDto
:
sppDeviceDtoList
)
{
if
(
CollectionUtil
.
isNotEmpty
(
localSppDeviceIdList
)
&&
localSppDeviceIdList
.
contains
(
sppDeviceDto
.
sppDeviceId
))
{
if
(
localSppDeviceIds
.
contains
(
sppDeviceDto
.
sppDeviceId
))
{
SppDeviceDto
localSppDevice
=
sppDeviceDao
.
getSppDeviceById
(
sppDeviceDto
.
sppDeviceId
);
// ペアリング情報だけローカルから取得して、更新する
sppDeviceDto
.
pairingDeviceName
=
localSppDevice
.
pairingDeviceName
;
sppDeviceDto
.
pairingDeviceAddress
=
localSppDevice
.
pairingDeviceAddress
;
sppDeviceDao
.
updateSppDevice
(
sppDeviceDto
);
// 削除のため、更新したら該当するIDを削除する
localSppDeviceIdList
.
remove
(
localSppDeviceIdList
.
indexOf
(
sppDeviceDto
.
sppDeviceId
));
localSppDeviceIds
.
remove
(
sppDeviceDto
.
sppDeviceId
);
}
else
{
// 取得したSPP通信端末のデータベースへ登録
sppDeviceDao
.
insert
(
sppDeviceDto
);
...
...
@@ -331,15 +338,25 @@ import jp.agentec.adf.util.DateTimeUtil;
}
// ローカル情報削除(サーバーと端末データの差分)
if
(
CollectionUtil
.
isNotEmpty
(
localSppDeviceIdList
))
{
for
(
Integer
deleteSppDeviceId
:
localSppDeviceIdList
)
{
sppDeviceDao
.
deleteById
(
deleteSppDeviceId
);
}
for
(
Integer
deleteSppDeviceId
:
localSppDeviceIds
)
{
sppDeviceDao
.
deleteById
(
deleteSppDeviceId
);
}
}
List
<
ContentDto
>
serverContents
=
json
.
contentVersions
;
// DTO Info:contentId, metaVersion, resourceVersion, contentNameKana, readerShareFlg
// AbstractDto#equals は getKeyValues()(ContentDto は contentId のみ)のため、従来の indexOf(serverDto) は contentId 一致と同値。
// indexOf は先頭一致を採用するため、同一 contentId が複数ある場合も先頭のみマップへ入れる。残りリストの順序は元リストの部分列として再現する。
ArrayList
<
ContentDto
>
localContentsInitialOrder
=
null
;
HashMap
<
Long
,
ContentDto
>
localByContentId
=
new
HashMap
<
Long
,
ContentDto
>();
if
(
localContents
!=
null
)
{
localContentsInitialOrder
=
new
ArrayList
<
ContentDto
>(
localContents
);
for
(
ContentDto
c
:
localContentsInitialOrder
)
{
if
(!
localByContentId
.
containsKey
(
c
.
contentId
))
{
localByContentId
.
put
(
c
.
contentId
,
c
);
}
}
}
for
(
ContentDto
serverContentDto
:
serverContents
)
{
while
(
isBusyRefreshingContent
())
{
...
...
@@ -357,9 +374,8 @@ import jp.agentec.adf.util.DateTimeUtil;
}
if
(
localContents
!=
null
)
{
int
localContentIndex
=
localContents
.
indexOf
(
serverContentDto
);
if
(
localContentIndex
>=
0
)
{
ContentDto
localDto
=
localContents
.
get
(
localContentIndex
);
ContentDto
localDto
=
localByContentId
.
remove
(
serverContentDto
.
contentId
);
if
(
localDto
!=
null
)
{
if
(!
serverContentDto
.
equalsVersion
(
localDto
))
{
// 更新 ContentInfo.zipをダウンロードする。
contentDownloader
.
downloadContentInfo
(
serverContentDto
.
contentId
);
if
(
serverContentDto
.
isLinkType
()
&&
localDto
.
isDownloadable
(
true
))
{
...
...
@@ -369,8 +385,6 @@ import jp.agentec.adf.util.DateTimeUtil;
else
if
(!
localDto
.
downloadedFlg
&&
serverContentDto
.
isLinkType
()
&&
localDto
.
isDownloadable
(
true
))
{
// ダウンロード未完了も追加
contentDownloader
.
addAutoDownload
(
serverContentDto
.
contentId
);
}
localContents
.
remove
(
localDto
);
// 既に存在するコンテンツはローカルのリストからはずしておく。
}
else
{
// 新規 ContentInfo.zipをダウンロードする。
contentDownloader
.
downloadContentInfo
(
serverContentDto
.
contentId
);
...
...
@@ -380,6 +394,19 @@ import jp.agentec.adf.util.DateTimeUtil;
}
}
}
if
(
localContents
!=
null
&&
localContentsInitialOrder
!=
null
)
{
localContents
.
clear
();
for
(
ContentDto
c
:
localContentsInitialOrder
)
{
Long
id
=
c
.
contentId
;
if
(
localByContentId
.
containsKey
(
id
))
{
ContentDto
still
=
localByContentId
.
get
(
id
);
if
(
still
==
c
)
{
localContents
.
add
(
c
);
localByContentId
.
remove
(
id
);
}
}
}
}
return
true
;
}
}
...
...
@@ -464,20 +491,20 @@ import jp.agentec.adf.util.DateTimeUtil;
}
try
{
List
<
ContentDto
>
list
=
contentDao
.
getSendLog
();
if
(
list
==
null
||
list
.
size
()
==
0
)
{
return
;
}
AcmsClient
acms
=
AcmsClient
.
getInstance
(
cache
.
getUrlPath
(),
ABVEnvironment
.
getInstance
().
networkAdapter
);
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
for
(
ContentDto
dto
:
list
)
{
// FIXME: Readerがここに来るかどうか
ContentDownloadLogParameters
downloadParam
=
new
ContentDownloadLogParameters
(
cache
.
getMemberInfo
().
sid
,
dto
.
contentId
,
DateTimeUtil
.
dateToTimestamp
(
dto
.
downloadStartDate
)
,
dto
.
resourceVersion
,
ABVEnvironment
.
DeviceTypeId
,
dto
.
getDownloadStatus
());
downloadParam
.
setDownloadSize
(
dto
.
downloadedBytes
);
downloadParam
.
setDownloadEndtime
(
DateTimeUtil
.
dateToTimestamp
(
dto
.
downloadEndDate
));
if
(
acms
.
contentDownloadLog
(
downloadParam
))
{
dto
.
logSendedFlg
=
true
;
contentDao
.
updateLogSendFlg
(
dto
);
}
for
(
ContentDto
dto
:
list
)
{
// FIXME: Readerがここに来るかどうか
ContentDownloadLogParameters
downloadParam
=
new
ContentDownloadLogParameters
(
cache
.
getMemberInfo
().
sid
,
dto
.
contentId
,
DateTimeUtil
.
dateToTimestamp
(
dto
.
downloadStartDate
)
,
dto
.
resourceVersion
,
ABVEnvironment
.
DeviceTypeId
,
dto
.
getDownloadStatus
());
downloadParam
.
setDownloadSize
(
dto
.
downloadedBytes
);
downloadParam
.
setDownloadEndtime
(
DateTimeUtil
.
dateToTimestamp
(
dto
.
downloadEndDate
));
if
(
acms
.
contentDownloadLog
(
downloadParam
))
{
dto
.
logSendedFlg
=
true
;
contentDao
.
updateLogSendFlg
(
dto
);
}
}
}
catch
(
Exception
e
)
{
...
...
ABVJE_BL/src/jp/agentec/abook/abv/bl/logic/ContractLogic.java
View file @
b613c708
package
jp
.
agentec
.
abook
.
abv
.
bl
.
logic
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
jp.agentec.abook.abv.bl.acms.client.AcmsClient
;
...
...
@@ -51,6 +54,10 @@ public class ContractLogic extends AbstractLogic {
List
<
ServiceOptionDto
>
list
=
AcmsClient
.
getInstance
(
cache
.
getUrlPath
(),
networkAdapter
).
serviceOption
(
param
);
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
if
(
isSameServiceOptionListAsDb
(
list
))
{
Logger
.
d
(
TAG
,
"service options unchanged, skip delete/insert"
);
return
;
}
try
{
serviceOptionDao
.
beginTransaction
();
...
...
@@ -68,6 +75,54 @@ public class ContractLogic extends AbstractLogic {
}
/**
* サーバ取得のサービスオプションとローカルDBの内容が同一なら、削除・再挿入を省略する。
*/
private
boolean
isSameServiceOptionListAsDb
(
List
<
ServiceOptionDto
>
serverList
)
{
List
<
ServiceOptionDto
>
localList
=
serviceOptionDao
.
getServiceOptions
();
if
(
localList
==
null
||
localList
.
size
()
!=
serverList
.
size
())
{
return
false
;
}
ArrayList
<
ServiceOptionDto
>
s
=
new
ArrayList
<
ServiceOptionDto
>(
serverList
);
ArrayList
<
ServiceOptionDto
>
l
=
new
ArrayList
<
ServiceOptionDto
>(
localList
);
Comparator
<
ServiceOptionDto
>
byId
=
new
Comparator
<
ServiceOptionDto
>()
{
@Override
public
int
compare
(
ServiceOptionDto
a
,
ServiceOptionDto
b
)
{
return
Integer
.
valueOf
(
a
.
serviceOptionId
).
compareTo
(
b
.
serviceOptionId
);
}
};
Collections
.
sort
(
s
,
byId
);
Collections
.
sort
(
l
,
byId
);
for
(
int
i
=
0
;
i
<
s
.
size
();
i
++)
{
if
(!
serviceOptionRowEquals
(
s
.
get
(
i
),
l
.
get
(
i
)))
{
return
false
;
}
}
return
true
;
}
private
static
boolean
serviceOptionRowEquals
(
ServiceOptionDto
a
,
ServiceOptionDto
b
)
{
if
(
a
.
serviceOptionId
!=
b
.
serviceOptionId
)
{
return
false
;
}
if
(!
safeStrEq
(
a
.
val
,
b
.
val
))
{
return
false
;
}
if
(!
safeStrEq
(
a
.
serviceOptionName
,
b
.
serviceOptionName
))
{
return
false
;
}
if
(!
safeStrEq
(
a
.
serviceOptionDispName
,
b
.
serviceOptionDispName
))
{
return
false
;
}
return
true
;
}
private
static
boolean
safeStrEq
(
String
x
,
String
y
)
{
String
xs
=
x
==
null
?
""
:
x
;
String
ys
=
y
==
null
?
""
:
y
;
return
xs
.
equals
(
ys
);
}
/**
* 権限喪失,非公開,削除時のDL済コンテンツ強制削除するかどうかを示します。
* @return 権限喪失,非公開,削除時のDL済コンテンツ強制削除する場合、trueを返します。
* @since 1.0.0
...
...
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