Coldspring 2.0 and Fusebox 5.5 (XML) - coldfusion

My app uses Fusebox 5.5 and Coldspring 1.2. I'm trying to migrate to Coldspring 2.0. In Fusebox_lexicon/coldspring/initialize.cfm there is the following block of code:
// set ColdSpring in this fusebox instance's application space
fb_appendLine('<cfset myFusebox.getApplication().getApplicationData().#fb_.coldspringfactory# = createObject("component", "coldspring.beans.DefaultXmlBeanFactory").init( defaultProperties="#fb_.defaultproperties#" )/>');
fb_.i = 1;
// load all bean definitions
for ( fb_.i = 1; fb_.i lte arraylen( fb_.verbInfo.beans ); fb_.i = fb_.i + 1){
fb_appendLine('<cfset myFusebox.getApplication().getApplicationData().#fb_.coldspringfactory#.loadBeansFromXmlFile( beanDefinitionFile="#fb_.verbInfo.beans[fb_.i]#" ) />');
}
Now I know that coldspring.beans.DefaultXmlBeanFactory has now moved to coldspring.beans.xml.XmlBeanFactory, but the problem is that loadBeansFromXmlFile no longer exists.
Is there an equivalent in version 2.0? Should I be editing this file at all?
thanks

I actually started looking at alternative frameworks, including Coldbox following this. I was initially concerned that CF10 / Coldspring 1.2 would not play nice (the code analyzer throws up some areas of concern), but now I think it may be OK.

Related

Draw.io -- Is there non-minified source?

We are trying to use the latest Draw.io repository, and modify the javascript client side code to change some of its behaviors for an improved UX. But, the only up to date source we can find is here:
https://github.com/jgraph/draw.io/tree/master/war/js
You'll notice that several of the source files are already minified, such as app.min.js
We found an old non-minified version of draw.io from 5 years ago:
https://github.com/vmassol/draw.io
But it looks like it's missing a lot of functionality..
Does anyone have more information about this? Is there a way to get the non-minified source of the up to date version? Just how much functionality is missing from the old version? Or, do we misunderstand something, and the minified files, like app.min.js are just pre-built products from the source that's in the rest of the directories?
Thanks!
The minified and non-minified (NM) sources are both in the project. The NM sources mostly live in the diagramly folder (the old name for draw.io) and the GraphEditor folder.
If you look in the build file, you can see which sources go into which *.min.js files.
The GraphEditor source serve as the base stack under draw.io. It used to be maintained as a cut-down editor, just not any longer.
i managed to run the app from the unminified modifying the index.html as follows:
// Changes paths for local development environment
if (urlParams['dev'] == '1') {
// Used to request grapheditor/mxgraph sources in dev mode
//the line below was: var mxDevUrl = document.location.protocol + '//devhost.jgraph.com/mxgraph2';
var mxDevUrl = document.location.origin + '/mxgraph';
// Used to request draw.io sources in dev mode
//the line below was : var drawDevUrl = document.location.protocol + '//devhost.jgraph.com/drawio/src/main/webapp/';
var drawDevUrl = document.location.origin + '/drawio/src/main/webapp/';
...
//The line below was: var geBasePath = mxDevUrl + '/javascript/examples/grapheditor/www/js';
var geBasePath = drawDevUrl + '/js/mxgraph';
var mxBasePath = mxDevUrl + '/javascript/src';
...
}
To make everything work I had to start an http-server (es. nodejs http-server module) at mxgraph and drawio repos parent.

Sitecore Glass Mapper always null

I am using Sitecore Glass Mapper for a new project I'm setting up.
We are using Sitecore 7.2, latest version of Team Development for Sitecore (TDS) code generation and the latest version of glass.
The code I am trying to execute:
var b = new SitecoreContext();
var c = b.GetCurrentItem<T01_Homepage>();
b is not null. c is null.
var d = b.GetItem<T01_Homepage>("path")
d is null.
I added my assembly in GlassMapperScCustom:
public static IConfigurationLoader[] GlassLoaders(){
var attributes = new AttributeConfigurationLoader(new[] { "Company.Framework.Websites.Corporate", "Company.Framework.Core", "Company.Framework.Common" });
return new IConfigurationLoader[] { attributes };
}
When I look into b.GlassContext.TypeConfigurations all my models are there.
I figured it could be a language issue because the site is in dutch and maybe the wrong language would be resolved incorrectly. This was also not the case.
I disabled WebActivator and added the GlassMapperSc.Start() in my Global.asax Application_Start method.
We are also using Autofac as DI framework. But without it, it still isn't working as you can see above. Also when I create my own custom models without TDS code generation the result of GetCurrentItem<T> is null.
Does anyone have an idea how I can fix this?
Did you check your Sites.config and the default language for this website? There could be a difference between the language which is defined in your Sitecore languages folder and your configuration.
I had a similar problem with one of my projects where I changed the Sitecore.Context.Language to "nl" instead of "nl-NL". The glass mapper will return null, but Sitecore.Context.Database.GetItem will return an object in this case.
Most of the times it is a language issue. The mapper returns a null object when you do not have versions in the current or given language.
What can be confusing is that Sitecore.Context.Database.GetItem returns an object, even if it does not have a version in the current language. Be sure to check that item.Versions has any.
Some things you may try (this didn't fit in the comments field)
1) Confirm that the related fields in the Sitecore Item object contain values (so Sitecore.Context.Item for your "c" var and Sitecore.Context.Database.GetItem("path") for your "d" var)
2) Try to encapsulate the GetItem/GetCurrentItem call in a VersionCountDisabler, like this:
T01_Homepage model = null;
using (new VersionCountDisabler())
{
var context = new SitecoreContext();
model = context.GetItem<T01_Homepage>("path");
}
// Do you have data in model now?
3) Try to encapsulate the same call with a SecurityDisabler. Just to confirm it's not a security issue.
4) If you still don't know what it is, please update your question with some (simplified) code for your model.

