intra-mart Accel Platform — Office 365 連携プログラミングガイド   初版  

Similar documents
intra-mart Accel Platform — Office 365 連携プログラミングガイド   第2版   None

intra-mart Accel Platform — Office 365 連携プログラミングガイド   第3版  

intra-mart Accel Platform — イベントナビゲータ 開発ガイド   初版   None

intra-mart Accel Platform — OAuth認証モジュール 仕様書   初版  

intra-mart Accel Platform — イベントナビゲータ 開発ガイド   初版  

intra-mart Accel Platform

intra-mart Accel Platform — IM-Repository拡張プログラミングガイド   初版  

intra-mart Accel Platform — 外部ソフトウェア接続モジュール 仕様書   第3版  

intra-mart Accel Platform — IM-BloomMaker プログラミングガイド   初版  

intra-mart Accel Platform — OData for SAP HANA セットアップガイド   初版  

intra-mart Accel Collaboration — Collaboration共通 ユーザ操作ガイド   第7版  

intra-mart Accel Platform

intra-mart Accel Collaboration — ファイルライブラリ ユーザ操作ガイド   第3版  

— intra-mart Accel Platform セットアップガイド (WebSphere編)   第7版  

intra-mart Accel Platform — Slack連携モジュール 利用ガイド   初版  

intra-mart Accel Platform

IM-PDFDirectPrint for Accel Platform — プログラミングガイド   第5版  

intra-mart Accel Collaboration — ファイルライブラリ ユーザ操作ガイド   第5版  

はじめに インフォマート API の呼び出しには OAuth2.0 による認証を受ける必要があります OAuth2.0 を使うことで インフォマート API を利用するサービスは インフォマートプラットフォーム ID( 1 以下 PFID) とパスワードを保存したり処理したりすることなく PFID

intra-mart Accel Collaboration — アンケート 管理者操作ガイド   第2版  

intra-mart Accel Platform — IM-共通マスタ スマートフォン拡張プログラミングガイド   初版  

IM-PDFDirectPrint for Accel Platform — プログラミングガイド   第2版  

IM-BIS for Accel Platform — Office365 for IM-BIS 連携ガイド   第2版  

intra-mart Accel Platform — IM-FileExchange 管理者操作ガイド   第3版  

intra-mart Accel Collaboration — ファイルライブラリ 管理者操作ガイド   第6版  

前ページからの続き // テキストボックス02 id 属性で取得 // id 属性で取得する場合は一意に決まるので 何番目かの指定は不要 var textbox02elem = document.getelementbyid("text_box02_id"); if ("001" == statee

intra-mart Accel Platform — 招待機能プログラミングガイド   初版  

WebOTXマニュアル

intra-mart Accel Platform — OData 連携チュートリアルガイド   初版  

IM-PDFTimeStamper for Accel Platform — プログラミングガイド   第3版  

— OpenRulesモジュール 2017 Summer リリースノート   第2版  

IM-FormatCreator

intra-mart Accel Platform — intra-mart Sphinxドキュメント ビルド手順書   第2版  

intra-mart WebPlatform/AppFramework

<td width=99%><input type="file" size="80" name="file"></td> <td width=1% nowrap align=right valign=top> 削除キー : </td> <td width=99%><input type="passw

モバイルアプリを Azure で作る - データを扱う Azure Storage を利 してデータを保存する 本稿では PHP と Windows Azure を使って 画像などのファイルを扱うアプリケーションを開発する方法を説明します Windows Azure Platform では データの

intra-mart 販売管理パッケージ

intra-mart Accel Platform — アクセスコンテキスト 拡張プログラミングガイド   第2版  

intra-mart Accel Documents

intra-mart Accel Platform — PCとスマートフォンの機能差異   初版  

intra-mart Accel Platform — 外部ソフトウェア接続モジュール 仕様書   第2版  

intra-mart Accel Platform — PCとスマートフォンの機能差異   初版  

AJAXを使用した高い対話性を誇るポートレットの構築

intra-mart Accel Platform

intra-mart ワークフローデザイナ

PowerPoint プレゼンテーション

Office 365監査ログ連携機能アクティブ化手順書

— OpenRulesモジュール 2017 Summer リリースノート   初版  

intra-mart Accel Platform — 標準テーマカスタマイズ 操作ガイド   第4版  

SmartBrowser_document_build30_update.pptx

intra-mart マスカット連携ガイド

IM-PDFCoordinator for Accel Platform — プログラミングガイド   第5版  

