将文档保存在 space 中,在露天使用空白字符

saving document in space with blank character in alfresco

我使用 alfresco 4.0

我在以阿拉伯语命名的露天特殊 space 中保存文档时遇到问题。

对于这个例子,我没有遇到问题:

/app:company_home/cm:تجربة

但是当 space 在 alfresco 中创建并以阿拉伯语命名并具有空白字符时,我遇到了问题。像这样:

/app:company_home/cm:تجربة ثانية

在这种情况下,我无法在露天保存文档

已更新:

当我有一个以英文命名的文件夹并且有这样的转义字符时,我也遇到了同样的问题:

秘书长阁下

记者秘书处

这是在露天保存文件的文件

 public String saveDocument(File file, String name, String folderName, String userName, String pwd, String code)
        throws Exception {
        File file_BC = file;
        try {
            BarCodeEngine barCodeEngine = new BarCodeEngine(file, code);
            file_BC = barCodeEngine.setBarCode();
        } catch (Exception e) {
            e.printStackTrace();
        }

        byte[] contentByte = IOUtils.toByteArray(new FileInputStream(file_BC));

        // Start the session
        AuthenticationUtils.startSession(userName, pwd);

        try {
            // Create a reference to the parent where we want to create content
            Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
            ParentReference companyHomeParent = new ParentReference(storeRef, null, folderName, Constants.ASSOC_CONTAINS, null);

            // Assign name
            companyHomeParent.setChildName("cm:" + name);

            // Construct CML statement to create content node
            // Note: Assign "1" as a local id, so we can refer to it in subsequent
            //       CML statements within the same CML block
            NamedValue[] contentProps = new NamedValue[1];
            contentProps[0] = Utils.createNamedValue(Constants.PROP_NAME, name);

            CMLCreate create = new CMLCreate("1", companyHomeParent, null, null, null, Constants.TYPE_CONTENT, contentProps);

            // Construct CML statement to add titled aspect
            NamedValue[] titledProps = new NamedValue[2];
            titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, name);
            titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, name);

            CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_TITLED, titledProps, null, "1");

            // Construct CML Block
            CML cml = new CML();
            cml.setCreate(new CMLCreate[] { create });
            cml.setAddAspect(new CMLAddAspect[] { addAspect });

            // Issue CML statement via Repository Web Service and retrieve result
            // Note: Batching of multiple statements into a single web call
            UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);
            Reference content = result[0].getDestination();

            // Write some content
            ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();

            //String text = "The quick brown fox jumps over the lazy dog";
            ContentFormat contentFormat = new ContentFormat("text/plain", "UTF-8");
            Content contentRef = contentService.write(content, Constants.PROP_CONTENT, contentByte, contentFormat);
            System.out.println("Document are created successfully. UID:= " + content.getUuid());

            return content.getUuid();
        } catch (Throwable e) {
            System.out.println(e.toString());
        } finally {
            // End the session
            AuthenticationUtils.endSession();

            //System.exit(0);
        }

        return null;
    }

我尝试用这个字符替换 espace : + 但没有成功

saveAttachement(file,
                                     fileName +
                                    System.currentTimeMillis(), container.replace(" ","+"),
                                    USER_NAME, PASSWORD,
                                    code);

这是带 espace

的旧容器

/app:company_home/cm:Secretary/cm:记者 秘书处

这是带有 +

的容器

/app:company_home/cm:阁下+Secretary/cm:记者+秘书处

在 alfresco 的日志中我没有发现任何错误

尝试使用 ISO9075.encode(folderName) 对您的文件夹名称进行编码。

Lucene 搜索语法需要使用 ISO9075 对空格进行编码。我认为这就是您使用 ParentReference 的幕后某处发生的事情。