我使用alfresco 4.0
我有一个问题是用阿拉伯语命名的alfresco中的特殊空间保存文档。
对于这个例子,我没有遇到问题:
/app:company_home/cm:تجربة
但是当我在alfresco中创建太空女巫用阿拉伯语命名并且有空白字符时,我有问题。像这样:
/app:company_home/cm:تجربة ثانية
在这种情况下,我无法在露天保存文件
已更新:
当我有一个英文名称的文件夹并且有这样的转义字符时,我也有同样的问题:
局长阁下
记者秘书处
这是在alfresco
中保存文档的文档 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:局长阁下/ cm:记者秘书处
这是带有
的容器/ app:company_home / cm:他的阁下+秘书/ cm:记者+秘书处
在alfresco的日志中我没有发现任何错误
答案 0 :(得分:0)
尝试使用ISO9075.encode(folderName)对folderName进行编码。
Lucene搜索语法需要使用ISO9075对空格进行编码。我知道这是在你的ParentReference用法的幕后发生的事情。