0

そのため、MOSS 2007 WebサービスAPIのJava実装を使用して、SharePointサイトにドキュメントをアップロードしようとしています。なんとかファイルをサイトにアップロードできました。これは、リンク先URLを手動で表示することで確認できます。ただし、すべてのドキュメントビューを使用する場合、ファイルは表示されません。メタデータの設定と関係があるように感じますが、よくわかりません。

参考までに私のコードは次のとおりです。

public static void main(String[] args) {

JCopy copy = new JCopy("http://somespsite", "user", "pass");
try {
        File f = new File("c:/test.txt");
        byte[] b = new byte[(int) f.length()];

        FileInputStream fileInputStream = new FileInputStream(f);
        fileInputStream.read(b);
        List<String> dest = new ArrayList<String>();
        dest.add("http://somespsite/Test Repository/Forms/test.txt");

        List< FieldInformation > fields = new ArrayList<FieldInformation>();
        FieldInformation field = new FieldInformation();
        field.setType(FieldType.TEXT);
        field.setDisplayName("Test2");
        field.setInternalName("Test2");
        field.setId(java.util.UUID.randomUUID().toString());
        field.setValue(field.getValue());

        copy.copyIntoItems(
                "c:/test.txt",
                dest, 
                fields, 
                b, 
                null);

        }catch (Exception e) {
            e.printStackTrace();
        }
}


class JCopy {
public int copyIntoItems(
        String sourceUrl, 
        List<String> destinations, 
        List<FieldInformation> fields, 
        byte[] stream,
        List<CopyResult> results ) 
{
    DestinationUrlCollection destinationUrls = new DestinationUrlCollection();
    for(String s : destinations)
        destinationUrls.addString(s);

    FieldInformationCollection fieldsInput = new FieldInformationCollection();
    for(FieldInformation f : fields)
        fieldsInput.addFieldInformation(f);

    Holder<Long> copyIntoItemsResult = new Holder<Long>(Long.valueOf(-1));
    Holder<CopyResultCollection> resultsOutput = new Holder<CopyResultCollection>((CopyResultCollection) results);

    try {

        port.copyIntoItems(sourceUrl, destinationUrls, fieldsInput, stream, copyIntoItemsResult, resultsOutput);

        results = resultsOutput.value.getCopyResult();

    } catch (Exception e) {
        e.printStackTrace();

    }

    return copyIntoItemsResult.value.intValue();
}}

portは、JDK1.6を使用してNetbeansによって生成されたスタブのインスタンスです。

4

1 に答える 1

1

ドキュメントを間違った場所にアップロードしています。

ファイルドキュメントライブラリに保存されます。ドキュメントライブラリには、各ファイルのプロパティを表示および編集するための一連のデフォルトフォームがあります。適切な権限を持つユーザーは、それらをカスタマイズしたり、新しい権限を追加したりできます。

フォームは、各ドキュメントライブラリの「Forms」フォルダに配置されます。すべてのビューには、Formsフォルダーではなく、ライブラリ自体のコンテンツが表示されます。

「テストリポジトリ」がドキュメントライブラリであると想定します。その場合、ファイルtest.txtを「テストリポジトリ」自体ではなく「フォーム」ディレクトリにアップロードします。

「テストリポジトリ/フォーム」ではなく「テストリポジトリ」を指すようにURLを変更するだけです。

于 2012-06-14T16:03:20.373 に答える