ユーティリティメソッド (Java)
最終更新日: 2024年7月22日
- トピック:
- APIs/SDKs
作成対象:
- 開発者
これらのヘルパーメソッドは、コントローラ間で再利用可能で、別のユーティリティクラスに移動できます。
メソッド
public class TargetRequestUtils {
public static Context getContext(HttpServletRequest request) {
Context context = new Context()
.channel(ChannelType.WEB)
.timeOffsetInMinutes(330.0)
.address(getAddress(request));
return context;
}
public static Address getAddress(HttpServletRequest request) {
Address address = new Address()
.referringUrl(request.getHeader("referer"))
.url(request.getRequestURL().toString());
return address;
}
public static List<TargetCookie> getTargetCookies(Cookie[] cookies) {
if (cookies == null) {
return Collections.emptyList();
}
return Arrays.stream(cookies)
.filter(Objects::nonNull)
.filter(cookie -> CookieUtils.getTargetCookieNames().contains(cookie.getName()))
.map(cookie -> new TargetCookie(cookie.getName(), cookie.getValue(), cookie.getMaxAge()))
.collect(Collectors.toList());
}
public static HttpServletResponse setCookies(List<TargetCookie> targetCookies,
HttpServletResponse response) {
targetCookies
.stream()
.map(targetCookie -> new Cookie(targetCookie.getName(), targetCookie.getValue()))
.forEach(cookie -> {
cookie.setPath("/");
response.addCookie(cookie);
});
return response;
}
public static List<MboxRequest> getMboxRequests(String... name) {
List<MboxRequest> mboxRequests = new ArrayList<>();
for (int i = 0; i < name.length; i++) {
mboxRequests.add(new MboxRequest().name(name[i]).index(i));
}
return mboxRequests;
}
public static PrefetchRequest getPrefetchRequest() {
PrefetchRequest prefetchRequest = new PrefetchRequest();
ViewRequest viewRequest = new ViewRequest();
prefetchRequest.setViews(Arrays.asList(viewRequest));
return prefetchRequest;
}
}
Target
- Adobe Target開発者ガイド
- 入門
- クライアントサイド実装
- 概要:Target をクライアント側 web に実装する
- Adobe Experience Platform Web SDK 実装の概要
- at.js の実装
- at.js の概要
- at.js の仕組み
- at.js のデプロイ方法
- オンデバイス判定
- at.js 関数
- at.js 関数の概要
- adobe.target.getOffer()
- adobe.target.getOffers() - at.js 2.x
- adobe.target.applyOffer()
- adobe.target.applyOffers() - at.js 2.x
- adobe.target.triggerView() - at.js 2.x
- adobe.target.trackEvent()
- mboxCreate() - at.js 1.x
- targetGlobalSettings()
- mboxDefine() と mboxUpdate() - at.js 1.x
- targetPageParams()
- targetPageParamsAll()
- registerExtension() - at.js 1.x
- sendNotifications() - at.js 2.1
- at.js カスタムイベント
- Adobe Experience Cloud デバッガーを使用した at.js のデバッグ
- Target でのクラウドベースのインスタンスの使用
- at.js の FAQ
- at.js のバージョンの詳細
- at.js 1.x から at.js 2.x へのアップグレード
- at.js の cookie
- User-agent と client hints
- グローバル mbox について
- サーバーサイド実装
- ハイブリッド実装
- Recommendations実装
- モバイルアプリの実装
- メール実装
- の API ガイド
- 実装パターン