How can I search and replace wsdlLocation value of reference property in a soa config file - soa

I am trying to replace the ui:wsdlLocation value of the reference property in the composite.xml by using the config file.
This is the snippet from composite.xml:
<reference name="xyz"
ui:wsdlLocation="http://www.example1.com/xyz/xyz.wsdl">
<interface.wsdl interface="http://xmlns.oracle.com/MIME_jws/xyz/xyz#wsdl.interface(xyz)"/>
</reference>
I tried replacing the value in reference section of the config file as follows:
<reference name="xyz">
<searchReplace>
<search>www.example1.com</search>
<replace>www.example2.com</replace>
</searchReplace>
</reference>
But when I am trying the validate config plan option, it says
Cannot use this deployment plan file. Schema validation error in File = .... at Line = 67 Column = 24:Element 'searchReplace' not expected.
Can anyone please tell me the right way to do this?

I suggest you use a deployment plan.xml to replace any end point server or URLs from composite. The replace activity used in deployment plan can override the design time URL and hence can point to a correct one.
Hope this helps.
Thanks,
M S

Related

Accessing custom project flavor property stored in .csproj file

OK, so I've managed to create a custom project flavor with a custom property page. It all works and the values are being saved to the .csproj file like such:
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{880389B4-B814-4796-844B-F0E1678C31D1}" Configuration="Debug|Any CPU">
<ServiceLibraryProjectFlavorCfg>
<BooleanProperty>True</BooleanProperty>
</ServiceLibraryProjectFlavorCfg>
</FlavorProperties>
<FlavorProperties GUID="{880389B4-B814-4796-844B-F0E1678C31D1}" Configuration="Release|Any CPU">
<ServiceLibraryProjectFlavorCfg />
</FlavorProperties>
</VisualStudio>
What I cant seem to figure out is how to access this custom property from, say, a menu item callback in my package. I can get the project that the selected item in the solution explorer which was right clicked belongs to, but I'm stuck after that...
Any help will be appreciated
Thanx
Hein
OK, I figured it out.
As part of creating a custom project flavor, you inherit from FlavoredProjectBase and implement the IVsProjectFlavorCfgProvider interface.
the IVsProjectFlavorCfgProvider has one implementable method
int CreateProjectFlavorCfg(IVsCfg pBaseProjectCfg, out IVsProjectFlavorCfg ppFlavorCfg)
So here I implemented a static mapping between my custom IVsProjectFlavorCfg and the specified IVsCfg
Already having a EnvDTE.Project reference, I could then use the following to get a IVsCfg reference:
IVsHierarchy hierarchy1 = null;
var sol = Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution;
sol.GetProjectOfUniqueName(project.UniqueName, out hierarchy1);
IVsSolutionBuildManager bm = Package.GetGlobalService(typeof(IVsSolutionBuildManager)) as IVsSolutionBuildManager;
IVsProjectCfg[] cfgs = new IVsProjectCfg[1];
bm.FindActiveProjectCfg(IntPtr.Zero, IntPtr.Zero, hierarchy1, cfgs);
IVsCfg cfg = cfgs[0] as IVsCfg;
I could then use the IVsCfg reference to look up my custom configuration provider.
If you can access the project node instance (and if your project system is based on MPF), you can just use the GetProjectProperty method of the ProjectNode class. It obtains a ProjectPropertyInstance and returns its evaluated value, or null if the property does not exist.

Override Alfresco pickerresults.lib.ftl

I've found a bug in pickerresults.lib.ftl that i have already reported
Briefly: if the user does not have the permission on a file parent, the line
<#if row.item.parent??>"parentName": "${row.item.parent.name!""}",
will fail, failing the entire script (and the user can't see any file)
So, waiting for the bug being resolved i need to patch this. I'd like to override the macro "pickerResultsJSON" defined in the file removong the line or putting a string value in place of "${row.item.parent.name!""}" that cause the exception
I have no idea of how to redefine the macro and where to place the file inside my amp. Can someone help me?
UPDATE
I'm using the Alfresck SDK 2.0 and my project structure is:
I've tryed to put a file "custom-pickerresults.lib.ftl" with the following content (as suggested by sev) but it does not seem to be the right position. Or should i "register" it in some way?
<#macro pickerResultsJSON results>
<#-- new code here -->
</#macro>
<#global pickerResultsJSON = pickerResultsJSON />
Since macros are just variables, you might be able to do something like this:
<#macro pickerResultsJSON>
<#-- new code here -->
</#macro>
<#global pickerResultsJSON = pickerResultsJSON />
As to where you would put that... you could put it in any file that is included globally on your project. It might require a little trial and error since I'm not sure what your project structure is.
Many thanks to sev, he pointed me the right way.
I realized that pickerresults.lib.ftl is used by the webservice pickerchildren.get.desc.xml and pickerchildren.post.desc.xmlso, the solution is to copy the web service definition and files along with the library in
/alfresco-myamp-repo/src/main/amp/config/alfresco/extension/templates/webscripts/com/my/repository/forms/
(repository/forms/ just becouse the original files are inside config/alfresco/templates/webscripts/org/alfresco/repository/forms/ but any other folder under /alfresco-myamp-repo/src/main/amp/config/alfresco/extension shuld do)
and change the library like this:
...
"type": "${row.item.typeShort}",
"parentType": "${row.item.parentTypeShort!""}",
<#-- from here -->
<#attempt>
<#if row.item.parent??>"parentName": "${row.item.parent.name!""}",</#if>
<#recover>
"parentName": "<unknown>",
</#attempt>
<#-- to here -->
"isContainer": ${row.item.isContainer?string},
<#if row.container??>"container": "${row.container!""}",</#if>
...
This way even if the user has not the permissions to read the parent's name the template can complete without errors (i don't know if the value "unknown" in place of the parent name can cause any troubles, but i did not notice nothing right now)

