Extract Aflresco documents from command line - alfresco

I would like to know if it is possible to access the documents that Alfresco keeps. I want to make a project to generate a zip for each user registered automatically.
Thanks

Related

Accessing files from Google cloud storage in RStudio

I have been trying to create connection between the Google cloud storage and RStudio server(The one I spinned up in Google cloud), so that I can access the files in R to run sum analysis on.
I have found three different ways to do it on the web, but I don't see many clarity around these ways so far.
Access the file by using the public URL specific to the file [This is not an option for me]
Mount the Google cloud storage as a disc in RStudio server and access it like any other files in the server [ I saw someone post about this method but could not find on any guides or materials that shows how it's done]
Using the googleCloudStorageR package to get full access to the Cloud Storage bucket.
The step 3 looks like the pretty standard way to do it. But I get following error when I try to hit the gcs_auth() command
Error in gar_auto_auth(required_scopes, new_user = new_user, no_auto =
no_auto, : Cannot authenticate -
options(googleAuthR.scopes.selected) needs to be set to
includehttps://www.googleapis.com/auth/devstorage.full_control or
https://www.googleapis.com/auth/devstorage.read_write or
https://www.googleapis.com/auth/cloud-platform
The guide on how to connect using this is found on
https://github.com/cloudyr/googleCloudStorageR
but it says it requires a service-auth.json file to set the environment variables and all other keys and secret keys, but do not really specify on what these really are.
If someone could help me know how this is actually setup, or point me to a nice guide on setting the environment up, I would be very much grateful.
Thank you.
Before using any services by google cloud you have to attach your card.
So, I am assuming that you have created the account, after creating the account go to Console ,if you have not created Project then Create Project, then click on sidebar find APIs & Services > Credentials.
Then,
1)Create Service Account Keys save this File in json you can only download it once.
2)OAuth 2.0 client ID give the name of the app and select type as web application and download the json file.
Now For Storage go to Sidebar Find Storage and click on it.
Create Bucket and give the name of Bucket.
I have added the single image in bucket, you can also add for the code purpose.
lets look how to download this image from storage for other things you can follow the link that you have given.
First create environment file as .Renviron so it automatically catches the json file and save it in a working directory.
In .Renviron file add those two downloaded json files like this
GCS_AUTH_FILE="serviceaccount.json"
GAR_CLIENT_WEB_JSON="Oauthclient.json"
#R part
library(googleCloudStorageR)
library(googleAuthR)
gcs_auth() # for authentication
#set the scope
gar_set_client(scopes = c("https://www.googleapis.com/auth/devstorage.read_write",
"https://www.googleapis.com/auth/cloud-platform"))
gcs_get_bucket("you_bucket_name") #name of the bucket that you have created
gcs_global_bucket("you_bucket_name") #set it as global bucket
gcs_get_global_bucket() #check if your bucket is set as global,you should get your bucket name
objects <- gcs_list_objects() # data from the bucket as list
names(objects)
gcs_get_object(objects$name[[1]], saveToDisk = "abc.jpeg") #save the data
**Note :**if you dont get json file loaded restart the session using .rs.restartR()
and check the using
Sys.getenv("GCS_AUTH_FILE")
Sys.getenv("GAR_CLIENT_WEB_JSON")
#it should show the files
You probably want the FUSE adaptor - this will allow you to mount your GCS bucket as a directory on your Server.
Install gcsfuse on the R server.
create a mnt directory.
run gcsfuse your-bucket /path/to/mnt
Be aware though that RW performance isnt great vis FUSE
Full documentation
https://cloud.google.com/storage/docs/gcs-fuse

Save profiles / files Alfresco