FW ファイルアップロード ダウンロード機能利用ガイド Version 年 9 月 21 日富士通株式会社 i All Right Reserved, Copyright FUJITSU LIMITED

intra-mart Accel Platform — ViewCreator ユーザ操作ガイド   第6版  

OSSTechプレゼンテーション

intra-mart WebPlatform/AppFramework

intra-mart Accel Platform — PCとスマートフォンの機能差異   第5版  

OpenRulesモジュール

intra-mart Accel Collaboration — インフォメーション ユーザ操作ガイド   第11版  

IM-PDFCoordinator for Accel Platform

intra-mart WebPlatform/AppFramework

目次 1. 画面構成 2. ライセンス登録 3. インストール 4. バックアップ方法 5. バッチバックアップ方法 6. 終了方法 7. アンインストール 8. 注意事項 2

V-CUBE One

intra-mart Accel Platform — 標準テーマカスタマイズ 操作ガイド   第3版  

ArcGIS for Server での Web マップの作成方法

OpenRulesモジュール

スライド タイトルなし

TestDesign for Web

PowerPoint プレゼンテーション

ドコモメール連携アプリ開発ガイド(新IF対応)

intra-mart Accel Platform — TableMaintenance ユーザ操作ガイド   第7版   None

Microsoft Word - PHP演習資料.doc

— IM-VisualDesigner Migration Tool 2017 Spring リリースノート   初版  

intra-mart WebPlaform / AppFramework

POWER EGG 3.0 Office365連携

CodeIgniter Con 2011, Tokyo Japan, February

Java (9) 1 Lesson Java System.out.println() 1 Java API 1 Java Java 1

--- サーバ側処理 Java servlet の例 // 通常の Java servlet での POST で受信と同じ protected void dopost(httpservletrequest request, HttpServletResponse response) throws S

SeciossLink クイックスタートガイド

Webプログラミング演習

目次 1. 画面構成 2. ライセンス登録 3. インストール 4. バックアップ方法 5. バッチバックアップ方法 6. 終了方法 7. アンインストール 8. 注意事項 2

Android Layout SDK プログラミング マニュアル

intra-mart im-JavaEE Framework

C:\Apache Software Foundation\Apache2.2\htdocs\sample\login.html サンプルプログラム passworddisc.php <head><title> ログイン </title></head> $user=$_post['user']; $

1 ユーザ認証を受けた権限で アプリケーションを利用するために ログインプロキシにアクセスします 2 ログインプロキシにより Shibboleth SP から Shibboleth IdP の認証画面にリダイレクトされます 3 ブラウザに認証画面を表示します 4 認証画面にユーザ / パスワードを入

intra-mart Accel Platform — TableMaintenance ユーザ操作ガイド   第8版  

untitled

Microsoft Word - W3C's_ARIA_Support

Javaセキュアコーディングセミナー東京 第3回 入出力(File, Stream)と例外時の動作 演習解説

ALG ppt

IOWebDOC

untitled

Oracle JDeveloper 10g ADF Creation Date: Jul 07, 2004 Last Update: Jul 08, 2004 Version 1.0

オブジェクト指向プログラミング・同演習 5月21日演習課題

IM-FormaDesigner for Accel Platform — IM-FormaDesigner 仕様書   第3版  

— IM-PDFTimeStamper for Accel Platform 2018 Spring リリースノート   第3版  

SpringSecurity

intra-mart Accel Platform — 郵便番号検索(日本) 仕様書   初版  

— intra-mart Accel Documents Timestamp Option 2016 Summer リリースノート   初版  

サーブレット (Servlet) とは Web サーバ側で動作する Java プログラム 通常はapache 等のバックグラウンドで動作する Servletコンテナ上にアプリケーションを配置 代表的な Servlet コンテナ Apache Tomcat WebLogic WebSphere Gla

Transcription:

クイック検索検索 目次 Copyright 2015 NTT DATA INTRAMART CORPORATION 1 Top

目次 intra-mart Accel Platform Office 365 連携プログラミングガイド初版 2015-08-01 1. 改訂情報 2. はじめに 2.1. 本書の目的 2.2. 対象読者 2.3. サンプルコードについて 2.4. 本書の構成 3. Office 365 連携プログラミング概要 3.1. Office 365 連携の流れ 4. SharePoint Online のファイラを作成する 4.1. SharePoint Online 上にディレクトリを新規作成する 4.2. SharePoint Online 上にファイルをアップロードする 4.3. SharePoint Online 上のファイルをダウンロードする 4.4. SharePoint Online 上のファイルの詳細情報を表示する 4.5. SharePoint Online 上のファイルを削除する 4.6. SharePoint Online 上のドキュメントをiframeで表示する 4.7. SharePoint Online のファイラを作成する 改訂情報 変更年月日 変更内容 2015-08-01 初版 2