Insert DateTime.Now to a Web.Config during publish/deploy

I want to have a date when an application was deployed/published in my Web.Config.
Is there a way to achieve that with web.config transformations?
With xdt:Transform="Replace" I can replace any node with predefined value, but is there a way to use some custom function to calculate that value (like DateTime.Now)?
I don't think you can do this with the config transforms (although I'm not 100% certain).
I would suggest using the MSBuild Extension Pack which contains a DateAndTime task to get the current Date and a Detokenise task to perform token replacement on a file.
You could then either:
edit your website csproj file remove the comments around the AfterBuild target, and place your tasks there
write a separate MSBuild script and run that after your site builds.
Hope that helps.

File transformation, is it possible to add autoincrement to a setting

In our automatic build we use MSBuild in combination with web.config transformation to create an acceptance config and a production config.
We have added attributes to change config settings
for example to change the cdn url's.
<add key="cdn1url" value="http://cdn.acceptance.oursite.com/"
xdt:Transform="SetAttributes"
xdt:Locator="Match(key)" />
Does anybody know if it is possible to add an autoincrement attribute? We want to add +1 to the version attribute (for css/img/js caching) on every production build.
An other option could be the Teamcity build number, but I am not sure if that is possible
You already have the Current or even Next Version number as msbuild property value - see 3
You do not have it -> see PS at the bottom and then back to 3
You can do it using FileUpdate task by providing a regexp and replacement text with a new version number:
<FileUpdate
Files="#(FilesToUpdate)"
Regex="regex here"
ReplacementText="$(NextVersionNumber)" />
PS: By using RegexMatch task you can extract current version and then by incrementing it you'll get a value for the $(NextVersionNumber) proeprty.

ASP.NET - show application build date/info at the bottom of the screen

I have a asp.net web application which has a number of versions deployed on different customer servers inside their networks. One practice that we have is to have clients email screenshots when they have issues.
In the old asp.net 1.1 days, we could grab details of the build DLL, using reflection, and show info about the build date and numbering on the screen in a subtle location.
With .NET 2.0 and higher, the build model changed, and this mechanism no longer works. I have heard of different build systems out there, but I'm really looking for the simplest way, on the 3.5 framework, to do what this functionality did on framework 1.1.
Every time a build is performed, update the build date/time, and somehow update the build number
Be able to see the build timestamp and number, to display on the screen
be as simple to implement as possible
I chose to just use the date of the executing assembly.
The way I publish the files, this works fine.
lblVersion.Text = String.Format("Version: {0}<br>Dated: {1}",
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(),
System.IO.File.GetLastWriteTime(System.Reflection.Assembly.GetExecutingAssembly().Location).ToShortDateString());
We are using .Net 2.0 and pull the version information out of the assembly. Perhaps not ideal, but we use the description to store the build date.
Assembly assembly = Assembly.GetExecutingAssembly();
string version = assembly.GetName().Version.ToString();
string buildDate = ((AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(
assembly, typeof(AssemblyDescriptionAttribute))).Description;
The build process uses asminfo nant task to generate the AssemblyInfo.cs file that contains this information.
<asminfo output="Properties\AssemblyInfo.cs" language="CSharp">
<imports>
<import namespace="System" />
<import namespace="System.Reflection" />
<import namespace="System.Runtime.CompilerServices" />
<import namespace="System.Runtime.InteropServices" />
</imports>
<attributes>
<attribute type="AssemblyVersionAttribute" value="${assembly.version}" />
<attribute type="AssemblyInformationalVersionAttribute" value="${assembly.version}" />
<attribute type="AssemblyDescriptionAttribute" value="${datetime::now()}" />
...
</attributes>
</asminfo>
I'm using .NET 2.0 and 3.5 and it is able to set both the build number and build date. While the help panel says that if yet let .NET set it, it will use a random number for the revision, that isn't true, it actually puts date/time info that can be easily extracted, which is confirmed by the online docs:
http://msdn.microsoft.com/en-us/library/system.reflection.assemblyversionattribute.assemblyversionattribute.aspx
See this blog:
http://dotnetfreak.co.uk/blog/archive/2004/07/08/determining-the-build-date-of-an-assembly.aspx?CommentPosted=true#commentmessage
I want to set the build version myself but still want the automatic date/time stamp so I use something like this for the
AssemblyVersion("1.0.*")
Here is a sample function to extract the build date/time
private System.DateTime BuildDate()
{
//This ONLY works if the assembly was built using VS.NET and the assembly version attribute is set to something like the below. The asterisk (*) is the important part, as if present, VS.NET generates both the build and revision numbers automatically.
//<Assembly: AssemblyVersion("1.0.*")>
//Note for app the version is set by opening the 'My Project' file and clicking on the 'assembly information' button.
//An alternative method is to simply read the last time the file was written, using something similar to:
//Return System.IO.File.GetLastWriteTime(System.Reflection.Assembly.GetExecutingAssembly.Location)
//Build dates start from 01/01/2000
System.DateTime result = DateTime.Parse("1/1/2000");
//Retrieve the version information from the assembly from which this code is being executed
System.Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
//Add the number of days (build)
result = result.AddDays(version.Build);
//Add the number of seconds since midnight (revision) multiplied by 2
result = result.AddSeconds(version.Revision * 2);
//If we're currently in daylight saving time add an extra hour
if (TimeZone.IsDaylightSavingTime(System.DateTime.Now, TimeZone.CurrentTimeZone.GetDaylightChanges(System.DateTime.Now.Year)))
{
result = result.AddHours(1);
}
return result;
}
You can get the Assembly Build date through reflection, check this examples:
Determining Build Date the hard way
Determining the Build Date of an Assembly

Resources