CmisInvalidArgumentException when downloading Private Working Copy from Alfresco via CMIS - alfresco

My open-source app downloads the files of an Alfresco folder (by CMIS).
Algorithm is very simple:
List content of folder with Folder.getChildren()
Download each with Document.getContentStream()
It works fine, except for folders that contain a Working Copy of a file, in which case Alfresco says:
org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException: Stream id is invalid: workspace://SpacesStore/8b9a58ba-652f-4a18-8d26-aba06df98d25;pwc
at org.alfresco.opencmis.CMISConnector.getContentStream(CMISConnector.java:1199)
at org.alfresco.opencmis.AlfrescoCmisServiceImpl.getContentStream(AlfrescoCmisServiceImpl.java:1795)
at sun.reflect.GeneratedMethodAccessor700.invoke(Unknown Source)
The ;pwc probably means "Private Working Copy", which is a special case in the CMIS protocol. Working Copies are created when an Alfresco Share user clicks "Edit Offline" on a document (aka check out/check in).
Is my algorithm flawed? Or could it be a bug in Alfresco/OpenCMIS?

I'm not sure of the details, as you don't paste here the code that triggers the exception and you don't mention which Chemistry version you're using. Anyway, if I run the following groovy code within the CMIS workbench v0.8.0 it successfully print all files contents:
def obj = session.getObjectByPath("/cc");
def children = obj.getChildren();
for (doc in children) {
def s = doc.getContentStream();
def i = s.getStream();
println(i.text);
}
The cc folder used above is one I created in Alfresco CMIS instance, where I put a file and checked it out to create a PWC. I assume there is some issue with your code, as the above code uses the very same API.

Related

How Can I use "my documents" folder as sqlite dabase path? [duplicate]

