When I click on "update preview", "update preview" show again and again.
Because Real URL is different from URL of Broker DB, the above problem happen.
So, I solve the problem by using ADF.
I refer to the follow pages. the follow pages are very useful for me.
http://jaimesantosalcon.blogspot.jp/2013/10/managing-claims-and-their-scope-in-sdl.html
http://erichuiza.blogspot.jp/2012/07/ambient-data-framework-in-nutshell.html
https://github.com/TridionPractice/tridion-practice/blob/master/AmbientDataFramework/ClaimStore.jsp
At first, to understand adf program, i implement easy program.
- Implement program and build
package com.tridion.tag.common; import java.io.File; import java.io.FileWriter; import java.net.URI; import java.util.Map; import java.util.TreeMap; import com.tridion.ambientdata.AmbientDataException; import com.tridion.ambientdata.claimstore.ClaimStore; import com.tridion.ambientdata.processing.AbstractClaimProcessor; public class AmbientDataFrameworkExtensionHandler extends AbstractClaimProcessor { @Override public void onRequestStart(ClaimStore claimStore) throws AmbientDataException { try { TreeMap<String, Object> claims = new TreeMap<String, Object>(); Map<URI, Object> allClaims = claimStore.getAll(); File file1 = new File("/tmp/log_adf1.txt"); for (URI claimUri : allClaims.keySet()) { claims.put(claimUri.toString(), allClaims.get(claimUri)); } FileWriter filewriter = new FileWriter(file1); filewriter.write("onRequestStart"); } catch (Exception e) { throw new AmbientDataException(e); } } @Override public void onRequestEnd(ClaimStore claimStore) throws AmbientDataException { try { File file = new File("/tmp/log_adf2.txt"); FileWriter filewriter = new FileWriter(file); filewriter.write("onRequestEnd"); } catch (Exception e) { throw new AmbientDataException(e); } } @Override public void onSessionStart(ClaimStore claimStore) throws AmbientDataException { try { File file = new File("/tmp/log_adf3.txt"); FileWriter filewriter = new FileWriter(file); filewriter.write("onRequestEnd"); filewriter.write(claimStore.getAll().size()); } catch (Exception e) { throw new AmbientDataException(e); } } }
create cd_ambient_cartridge_conf.xml (configuration file)
<ClaimDefinitions> <ClaimDefinition Uri="tcd:claim:userid" Scope="SESSION" Description="The user's unique identifier." /> </ClaimDefinitions> <ClaimProcessorDefinitions> <ClaimProcessorDefinition Uri="tcd:claimprocessor:example:userdetails" ImplementationClass="com.tridion.tag.common.AmbientDataFrameworkExtensionHandler" Description="Example"> </ClaimProcessorDefinition> </ClaimProcessorDefinitions>
configure cd_ambient_conf.xml
restart webservice
access the webpage
confirm the result
I confirm that log_adf1.txt and log_adf2.txt are created at tmp directory. but the above files are 0 KB and any error is not outputted. I expect that the files are described as each "onRequestStart", "onRequestEnd".
why the program is not work as expected is my program bad and my understarding wrong?