I want to uninstall Alfresco and re-install again, but I don't want to loose the accounts created in Alfresco and the other things. Is there any way to save this ?
Thanks!!
Let's assume that by re-installing you mean you want to start with a clean alfresco WAR and share WAR. If so, you can just shut down, remove the alfresco and share directories, then place the clean WARs in the $TOMCAT_HOME/webapps directory. If you had any AMPs deployed, use MMT to re-install those. Then, restart Tomcat. The content is in the content store directory and the metadata is in the database, so you can start over with fresh WARs without losing any data.
If you mean you want to delete everything in $ALFRESCO_HOME but you want to save your data, the easiest thing to do is to dump your database and tar up your content store. Then you can completely blow away your installation, and after reinstalling, you can load your database and un-tar your content store.
If you are trying to blow away some, but not all of your data, you'll have to export what you want to keep. You might go look at the docs on ACP files as one possible approach. Or you could use something like CMIS to write an exporter.
For users, specifically, it is often helpful to use an LDAP directory instead of managing them in Alfresco directly. That way you can completely start over and Alfresco will simply synchronize your users from LDAP.
If you don't want to use LDAP an alternative is to have a simple CSV file with user account data. After starting your repository for the first time you can re-import your users from the CSV file.

Should we store data in database?

i'm asp.net beginner and currently working in "upload download file" project with asp.net and vb.net as code behind language (like skydrive's web).
what i'm want ask is about upload file in server, must we store path file, size, accessed or created date into database? as we know we can use directory listing in system.io.
Thanks for your help.
You definetly want to store the path of the file. You want a way to find the file ;) Maybe later you will have multiple servers, replication or other fancy things.
For the rest, it depends a bit on the type of website. If it's going to get high traffic then store it in the database, this will limit the number of IO call (very slow). Also, it'll be a lot easier to handle sorting and queries. (sort by date, pull only the read onyl files, ...).
Database will also help if you want to show history or statistique.
You can save file in some directory and can save path of that file in database. You can also store size and created date of that file in DB. But storing a file in DB is a bit difficult. Rather than save file in Directory and save path of that file in DB
you could store the file information in a database to built some extra features like "avoid storing duplicate files", because you are having a faster search in the database! if you search the filesystem always a recursive function call get started

What is the best way of storing last run date-time/ execution date-time for windows service?

I have a windows service that runs every 1 hour. I would like to store the last run date-time so that I can check the value (last run date-time) every time the service runs.
This value is used as one of the parameter for stored procedure used by the service to get data.
Now, my question is what is the best/ideal way of storing this last run date value?
I can think of 3 ways:
Store it in a database table.
Store it in a text or XML file in the application folder (question here is: is it good to create a text
file in application folder and update it every hour?).
Create a section in config file and update it every time service is executed.
Experts, please advise.
If you have a single service that needs to check the last time the process it executes was run to completion, I would store in as a user setting item. If you are thinking that maybe you'll have many services that share this task, putting it a shared location (like a database) would be helpful--although, it should be easy to migrate the data from user setting to a database should you need to use multiple services.
I would avoid a custom XML or data file simply because there's already support for user (run-time) settings in .NET and Visual Studio.
Update:
If you want to use user settings, you can simply double-click the Settings in Solution Explorer (under Properties in a Project) or in the properties for a Project, select the Settings tab. Add a value with a User Scope (probably of type System.DateTime. And if you named LastExecuted it you would use code like the following to update the value:
Properties.Settings.Default.LastExecuted = DateTime.Now;
Properties.Settings.Default.Save();

Batch-creation of Alfresco users

Is it possible to create Alfresco users in a "batch" way?
I mean, creating lots of users with a script or calling an API or something.
Thank you!
There is a module for the Share admin console in the Share-Extras project which allows the creation of users from a CSV file. It can found here: http://code.google.com/p/share-extras/wiki/CreateBulkUsers
The alfresco shell tools project allows the batch creation of Alfresco users:
https://code.google.com/p/alfresco-shell-tools/wiki/UsersAndGroupsFun#Create_a_new_user
It wraps the REST APIs mentioned in the other replies in an easy to use manner.
I think the easiest way to do that is to use the addPerson webscript.
Just create a small application that calls the webscript (it's a normal HTTP POST request) with the user data you want.
http://wiki.alfresco.com/wiki/Repository_RESTful_API_Reference#Add_Person
If you're using Alfresco Team, or a recent nightly build, then you can simply upload a CSV / Excel file of users and have them created for you. (It's in Swift too)
You'll find the link to do this in the admin console, and the webscript that backs this is http://localhost:8080/alfresco/service/api/people/upload (perform a GET to fetch the spreadsheet template, or a POST to upload the users)

Resources