I´m developing an app that is reading jpeg and pdf files from a configurable location on the filesystem.
Currently there is a running version implemented in WPF and now I´m trying to move to the new Windows Universal apps.
The following code works fine with WPF:
public IList<string> GetFilesByNumber(string path, string number)
{
if (string.IsNullOrWhiteSpace(path))
throw new ArgumentNullException(nameof(path));
if (string.IsNullOrWhiteSpace(number))
throw new ArgumentNullException(nameof(number));
if (!Directory.Exists(path))
throw new DirectoryNotFoundException(path);
var files = Directory.GetFiles(path, "*" + number + "*",
SearchOption.AllDirectories);
if (files == null || files.Length == 0)
return null;
return files;
}
With using Universal Apps I ran into some problems:
Directory.Exists is not available
How can I read from directories outside of my app storage?
To read from an other directory outside the app storage I tried the following:
StorageFolder folder = StorageFolder.GetFolderFromPathAsync("D:\\texts\\");
var fileTypeFilter = new string[] { ".pdf", ".jpg" };
QueryOptions queryOptions = new QueryOptions(CommonFileQuery.OrderBySearchRank, fileTypeFilter);
queryOptions.UserSearchFilter = "142";
StorageFileQueryResult queryResult = folder.CreateFileQueryWithOptions(queryOptions);
IReadOnlyList<StorageFile> files = queryResult.GetFilesAsync().GetResults();
The thing is: It isn´t working, but I get an exception:
An exception of type 'System.UnauthorizedAccessException' occurred in TextManager.Universal.DataAccess.dll but was not handled in user code
Additional information: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
I know that you have to configure some permissions in the manifest, but I can´t find one suitable for filesystem IO operations...
Did someone also have such problems/a possible solution?
Solution:
From the solutions that #Rico Suter gave me, I chosed the FutureAccessList in combination with the FolderPicker. It is also possible to access the entry with the Token after the program was restarted.
I can also recommend you the UX Guidlines and this Github sample.
Thank you very much!
In UWP apps, you can only access the following files and folders:
Directories which are declared in the manifest file (e.g. Documents, Pictures, Videos folder)
Directories and files which the user manually selected with the FileOpenPicker or FolderPicker
Files from the FutureAccessList or MostRecentlyUsedList
Files which are opened with a file extension association or via sharing
If you need access to all files in D:\, the user must manually pick the D:\ drive using the FolderPicker, then you have access to everything in this drive...
UPDATE:
Windows 10 build 17134 (2018 April Update, version 1803) added additional file system access capabilities for UWP apps:
Any UWP app (either a regular windowed app or a console app) that declares an AppExecutionAlias is now granted implicit access to the files and folders in the current working directory and downward, when it’s activated from a command line. The current working directory is from whatever file-system location the user chooses to execute your AppExecutionAlias.
The new broadFileSystemAccess capability grants apps the same access to the file system as the user who is currently running the app without file-picker style prompts. This access can be set in the manifest in the following manner:
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
...
IgnorableNamespaces="uap mp uap5 rescap">
...
<Capabilities>
<rescap:Capability Name="broadFileSystemAccess" />
</Capabilities>
These changes and their intention are discussed at length in the MSDN Magazine article titled Universal Windows Platform - Closing UWP-Win32 Gaps. The articles notes the following:
If you declare any restricted capability, this triggers additional
scrutiny at the time you submit your package to the Store for
publication. ... You don’t need an AppExecutionAlias if you have this
capability. Because this is such a powerful feature, Microsoft will
grant the capability only if the app developer provides compelling
reasons for the request, a description of how this will be used, and
an explanation of how this benefits the user.
further:
If you declare the broadFileSystemAccess capability, you don’t need to
declare any of the more narrowly scoped file-system capabilities
(Documents, Pictures or Videos); indeed, an app must not declare both
broadFileSystemAccess and any of the other three file-system
capabilities.
finally:
Even after the app has been granted the capability, there’s also a
runtime check, because this constitutes a privacy concern for the
user. Just like other privacy issues, the app will trigger a
user-consent prompt on first use. If the user chooses to deny
permission, the app must be resilient to this.
The accepted answer is no longer complete. It is now possible to declare broadFileSystemAccess in the app manifest to arbitrarily read the file system.
The File Access Permissions page has details.
Note that the user can still revoke this permission via the settings app.
You can do it from UI in VS 2017.
Click on manifest file -> Capabilities -> Check photo library or whatever stuff you want.
According to MSDN doc : "The file picker allows an app to access files and folders, to attach files and folders, to open a file, and to save a file."
https://msdn.microsoft.com/en-us/library/windows/apps/hh465182.aspx
You can read a file using the filepicker through a standard user interface.
Regards
this is not true:
Files which are opened with a file extension association or via sharing
try it, by opening files from mail (outlook) or from the desktop...
it simply does not work
you first have to grant the rights by the file picker.
so this ist sh...
This is a restricted capability. Access is configurable in Settings > Privacy > File system. and enable acces for your app. Because users can grant or deny the permission any time in Settings, you should ensure that your app is resilient to those changes. If you find that your app does not have access, you may choose to prompt the user to change the setting by providing a link to the Windows 10 file system access and privacy article. Note that the user must close the app, toggle the setting, and restart the app. If they toggle the setting while the app is running, the platform will suspend your app so that you can save the state, then forcibly terminate the app in order to apply the new setting. In the April 2018 update, the default for the permission is On. In the October 2018 update, the default is Off.
More info

Is it possible to automate setting of Artifactory properties?

Artifactory seems to automatically generate properties for RPMs, Python wheels etc. Can I extend this function for my own file formats?
I've read the documentation and this talks about the REST API etc but I want to have Artifactory pull properties straight out of the file that I'm uploading.
None yet - I'm asking how.
The logic that automatically generates properties for RPMs etc is hardcoded into each package type Artifactory supports, and you can't add custom repository types.
What you can do is write a user plugin which runs whenever a file is uploaded, reads the file, and adds the appropriate properties. For example:
storage {
afterCreate { item ->
if (!item.isFolder() && item.name.endsWith(".customext")) {
def fstream = repositories.getContent(item.repoPath).inputStream
// read fstream and generate properties
repositories.setProperty(item.repoPath, propName, propVal)
}
}
}
Some notes:
The language is Groovy. If you aren't familiar with Groovy, in a pinch you can pretend it's Java, since most Java is also valid Groovy.
User plugin documentation is here
User plugin API Javadoc is here
For reference, the officially supported plugins are all here

