Moving content from one content store to another in Alfresco - alfresco

I have two content store defined in content-store-selector-context.xml file .
First one is default content store and another content store in different physical location(storeB) .
Once in month i need to move files from default conent store to into storeB .
I am planning to use scheduler which will invoke a script . script should move files from default to storeB. (PS:-Not copying)
Both content store is viewable from same server.
I was using following script , but this copy the file to storeB but not removing from default content store . Can i know anything wrong in this script or please suggest different approach if any
var logFile = space.childByNamePath("alf docs1.txt");
logFile.addAspect("cm:storeSelector");
logFile.properties['cm:storeName'] = "storeB";
logFile.save();

Related

Alfresco contentstore selection

This is regarding a alfresco multiple content store .
I believe , we can create multiple contentstore location , other than default one. ($ALF_DATA/contentstore/2019) . In case if i have multiple contentsore defined using config file(‘content-store-selector-context.xml’ ), Is there a way to specify or select contentstore while uploading files to alfresco . for ex – if i have following config ,
D:/storeB
How can i specify document to be uploaded to [D:/storeB/2019 ] location , instead of default location ($ALF_DATA/contentstore/2019)
Thanks
RTFM? Documentation Using the new content store states, you need to add the aspect cm:storeSelector and set the property cm:storeName
This could be done by Skript, rule or extension.
If you have Enterprise version, you have that OOTB.
https://docs.alfresco.com/5.2/concepts/store-manage-content.html
If you're on community, I'd suggest using https://github.com/Acosix/alfresco-simple-content-stores.

Dynamically Update Manifest file based on image uploads in SilverStripe admin

I'm new to HTML5's application cache, but am familiar with the basics of it. I'm working on a cache manifest file for a SilverStripe site that needs to be dynamically updated whenever the content manager uploads a new image. I understand that the images will be appended to the Manifest function below using a loop, but the part that I find to be a challenge is updating the date and version number every time. Would I need to have the date and version listed as variables? Or is that not possible considering the setup of the Manifest function?
public function Manifest() {
$static = <<<EOT
CACHE MANIFEST
# 2016-03-17 v6.0.0
[manifest content]
EOT;
//Append any new image file that gets uploaded
$static = $static . "\n" . "/test.html";
$this->response->addHeader("Content-type", "text/cache-manifest");
return $static;
}
When you change cached by manifest file, the manifest content does not change. However you must change the content to trigger update in a browser. In this case you update a comment. This comment can contain anything. The date and version is common practice, because they reflect the change. So all you need it to get most recent change date from File.LastEdited field.

How to Track deleted file in alfresco

I do not know this question is common or not.
I want to track record of those files that is deleted in trashcan.I just read that after deletion it will go in content-store.Deleted so from where how can i get the details of deleted files.
You can use the searchservice to find all the nodes in the trashcan. These exists in archive://SpacesStore, just like you would in workspaces://SpacesStore .
String query = "#cm\\:title:mytitle.doc";
searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_FTS, )
If you delete a file, it will go into trashcan and into archive://SpacesStore . It will remain there forever, unless you (or the optional trashcan cleaner module) empty it out of the trashcan. After you empty the trashcan, it will still remain in archive://SpacesStore for 14 days. After those 14 days it will be removed from the DB and the content will be moved to contentstore.deleted
Nodes that have been emptied out of the trashcan, have all references(metadata) in the DB deleted, so they can no longer be accessed programatically. The only thing that remains is the raw content in contentstore.deleted.
A good explanation of alfresco content deletion is here:
http://blyx.com/2014/08/18/understanding-alfresco-content-deletion/
Phase 2- Any user or admin (or trashcan cleaner) empties the trashcan:
That means the content is marked as an “orphan” and after a
pre-determined amount of time elapses, the orphaned content item ris
moved from the alf_data/contentstore directory to
alf_data/contentstore.deleted directory. Internally at DB level a
timestamp (unix format) is added to alf_content_url.orphan_time field
where an internal process called contentStoreCleanerJobDetail will
check how many long the content has been orphaned.,f it is more than
14 days old, (system.content.orphanProtectDays option) .bin file is
moved to contentstore.deleted. Finally, another process will purge all
of its references in the database by running
nodeServiceCleanupJobDetail and once the index knows the node has bean
removed, the indexes will be purged as well.

Drupal - Get image from url and import it into node

Im writing a module for drupal, Im trying to create a node from my module, everything is fine , I only have 1 problem with creating an image , The image exist on different server, so I want to grab the page and insert it , I install module http://drupal.org/project/filefield_sources , which has remote option , I search in the module code , I could not find the function that he used for this process, module work very nice from interface , but how i make it do the job from code ? which function should i call and what parameter should i pass .
I'm over Drupal 6.
Hopefully you're using Drupal 7...
The system_retrieve_file() function will download a file from a remote source, copy it from temp to a specified destination and optionally save it to the file_managed table if you want it to be managed.
$managed = TRUE; // Whether or not to create a Drupal file record
$path = system_retrieve_file($url, 'public://my_files/', $managed);
If you want to get the file object immediately after you've done this, the following is the only way I've found so far:
$file = file_load(db_query('SELECT MAX(fid) FROM {file_managed}')->fetchField());
get fid using $path->fid. no need to mysql

Converting RTF to PDF from System

I've createad a rule to transform any file to PDF and copy this one to another folder.
So i can add a file named: "test.rtf" and then the rule create a test.pdf into folder "PDF"..
Till here its ok. If i add a file through alfresco (add content button) it works perfectly...
By the way, on the system that i've developed when i try to add a file then i get my file .rtf correctly in the folder, but the pdf file converted and copied goes without any content...
If i send a rtf file with a table with 10 rows and into the rows i right "testing" then the pdf created goes with the table, and with 10 empty rows...
Someone knows the reason for that?
Im not sure, but maybe when i send the file by the system alfresco starts to convert and copy before completing to create the rtf... someone already got some problem like this one?
The problem you're getting in is that Alfresco first creates an empty file with all the meta-data and then updates the file with the associated content.
So you can do 2 things:
1: create a rule which is triggered on update, instead on create/inbound
2: create a rule which triggers a Javascript file, which will do the transformation and will check on the content size.
Hence it's better to create a rule which checks the content on size.
Create a JavaScript file in Data Dictionary/Scripts.
Check the JavaScript API
Something like this:
if (document != null && document.size > 0){
document.transformDocument("application/rtf");
}

Resources