はじめに intra-mart Accel Platform Office 365 連携プログラミングガイド初版 2015-08-01 本書の目的 本書では intra-mart Accel Platform における Office 365 連携機能を用いたプログラミング方法について説明します 対象読者 次の開発者を対象としています intra-mart Accel Platform で Office 365 上のリソースを利用したアプリケーションを作成したい開発者 サンプルコードについて 本書に掲載されているサンプルコードは可読性を重視しており 性能面や保守性といった観点において必ずしも適切な実装ではありません サンプルコードを参考に開発する場合は 上記について十分に注意してください なお ドキュメントの流れに合わせてサンプルを実装し 実際に動作確認を行う場合の前提条件は以下の通りです Office 365 連携セットアップガイドを参考に Office 365 連携の環境を作成してください 本書の構成 本書は以下のような構成となっています Office 365 連携プログラミング概要 SharePoint Online のファイラを作成する Office 365 連携プログラミング概要 3

Office 365 連携の流れ Office 365 連携機能の API は Office 365 の WebAPI をラップする形で提供しています Office 365 の WebAPI の実行に必要なアクセストークンは intra-mart Accel Platform (Office 365 連携 ) が OAuth2.0 の仕様に則って 自動 的に取得 更新します これにより開発者は OAuth2.0 関連の実装が不要となり Office 365 連携機能の API を利用したビジネスロジックの実装に集中することができ ます 開発者は以下の図の 7 と 10 に必要な処理や画面を実装することで Office 365 連携機能を利用したプログラムを作成できます Office 365 連携のフロー図 1. ユーザが 個人設定 - 外部連携アプリケーション 画面で Office 365 連携のプロバイダーを 許可 します 2. intra-mart Accel Platform (Office 365 連携 ) はユーザを Microsoft Azure Active Directory ( 以降 Microsoft Azure AD とする ) にリダイレクトさせます 3. ユーザは Microsoft Azure AD にサインインを行い認証し 必要な場合は許諾を行います 4. Microsoft Azure AD は intra-mart Accel Platform (Office 365 連携 ) のリダイレクトURI に認可コードを返します 5. intra-mart Accel Platform (Office 365 連携 API) は Microsoft Azure AD に認可コードを提示し アクセストークンを要求します 6. Microsoft Azure AD は アクセストークンとリフレッシュトークンを返却します ( アクセストークンの有効期限が切れた場合 リフレッシュトークンを利用し新しいアクセストークンに更新します ) 7. ユーザが SharePoint Online のファイル操作などの Office 365 連携機能のAPIを利用した画面をリクエストします 8. intra-mart Accel Platform (Office 365 連携 API) は アクセストークンを利用し Office 365 の Web API を実行します 9. Office 365 の Web API はリクエストされたデータを返します 10. intra-mart Accel Platform (Office 365 連携 ) は データを利用しユーザのリクエストに応答します コラム Microsoft Azure AD のアクセストークンの取得フローについての詳細は以下のページを参照してください https://msdn.microsoft.com/en-us/library/azure/dn645542.aspx (English) https://msdn.microsoft.com/ja-jp/library/azure/dn645542.aspx ( 日本語 ) https://msdn.microsoft.com/zh-cn/library/azure/dn645542.aspx ( 中文 ) 4

SharePoint Online のファイラを作成する Office 365 連携機能では Office 365 の SharePoint Online のドキュメントにアクセスするための以下の API を提供します Office 365 のFiles REST APIをラップした低レベルAPI jp.co.intra_mart.foundation.office365.api.v1_0.files.operation.filesoperation intra-mart Accel Platform の Storageインタフェースを継承した高レベルAPI jp.co.intra_mart.foundation.office365.service.storage.sharepointstorage ここでは Office 365 連携機能の SharePointStorage APIを利用して実際にプログラムを作成する過程を説明します 本項では 例として JavaEE 開発モデルを利用しています また サンプルコードは可読性を重視しているため JSP 内で全ての処理を行っています 本項に記載のサンプルを組み合わせると以下のような SharePoint Online のファイラが完成します SharePoint Online のファイラの完成イメージ 5