Setting custom local storage Path in QML

I m trying to put a custom path in QML file but can't get it done.
I'm trying to get de db in a shared folder where i'm willing to put the DB so any person who has the program can acces to data.
I'm using Sqlite and Qt Creator 5.7 but not a lot of info about this.
You can simply COPY the database from its default path. Typically that is located (In windows anyways) at
C:\Users\<username>AppData\Local\<program name>\QML\OfflineStorage\Databases
and on Mobile devices it is stored in a similar place --
on android its in a sub folder of:
/data/data/<Program Name>
On *nix it is located:
/home/<user>/.local/share/[ProjectName]/QML/OfflineStorage/Databases

How to access public download folder in every platform in Xamarin.Forms

I need to create a backup service so I intend to save the SQLite database file on each platform. The saved file should be available after the uninstall of the app.
I intend to use the Downloads folder (which should be available on every platform).
I have created an interface and use the following code per platform:
Interface:
public interface IBackupService
{
string GetDownloadPath();
}
Android:
public string GetDownloadPath()
{
return Android.OS.Environment.DirectoryDownloads;
}
UWP:
public string GetDownloadPath()
{
return Windows.Storage.KnownFolders.???????;
}
What should I do about that? Is there a public library that I could use?
There does not seem to be a general downloads folder as per this documentation on KnownFolders. So your assumption on the Downloads folder being on every platform doesn't seem to be correct.
If we dive in a bit further we get to the DocumentsLibrary which seems the obvious choice for this kind of purpose, but it is not. Microsoft says:
The Documents library is not intended for general use. For more info,
see App capability declarations. Also, see the following blog post.
Dealing with Documents: How (not) to use the documentsLibrary capability in Windows Store apps
The paragraph after that seems to describe what we have to do then;
If your app has to create and update files that only your app uses,
consider using the app's local folder. Get the app's local folder from
the Windows.Storage.ApplicationData.Current.LocalFolder property.
So, as I can extract from your question you only want to use storage for your app, so the Windows.Storage.ApplicationData.Current.LocalFolder seems to be the right choice according to Microsoft.

Howto recognize documents in Alfresco 5.0 and filing them according content?

I have following use case:
Existing scanner scans documents and stores them via WebDAV or a shared network drive to Alfresco
Documents are separated with a barcode to identify the customer and document type (e.g. bill)
If a document arrives in the shared drive, Alfresco should analyse it and move it (according customer and document type) to the suitable internal folder structure.
Example of a folder structure:
/scans/
/customers/ExampleCustomer1/bills
/customers/ExampleCustomer1/emails
/customers/ExampleCustomer1/hr
/customers/ExampleCustomer2/bills
/customers/ExampleCustomer2/emails
/customers/ExampleCustomer2/hr
Question:
What do I need in Alfresco to process step 3) to automatically recognize documents and file them?
P.s. I know there exists applications like Ephesoft/Kofax but I would like to have a module inside Alfresco which does the job for me without external dependencies.
I would suggest the following sequence:
1)Your scanner or other (OCR) software needs to interprete the barcode and save the customer and type somewhere in the document, for example in docx metadata.( I am not aware of an alfresco module doing ocr or barcode reading)
2)After upload via webdav, you have to run alfresco metadata extract action, which will have to extract the customer and type from the documents metadata into alfresco metadata by using an alfresco rule script or behaviour.
Using a rule, you can choose the action "extract common metadata fields"
Using a java behaviour, you can call the same action like this:
Action action = actionService.createAction("extract-metadata");
actionService.executeAction(action, node);
This extract action is described here : https://wiki.alfresco.com/wiki/Metadata_Extraction . You may have to add custom code for your barcode requirement. (https://wiki.alfresco.com/wiki/Content_Transformation_and_Metadata_Extraction_with_Apache_Tika )
3)an alfresco rule script or behaviour is now able to move your document by reading this alfresco metadata property.
This is a very good howto about custom types and let me deep dive into Alfresco:
http://ecmarchitect.com/alfresco-developer-series-tutorials/content/tutorial/tutorial.html
Alfresco Developer Tutorials: http://ecmarchitect.com/alfresco-developer-series

Resources