How to programmatically update references in sitecore?

I have 2 templates: ArticleItem and ArticlePageItem, the ArticlePageItem has a ReferenceField 'Content.Reference' that links to an ArticleItem. Below is the code to create an article:
Item articlePageItem = articlePageParentItem.Add(articleItem.Name, new TemplateItem(master.GetItem(ConstantString.ArticlePageTemplateID)));
using (new UserSwitcher(Sitecore.Context.User))
{
articlePageItem.Editing.BeginEdit();
articlePageItem.Fields["Content.Reference"].Value = articleItem.ID.ToString();
articlePageItem.Editing.EndEdit();
}
But after I execute the code above, I cannot get the ArticleItem reference through Globals.LinkDatabase.GetReferences(articlePageItem), even though I use Globals.LinkDatabase.UpdateReference(articlePageItem).
Does anyone know how to implement this?
[Update]
Below is our environment:
We have a website based on Sitecore, and we're developing another system aims to simplify the article management. We use .NET 4 & ASP.NET MVC 3 to implement this system, and reference Sitecore.Kernal.dll & Sitecore.Client.dll to our project. But our sitecore version is 6.2 which is incomplatible with .NET 4, so I just copied part of the configurations. I think it maybe dues to the incomplete web.config.
If you are executing the above code you should also consider publishing the item changes.
This can be done by using the following code snippet:
// publish all changed content
Database webDatabase = Sitecore.Configuration.Factory.GetDatabase("web");
PublishOptions publishOptions = new PublishOptions(masterDatabase, webDatabase, PublishMode.Smart, Sitecore.Context.Language, DateTime.Now);
publishOptions.RootItem = vacatureRoot;
publishOptions.Deep = true;
Publisher publisher = new Publisher(publishOptions);
publisher.Publish();
Where 'vacatureRoot' is the root -> in your case articlePageParentItem
After publishing the references should be set automatically and should be retrievable by using the normal way of getting Fields.
It looks like you are using a ReferenceField and therefore your code should look something like this:
ReferenceField rfRef = Sitecore.Context.Item.Fields["Content.Reference"];
if(rfRef != null && rfRef.TargetItem != null)
{
//Your logic here
}
Answer for comment:
I think you could best use the following code fragment ->
Sitecore.Globals.LinkDatabase.UpdateReferences(articlePageItem);
I think this will do what the name says, update the references for this item.
Hope this will work for you!

Not able to initialize org.apache.poi.xslf.usermodel.XMLSlideShow in coldfusion

<cfscript>
filepath = ExpandPath("./1.ppt");
fis = CreateObject( "java", "java.io.FileInputStream" ).init(filepath);
//initialize slideshow object with input stream
src = createObject("java","org.apache.poi.xslf.usermodel.XMLSlideShow").init(fis);
fis.close();
</cfscript>
I am not able to initialize org.apache.poi.xslf.usermodel.XMLSlideShow object in coldfusion.
Getting following error:
Unable to find a constructor for class org.apache.poi.xslf.usermodel.XMLSlideShow that accepts parameters of type ( java.io.FileInputStream )
Please help
I know you said you are using POI 3.8, but the error message says you are using an older version.
As Antony mentioned, ColdFusion 9 is bundled with an older version (POI 3.5) which is what createObject() uses. There was no XMLSlideShow(InputStream) constructor back in version 3.5. Hence the error message.
There are two (2) ways to load a newer version of POI:
Use the JavaLoader to run the newer version in parallel
Replace the existing POI jars in {cf_root}\lib. Then restart the CF server. Note: I have not done this personally, so I do not know if doing so will break other features

Xerces-C: Migration from v2.x to v3.x?

I would like to migrate a project (legacy code which I am not quite familiar with) from Xerces-C v2.x to v3.x.
It turns out that Xerces-C v3 dropped the DOMBuilder class. The migration archive tells me this:
...a number of DOM interfaces (DOMBuilder, DOMWriter, DOMInputSource, etc.) were replaced as part of the the final DOM Level 3 specification conformance work.
That's nice. But is there any guide on how to migrate code that relies on these classes to the new API?
Replacements for removed APIs:
Use XercesDOMParser or DOMLSParser instead of DOMBuilder (more info):
xercesDOMParser->setCreateCommentNodes(true);
Use DOMLSSerializer instead of DOMWriter:
DOMLSSerializer* writer = ((DOMImplementationLS*)impl)->createLSSerializer();
DOMConfiguration* dc = writer->getDomConfig();
dc->setParameter(XMLUni::fgDOMErrorHandler,errorHandler);
dc->setParameter(XMLUni::fgDOMWRTDiscardDefaultContent,true);
Use DOMLSInput instead of DOMInputSource.
See also:
"Xerces-C++ API Reference 3.1.1"
"Xerces-C++ API Reference 2.8.0"