項目 SharePoint Online 上にディレクトリを新規作成する SharePoint Online 上にファイルをアップロードする SharePoint Online 上のファイルをダウンロードする SharePoint Online 上のファイルの詳細情報を表示する SharePoint Online 上のファイルを削除する SharePoint Online 上のドキュメントをiframeで表示する SharePoint Online のファイラを作成する 注意 Office 365 連携のAPIの詳細については以下を参照してください APIドキュメント - SharePointStorage APIドキュメント - FilesOperation Office 365 連携のタグライブラリの詳細については以下を参照してください タグライブラリ - im-office365:excel タグライブラリ - im-office365:powerpoint タグライブラリ - im-office365:word SharePoint Online 上にディレクトリを新規作成する SharePoint Online 上にディレクトリを新規作成する実装のサンプルです リクエストパラメータとして受け取ったプロバイダ ID ターゲットのディレクトリパス ディレクトリの名称を元に新規ディレクトリを作成します 実装例 SharePointStorage#makeDirectories() を利用します %CONTEXT_PATH%/sample/office365/filer/create_dir.jsp 6

7

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 <%@ page contenttype="text/html; charset=utf-8" pageencoding="utf-8" %> <%@ taglib prefix="imui" uri="http://www.intra-mart.co.jp/taglib/imui" %> <%@ page import="java.io.ioexception" %> <%@ page import="jp.co.intra_mart.common.platform.log.logger" %> <%@ page import="jp.co.intra_mart.foundation.context.contexts" %> <%@ page import="jp.co.intra_mart.foundation.context.model.accountcontext" %> <%@ page import="jp.co.intra_mart.foundation.office365.service.storage.sharepointstorage"%> <% String usercd = Contexts.get(AccountContext.class).getUserCd(); String providerid = request.getparameter("providerid"); String currentdirpath = request.getparameter("targetdirpath")!= null? request.getparameter("targetdirpath") : "/"; String createdirname = request.getparameter("createdirname")!= null? request.getparameter("createdirname") : null; String dirpath = currentdirpath + createdirname; String successmsg = null; String errormsg = null; if (createdirname == null) { errormsg = " ディレクトリ名が指定されていません "; else { SharePointStorage storage = new SharePointStorage(userCd, providerid, dirpath); try { // ディレクトリの作成 boolean result = storage.makedirectories(); if (result) { successmsg = " ディレクトリを作成しました <br/><br/>" + dirpath; else { errormsg = " ディレクトリを作成できませんでした <br/><br/>" + dirpath; catch (IOException e) { errormsg = builderrormessage(" ディレクトリ作成時にエラーが発生しました ", e); %> <imui:head> <title>office365 - SharePointStorage API サンプル - ディレクトリ作成 </title> <script type="text/javascript"> $(document).ready(function() { if(<%=successmsg!= null%>){ imuishowsuccessmessage('<%=successmsg%>'); if(<%=errormsg!= null%>){ imuishowerrormessage('<%=errormsg%>'); ); </script> </imui:head> <div class="imui-title"> <h1><%=dirpath%></h1> <div class="imui-toolbar-wrap"> <div class="imui-toolbar-inner"> <ul class="imui-list-toolbar"> <li> <a href="javascript:$('#backtoindex').submit();" class="imui-toolbar-icon" title=" 一覧に戻る "> <span class="im-ui-icon-common-16-back"></span> 一覧に戻る </a> </li> 8

68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 </li> </ul> intra-mart Accel Platform Office 365 連携プログラミングガイド初版 2015-08-01 <form method="post" action="sample/office365/filer/index.jsp" id="backtoindex"> <input type="hidden" name="targetdirpath" value="<%=currentdirpath%>"/> </form> <%! private static Logger logger = Logger.getLogger("sample.office365.filer.create_dir"); private String builderrormessage(string errormessage, Exception errordetail) { logger.error(errordetail.getmessage(), errordetail); return errormessage + "<br/><br/>" + errordetail.getmessage(); %> 注意 Microsoft 社が提供する Office 365 のWebAPIの動作仕様に起因し以下の制限があります SharePointStorage#makeDirectories() および FilesOperation#createFolderByPath() を利用しディレクトリを作成する場合 ルートディレクトリ直下に存在するディレクトリ名と同名のディレクトリを任意のディレクトリ配下に作成することはできません SharePoint Online 上にファイルをアップロードする SharePoint Online 上にファイルをアップロードする実装のサンプルです マルチパートフォームデータとして受け取ったプロバイダ ID ターゲットのディレクトリパス ファイルを元にファイルをアップロードします 実装例 SharePointStorage#create() を利用します %CONTEXT_PATH%/sample/office365/filer/upload.jsp 9

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 <%@ page contenttype="text/html; charset=utf-8" pageencoding="utf-8" %> <%@ page import="java.io.inputstream" %> <%@ page import="java.io.outputstream" %> <%@ page import="jp.co.intra_mart.foundation.context.contexts" %> <%@ page import="jp.co.intra_mart.foundation.context.model.accountcontext" %> <%@ page import="jp.co.intra_mart.common.aid.javaee.http.multipartformdata" %> <%@ page import="jp.co.intra_mart.common.aid.javaee.http.multipartformdata.entity" %> <%@ page import="jp.co.intra_mart.foundation.office365.service.storage.sharepointstorage"%> <%@ page import="jp.co.intra_mart.common.aid.jdk.java.io.ioutil" %> <% String usercd = Contexts.get(AccountContext.class).getUserCd(); //Web Application Server によってはレスポンスにテーマが含まれてしまうため notheme を指定 request.setattribute("imui-theme-builder-module", "notheme"); response.setcontenttype("json"); MultipartFormData data = new MultipartFormData(request); String providerid = data.getentity("providerid").getcontent(); String targetdirpath = new String(data.getEntity("targetDirPath").getBytes(), "utf-8"); Entity localfileentity = data.getentity("local_file"); String filename = localfileentity.getfilename(); SharePointStorage storage = new SharePointStorage(userCd, providerid, targetdirpath + "/" + filename); try (OutputStream outputstream = storage.create(); InputStream inputstream = localfileentity.getinputstream() ){ IOUtil.transfer(inputStream, outputstream); response.setcontenttype("json"); %> [{ "name":"<%= localfileentity.getfilename() %>", "size":<%= localfileentity.getcontentlength() %>, "error":"" ] SharePoint Online 上のファイルをダウンロードする SharePoint Online 上のファイルをダウンロードする実装のサンプルです リクエストパラメータとして受け取ったプロバイダ ID ターゲットのファイルパス ファイルの名称を元にファイルをダウンロードします 実装例 SharePointStorage#open() を利用します %CONTEXT_PATH%/sample/office365/filer/download.jsp 10

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 <%@ page contenttype="text/html; charset=utf-8" pageencoding="utf-8" %> <%@ page import="java.io.inputstream" %> <%@ page import="java.io.outputstream" %> <%@ page import="javax.activation.filetypemap" %> <%@ page import="jp.co.intra_mart.common.aid.jdk.java.io.ioutil" %> <%@ page import="jp.co.intra_mart.foundation.context.contexts" %> <%@ page import="jp.co.intra_mart.foundation.context.model.accountcontext" %> <%@ page import="jp.co.intra_mart.foundation.office365.service.storage.sharepointstorage" %> <%@ page import="jp.co.intra_mart.foundation.http.responseutil" %> <% String usercd = Contexts.get(AccountContext.class).getUserCd(); String providerid = request.getparameter("providerid"); String targetfilepath = request.getparameter("targetfilepath"); String targetfilename = request.getparameter("targetfilename"); response.resetbuffer(); response.setcharacterencoding(null); String mimetype = FileTypeMap.getDefaultFileTypeMap().getContentType(targetFileName); response.setcontenttype(mimetype); String encodedfilename = ResponseUtil.encodeFileName(request, "UTF-8", targetfilename); response.setheader("content-disposition", "attachment; " + encodedfilename); SharePointStorage sharepointstorage = new SharePointStorage(userCd, providerid, targetfilepath); try (InputStream inputstream = sharepointstorage.open(); OutputStream outputstream = response.getoutputstream(); ) { IOUtil.transfer(inputStream, outputstream); %> SharePoint Online 上のファイルの詳細情報を表示する SharePoint Online 上のファイルの詳細情報を表示する実装のサンプルです リクエストパラメータとして受け取ったプロバイダ ID ターゲットのファイルパスをファイルの詳細情報を表示します 実装例 %CONTEXT_PATH%/sample/office365/filer/show_detail.jsp 11

12

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 <%@ page contenttype="text/html; charset=utf-8" pageencoding="utf-8" %> <%@ taglib prefix="imui" uri="http://www.intra-mart.co.jp/taglib/imui" %> <%@ taglib prefix="imtag" uri="http://www.intra-mart.co.jp/taglib/core/standard" %> <%@ taglib prefix="i18n" uri="http://www.intra-mart.co.jp/taglib/im-i18n" %> <%@ page import="jp.co.intra_mart.foundation.context.contexts" %> <%@ page import="jp.co.intra_mart.foundation.context.model.accountcontext" %> <%@ page import="jp.co.intra_mart.foundation.office365.service.storage.sharepointstorage"%> <% String usercd = Contexts.get(AccountContext.class).getUserCd(); String providerid = request.getparameter("providerid"); String targetpathforshowdetail = request.getparameter("targetpathforshowdetail"); String errormsg = ""; if(targetpathforshowdetail == null){ errormsg = " ファイル または ディレクトリが指定されていません "; SharePointStorage storage = new SharePointStorage(userCd, providerid, targetpathforshowdetail); %> <imui:head> <title>office365 - SharePointStorage API サンプル - 詳細表示 </title> <script type="text/javascript"> $(document).ready(function() { if(<%= errormsg!= null %>){ imuishowerrormessage('<%= errormsg %>'); ); </script> </imui:head> <div class="imui-title"> <imtag:condition validity="<%= Boolean.toString(errorMsg.isEmpty()) %>"> <h1><%=storage.getcanonicalpath()%></h1> </imtag:condition> <div class="imui-form-container-narrow"> <div class="imui-chapter-title"> <h2> 詳細情報 </h2> <imtag:condition validity="<%= Boolean.toString(errorMsg.isEmpty()) %>"> <table class="imui-table"> <th class="wd-335px"> 正規化したパス </th> <td><%=storage.getcanonicalpath()%></td> <th> コンテンツをブラウザ上で確認可能な Web URL</th> <td> <a href="<%=storage.getweburl()%>"><%=java.net.urldecoder.decode(storage.getweburl(), "UTF-8")%></a> </td> <th> 作成時刻 </th> <td><i18n:datetime value="<%=new java.util.date(storage.created())%>" pattern="yyyy/mm/dd hh:mm:ss"/></td> <th> 作成ユーザ ID</th> <td><%=storage.createduserid()%></td> <th> 作成ユーザ名 </th> <td><%=storage.createdusername()%></td> 13

68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 intra-mart Accel Platform Office 365 連携プログラミングガイド初版 2015-08-01 <th> 最終更新時刻 </th> <td><i18n:datetime value="<%=new java.util.date(storage.lastmodified())%>" pattern="yyyy/mm/dd hh:mm:ss"/></td> <th> 最終更新ユーザ ID</th> <td><%=storage.lastmodifieduserid()%></td> <th> 最終更新ユーザ名 </th> <td><%=storage.lastmodifiedusername()%></td> <th> ファイルサイズ </th> <td><%=storage.length()%> バイト </td> </table> </imtag:condition> SharePoint Online 上のファイルを削除する SharePoint Online 上のファイルを削除する実装のサンプルです リクエストパラメータとして受け取ったプロバイダ ID ターゲットのファイルパスを元にファイルを削除します 実装例 SharePointStorage#remove() を利用します %CONTEXT_PATH%/sample/office365/filer/remove.jsp 14

15

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 <%@ page contenttype="text/html; charset=utf-8" pageencoding="utf-8" %> <%@ taglib prefix="imui" uri="http://www.intra-mart.co.jp/taglib/imui" %> <%@ page import="java.io.ioexception" %> <%@ page import="jp.co.intra_mart.common.platform.log.logger" %> <%@ page import="jp.co.intra_mart.foundation.context.contexts" %> <%@ page import="jp.co.intra_mart.foundation.context.model.accountcontext" %> <%@ page import="jp.co.intra_mart.foundation.office365.service.storage.sharepointstorage"%> <% String usercd = Contexts.get(AccountContext.class).getUserCd(); String providerid = request.getparameter("providerid"); String targetpath = request.getparameter("targetpathforremove"); String currentdirpath = request.getparameter("targetdirpath")!= null? request.getparameter("targetdirpath") : "/"; String successmsg = null; String errormsg = null; if (targetpath == null) { errormsg = " ファイル または ディレクトリが指定されていません "; else { SharePointStorage storage = new SharePointStorage(userCd, providerid, targetpath); try { // ファイルまたはディレクトリの削除 boolean result = storage.remove(true); if (result) { successmsg = " " + targetpath + " を削除しました "; else { errormsg = " " + targetpath + " を削除できませんでした "; catch (IOException e) { errormsg = builderrormessage(" 削除時にエラーが発生しました ", e); %> <imui:head> <title>office365 - SharePointStorage API サンプル - 削除 </title> <script type="text/javascript"> $(document).ready(function() { if(<%=successmsg!= null%>){ imuishowsuccessmessage('<%=successmsg%>'); if(<%=errormsg!= null%>){ imuishowerrormessage('<%=errormsg%>'); ); </script> </imui:head> <div class="imui-title"> <h1><%=targetpath%></h1> <div class="imui-toolbar-wrap"> <div class="imui-toolbar-inner"> <ul class="imui-list-toolbar"> <li> <a href="javascript:$('#backtoindex').submit();" class="imui-toolbar-icon" title=" 一覧に戻る "> <span class="im-ui-icon-common-16-back"></span> 一覧に戻る </a> </li> </ul> 16

68 69 70 71 72 73 74 75 76 77 78 79 intra-mart Accel Platform Office 365 連携プログラミングガイド初版 2015-08-01 <form method="post" action="sample/office365/filer/index.jsp" id="backtoindex"> <input type="hidden" name="targetdirpath" value="<%=currentdirpath%>"/> </form> <%! private static Logger logger = Logger.getLogger("sample.office365.filer.remove"); private String builderrormessage(string errormessage, Exception errordetail) { logger.error(errordetail.getmessage(), errordetail); return errormessage + "<br/><br/>" + errordetail.getmessage(); %> SharePoint Online 上のドキュメントを iframe で表示する SharePoint Online 上のドキュメントを iframe で表示する実装のサンプルです リクエストパラメータとして受け取ったプロバイダ ID ターゲットのファイルパスを元にドキュメントを iframe で表示します 実装例 im-office365 タグを利用します %CONTEXT_PATH%/sample/office365/filer/show_iframe.jsp 17

18

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 <%@ page contenttype="text/html; charset=utf-8" pageencoding="utf-8"%> <%@ taglib prefix="imtag" uri="http://www.intra-mart.co.jp/taglib/core/standard" %> <%@ taglib prefix="im-office365" uri="http://www.intra-mart.co.jp/taglib/im-office365"%> <% String width = "640"; String height = "480"; String providerid = request.getparameter("providerid"); String targetpath = request.getparameter("targetpathforshowiframe"); String errormsg = null; if (targetpath == null) { errormsg = " ファイルが指定されていません "; %> <imui:head> <title>office365 - iframe 表示 </title> <script type="text/javascript"> $(document).ready(function() { if(<%=errormsg!= null%>){ imuishowerrormessage('<%=errormsg%>'); ); </script> </imui:head> <div class="imui-title"> <h1><%=targetpath%></h1> <div id="imui-container-inner"> <imtag:condition validity="<%=isword(targetpath)%>"> <im-office365:word providerid="<%=providerid%>" path="<%=targetpath%>" width="<%=width%>" height="<%=height%>" /> </imtag:condition> <imtag:condition validity="<%=isexcel(targetpath)%>"> <im-office365:excel providerid="<%=providerid%>" path="<%=targetpath%>" width="<%=width%>" height="<%=height%>" /> </imtag:condition> <imtag:condition validity="<%=ispowerpoint(targetpath)%>"> <im-office365:powerpoint providerid="<%=providerid%>" path="<%=targetpath%>" width="<%=width%>" height="<%=height%>" /> </imtag:condition> <%! private String isword(final String filename) { return ".docx".equals(getextention(filename))? "true" : "false"; private String isexcel(final String filename) { return ".xlsx".equals(getextention(filename))? "true" : "false"; private String ispowerpoint(final String filename) { return ".pptx".equals(getextention(filename))? "true" : "false"; private String getextention(string filename) { final int indexoflastdot = filename.lastindexof("."); if (indexoflastdot == -1) { return null; return filename.substring(indexoflastdot); %> 19

68 %> intra-mart Accel Platform Office 365 連携プログラミングガイド初版 2015-08-01 注意 ドキュメントを表示するにはユーザが Office 365 - SharePoint Online にログインしている必要があります SharePoint Online のファイラを作成する 前述の実装例を組み合わて SharePoint Online のファイラを作成します providerid は Office 365 連携セットアップガイド で環境構築の際に設定した <im_office365_files_api.xml> のプロバイダ ID を指定してくだ さい 実装例 SharePointStorage#directoriesStorages() SharePointStorage#filesStorages() を利用します %CONTEXT_PATH%/sample/office365/filer/index.jsp 20

21

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 <%@ page contenttype="text/html; charset=utf-8" pageencoding="utf-8" %> <%@ taglib prefix="imui" uri="http://www.intra-mart.co.jp/taglib/imui" %> <%@ taglib prefix="imtag" uri="http://www.intra-mart.co.jp/taglib/core/standard" %> <%@ page import="java.io.inputstream" %> <%@ page import="java.io.ioexception" %> <%@ page import="java.io.outputstream" %> <%@ page import="java.util.arraylist" %> <%@ page import="java.util.collection" %> <%@ page import="jp.co.intra_mart.common.platform.log.logger" %> <%@ page import="jp.co.intra_mart.foundation.context.contexts" %> <%@ page import="jp.co.intra_mart.foundation.context.model.accountcontext" %> <%@ page import="jp.co.intra_mart.foundation.oauth.client.service.oauthpreconditionexception" %> <%@ page import="jp.co.intra_mart.foundation.office365.service.storage.sharepointstorage"%> <% String providerid = "Please_input_your_ID"; String usercd = Contexts.get(AccountContext.class).getUserCd(); String currentdirpath = request.getparameter("targetdirpath")!= null? addslashtotheend(request.getparameter("targetdirpath")) : "/"; String errormsg = null; SharePointStorage storage = new SharePointStorage(userCd, providerid, currentdirpath); // 一覧取得 Collection<SharePointStorage> directoriesstorages = new ArrayList<SharePointStorage>(); Collection<SharePointStorage> filesstorages = new ArrayList<SharePointStorage>(); try { directoriesstorages = storage.directoriesstorages(false); filesstorages = storage.filesstorages(false); catch (IOException e) { errormsg = builderrormessage(" ディレクトリ または ファイル一覧の取得時にエラーが発生しました ", e); // 親ディレクトリの存在チェック String parentdir = storage.getparent(); String existsparentdir = parentdir!= null? "true" : "false"; %> <imui:head> <title>office365 - SharePointStorage API サンプル </title> <script src="csjs/im_window.js"></script> <script type="text/javascript"> function movedir(targetdirpath){ $('#targetdirpath').val('<%= currentdirpath %>' + targetdirpath); $('#movedirform').submit(); function downloadfile(targetfilepath){ $('#targetfilepath').val('<%= currentdirpath %>' + targetfilepath); $('#targetfilename').val(targetfilepath); $('#downloadfileform').submit(); function removefileordir(targetpath){ $('#targetpathforremove').val('<%= currentdirpath %>' + targetpath); $('#removefileordirform').submit(); function showdetail(targetpath){ opennewwindow("office365_show_detail").focus(); $('#targetpathforshowdetail').val('<%= currentdirpath %>' + targetpath); $('#showdetailform').submit(); function showiframe(targetpath){ opennewwindow("office365_show_iframe").focus(); 22

68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 intra-mart Accel Platform Office 365 連携プログラミングガイド初版 2015-08-01 opennewwindow("office365_show_iframe").focus(); $('#targetpathforshowiframe').val('<%= currentdirpath %>' + targetpath); $('#showiframeform').submit(); $(document).ready(function() { if(<%= errormsg!= null %>){ imuishowerrormessage('<%= errormsg %>'); $('#toparent').click(function() { $('#targetdirpath').val('/' + '<%= parentdir %>'); $('#movedirform').submit(); ); ); </script> </imui:head> <div class="imui-container"> <div class="imui-title"> <h1><%= currentdirpath %></h1> <div class="imui-form-container-narrow"> <div class="imui-chapter-title"> <h2> ファイル一覧 </h2> <form method="post" action="sample/office365/filer/index.jsp"> <input type="text" name="targetdirpath" value="<%= currentdirpath %>" size="70" /> <input type="submit" value=" 移動 " class="imui-small-button" /> </form> <br /> <table class="imui-table"> <th> 名前 </th> <th> 詳細 </th> <th> 削除 </th> <th>iframe 表示 </th> <imtag:condition validity="<%= existsparentdir %>"> <td><a href="javascript:void(0)" id="toparent"> 親ディレクトリへ移動 </a></td> <td></td> <td></td> <td></td> </imtag:condition> <!-- ディレクトリ一覧 --> <imtag:repeat list="<%= directoriesstorages %>" type="sharepointstorage" item="dirstorage" index="idx"> <td> <span class="im-ui-icon-common-16-folder"></span> <a href="javascript:void(0)" onclick="movedir('<%= dirstorage.getname() %>');"><%= dirstorage.getname() %></a> </td> <td align="center"> <a href="javascript:void(0)" onclick="showdetail('<%= dirstorage.getname() %>');"> <span class="im-ui-icon-common-16-information"></span> </a> </td> <td align="center"> <a href="javascript:void(0)" onclick="removefileordir('<%= dirstorage.getname() %>');"> <span class="im-ui-icon-common-16-trashbox"></span> </a> </td> <td></td> </imtag:repeat> 23