Moving files in a verity collection - coldfusion

I have a collection of files which have been added to a verity collection. The filename, with complete path, has been used as the key.
I would like to move the location of the files on disk, but I am concerned that I will end up with duplicate entries (when I update the same file, the path to the file will be different, so I'll have an entry for the old file and an entry for the new one).
I wasn't involved with the original application setup, and I don't know much about verity or coldfusion (the rest of the app is in PHP). Can anyone suggest how I can go about running some sort of regex replace on each key in a verity collection, or possibly suggest another approach?

I would recommend to create new collection, adjust to your new specs (at least new path in your case) and swich to it in the application code (replace the collection name in cfindex/cfsearch).
After making sure it works properly you are free to delete the old one.
If you can not create collection for some reason, you can simply purge the collection, switch the path and re-index it.
Please note that you can do all of this directly from the application (maybe temporarily script) using cfcollection tag, and using CF Admin (see Verity Collections in menu) too.

Related

Data Management API get the full folder path of the document

when using https://developer.api.autodesk.com/data/v1/projects/:project_id/folders/:folder_id/search end point, I am receiving both deleted and non deleted documents.
I know there are post stating using included.attributes.hidden would resolve the issue, however I noticed If you delete the parent folder of the document, the document included.attributes.hidden still shows false (not deleted).
I am thinking of work around to get the document full hierarchy of the searched folder then cross check it with the document parents to know if the document is deleted.
Definitely going the recursive approach by calling parent of a parent till i reach the searched folder is not practical.
I need assistance in the following:
1- Is there a way to get the whole hierarchy under the searched folder.
2- Any other suggestion to know if a file is deleted.
After checking with engineer team, I got some comments:
It is as designed the documents/items are still hidden=false when the folder is deleted.
To dump whole hierarchy of folder, you may try with top folder and check subfolder recursively by GET:Folder Contents. Since GET:Folder Contents will tell if a folder is hidden or not, you could skip this folder (accordingly, skip the items inside the folder). By default, hidden items will not be returned. Finally build the folder & items tree.
If you search items by GET:Folder Search API, you would get those un-hidden items, yet its folder has been deleted, as you are experiencing. So you will have to double check if their folders are hidden or not. This means a tedious checking.
So I would suggest you build the tree from the top.

Can I write a file to a linux directory specifying file permissions in cfscript?

I have a function which writes a coldfusion query result as file to the temp directory. It works fine, and saves having to run the query so often.
However, I want to write a git hook to delete these cached files as when we push new code the data may have become stale and so should be replaced. The files are created by the apache user in 644 mode. The git user is in the same group as the apache user, so for the git user to be able to delete the files, I want to either create them in, or subsequently set them to 664 mode.
Initially I added fileSetAccessMode after the objectSave I was using:
objectSave( data, filepath );
fileSetAccessMode( filepath, '664' )
However this didn't seem to have any effect, so tried
fileWrite( filepath, data, '664' );
which also seems to write the file fine, but not set the the permissions.
I note that the Adobe Docs for fileWrite don't specify a parameter for mode, so I guess that's why that doesn't work. I much prefer cfdocs.org in general but I was quite confused by their take on the cfscript versions of cffile, as it wasn't obvious which functions used which parameters.
After some more googling, I found this cflib.org cftag style function which I guess I could borrow and reference in cfscript but I don't really want to have to do that.
What I really want to know is, can I achieve this purely in cfscript or is there a genuine difference in API functionality between script and tag? (I'm pretty sure this is the case in other instances).
Very grateful for any input.
After taking a break and coming back to this, I discovered that I can use
fileSetAccessMode( file, '664' );
In cfscript, and embarrassingly I had it in the wrong place in my code. However, it is still necessary to do that separately having created the file previously because
fileWrite( file, content );
doesn't support the "mode" parameter as in
<cffile action="write" file="file" output="content" mode="664">
having consulted with some wiser members of the community, I have filed this as a bug with Adobe.

linking to cfml code ala jsfiddle

ok so i'm working on a new version of cflive.net and one of the features is to link to code.
I am using jsfiddle.net as my inspiration for the new site.
Now with jsfiddle all the code runs in the client, so it is not a problem for other people to edit it.
But with CFML obviously the files need to be saved on the server first, which means the original file would get overwritten if anyone makes any changes, which is obviously going to be problematic as the original author may not want his files to get edited, so I am looking for some feedback/suggestions on what would be the best way to handle this.
My best idea so far is.
All files are stored in a unique folder using a JsessionID
e.g. anonymous files
/jsessionid/filename.cfm
or user files
/user/jsessionid/filename.cfm
the original author marks the files as editable or not. You must register and be logged in to have this control.
Files created anonymously (not logged in) can be edited as default.
If the file is editable then it can be edited, otherwise it gets duplicated for each new session.
Anonymous sessions get deleted if they have not been access for 90 days.
thoughts?

Coldfusion mapping error

Note: If you wish to use an absolute template path (for example,
template="/mypath/index.cfm") with CFINCLUDE, you must create a
mapping for the path using the ColdFusion Administrator.
I went to the administration page but not sure what to put in here.
I'm pretty new to coldfusion. anyone got any ideas why this would be happening.
CFINCLUDE uses relative paths in relation to the file where the cfinclude is, so if want to include a file in another directory, 1. it has to be inside your wwwroot (or the root directory, or subdirectories) of your site, 2. you can go to other directories by doing ... hope this helps a little bit. If you want to include a file that is outside of your wwwroot, then you'll need to map that directory in Coldfusion Administrator using the same syntax above when you do include it.
To add a mapping, open your coldfusion administrator.
Server Settings > Mappings
There are 2 paths. Logical and Directory.
Logical can be anything you want, and directory is where it maps to.
eg. you might have a folder below your web root which stores email templates mapped as:
logical path: /emails
directory path: /var/www/mycfapp/content/includes/emails
You can <cfinclude template="/emails/forgotPass"> from any cf template and the mapping would get picked up.
You can use the mappings for new object creation too. Lets pretend forgotPass is a cfc.
fp = new emails.forgotPass();
// if you have funky characters in there, eg dash, just quote it.
fp = new "emails.forgot-pass"();
Mappings also work when extending cfcs. With one small exception. No leading slash.
component extends="emails/forgotPass" {
// ...
}
Im pretty sure mappings are detected first, so if you have a folder with the same name it might not get picked up.
In cf9 you can also specify your mappings in your Application.cfc, instead of coldfusion administrator, which affects all applications on your server. eg.
this.mappings["/emails"] = "/var/www/mycfapp/content/includes/emails";
You'll need to tick the Enable Per App Settings option on the cfadmin Settings page.
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0b63c-7fd5.html

Magento - locate specific core files

I am familiar with theming and using template hints in the Magento back office to locate .phtml files.
What I am not really familiar with are the core files such as app/code/core/Mage/Catalog/Model
What I need to do is override a core file like I would a core phtml file by copying it to 'my theme'.
I basically want to amend some labels which appear on the order summary page of the Magento checkout process - domain.com/checkout/cart/
I followed the trail to the phtml files using template hints. Within the app/design/frontend/default/mytheme/template/checkout/cart I found the code
renderTotals(); ?>
Now I managed, by accident, to stumble upon two of the files I wanted to change:
/httpdocs/app/code/local/Mage/Sales/Model/Quote/Address/Total/Grand.php
/httpdocs/app/code/local/Mage/Sales/Model/Quote/Address/Total/Shipping.php
I made local copies of these files (http://www.magentocommerce.com/wiki/how_to/how_to_create_a_local_copy_of_app_code_core_mage) to override the default labels, like I would if I was overriding a template file.
My question is, how can you locate core files which pertain to the 'stuff' you want to change, located in function calls such as renderTotals(); ?> in the phtml files?
Not being able to pinpoint stuff like I can with template hints is slowing me down, and I am struggling to find a solution as I am not up on all the vocab surrounding Magento yet.
Hope this makes sense and thanks in advance!
From the same settings page where you turn on Template Path Hints, also turn on the "Add Block Names to Hints" setting. This will show you PHP class names such as: Mage_Sales_Model_Quote_Address_Total_Grand to which you can deduce the folder path (underscores represent a subfolder, and the last piece represents the file name).
If you're getting a block such as Mage_Sales_Model_Quote_Address_Total_Default then sometimes it just takes a little common sense to see that it's pulling in other files from the same folder (such as Grand.php and Shipping.php). But there are generally only a couple files in the same folder, so this is pretty easy to see.
As Sid Vel said, a good Search Project functionality is helpful. But if you find yourself looking at Abstract.php of some class, often you need to look in a subfolder in that directory with the proper name to find the concrete implementations. But still, it gets you very close to where you need to be.
I always use Dreamweaver's site / directory search function. It will scan through all the files in the Core folder and tell you where the function is from. In your case, I would search for "renderTotals". You need to enable PHTML editing in Dreamweaver.
Most IDE's will allow this kind of search option. In Aptana you can Ctrl + Click on the function to open the file it is coming from. Magento takes ages to index itself on Aptana, due to its sheer size.