SPWebConfigModification - Features over writing each other modification - sharepoint-2010

I am using log4Net with share point 2010. I have a feature which automatically adds the log4net config when my soultion is deployed in Error mode using following code
SPWebService service = SPWebService.ContentService;
service.WebConfigModifications.Clear();
//ADD log4Net config section
service.WebConfigModifications.Add(new SPWebConfigModification()
{
Path = "configuration/configSections",
Name = "section[#name='log4net']",
Sequence = 0,
Owner = CREATE_NAME,
Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode,
Value = string.Format(#"<section name='log4net' type='log4net.Config.Log4NetConfigurationSectionHandler, log4net, Version={0}, Culture=neutral, PublicKeyToken={1}' />", LOG4NET_VERSION, LOG4NET_PUBLIC_KEY_TOKEN)
});
string log4netConfig = #"<log4net>
<appender name='RollingFileAppender' type='log4net.Appender.RollingFileAppender'>
<file value='C:\\logs\\Logger.log' />
<appendToFile value='true' />
<rollingStyle value='Composite' />
<datePattern value='yyyyMMdd' />
<maxSizeRollBackups value='200' />
<maximumFileSize value='50MB' />
<layout type='log4net.Layout.PatternLayout'>
<conversionPattern value='%d [%t] %-5p %c [%x] <%X{auth}> - %m%n' />
</layout>
</appender>
<root>
<level value='ERROR' />
<appender-ref ref='RollingFileAppender' />
</root>
</log4net>";
//add error default config
service.WebConfigModifications.Add(new SPWebConfigModification()
{
Path = "configuration",
Name = "log4net",
Sequence = 0,
Owner = CREATE_NAME,
Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode,
Value = log4netConfig
});
service.Update();
service.ApplyWebConfigModifications();
I wanted to create another feature which over writes Error mode of the log4net and change it to debug, so that the end user does not have to modifiy web config manually.
The problem is when the second feature is activated, it deletes everything added by the first feature.
Is this standard behaviour ?? Any feature that would activate would delete the changes by other feature.
EDIT 2
Steps to replicate
Create 2 feature. both of them should add some different entries in web config.
Activate feature 1 - Feature 1 changes are in web config
Activate feature 2 - Feature 2 changes are in web config but feature 1
changes are gone
Deactivate both the features
Activate feature 2 - Feature 2 changes are in web config
Activate feature 1 - Feature 1 changes are in web config but feature
2 changes are gone

The reason why the first web configuration is removed is because of the code block:
service.WebConfigModifications.Clear();
Basically you're saying that you will be clearing all other configurations set in your web config prior to adding the items in your feature. Removing the said code block should fix your issue.
If you need to do some other things when activating or deactivating a feature try using Feature Receivers. A good example to start with web configurations and feature receivers can be found here.
Also to give you more idea on the code block above is giving you problems you can check out the problem another guy which had the similar problem here.

if I understand this correctly, what's happening is you add a webconfigmodification, this isn't technically "added" yet as it is hasn't been implemented just yet. When you created the 2nd modification, it overwrites the first modification you created, which in turns, erases the first modification that was made, and this was the one that was applied.

Related

RTI DDS creating own data types

I am working on a .Net example where I define my own data type using RTI Connext DDS.
Instead of creating the application from the beginning, I got help from the source code of the hello_world_xml_dynamic example in rti_workspace directory. I have made several changes to the USER_QOS_PROFILES.xml file to create my own data type and changes its name to MY_PROFILES.xml
But when I compile the application and run it from the command line, I get the following error:
DDS_DomainParticipantFactory_create_participant_from_config_w_paramsI:ERROR: Profile library 'MyParticipantLibrary::PublicationParticipant' not found
! Unable to create DDS domain participant
The line of code that catching the error:
if (this.participant == null)
{
this.participant = DDS.DomainParticipantFactory.get_instance().
create_participant_from_config(
"MyParticipantLibrary::PublicationParticipant");
if (this.participant == null)
{
Console.Error.WriteLine("! Unable to create DDS domain participant");
return;
}
}
this is the configuration file MY_PROFILES.xml :
<!--
RTI Data Distribution Service Deployment
-->
<dds xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://community.rti.com/schema/6.0.1/rti_dds_profiles.xsd">
<!-- Qos Library -->
<qos_library name="qosLibrary">
<qos_profile name="DefaultProfile">
</qos_profile>
</qos_library>
<!-- types -->
<types>
<struct name="FlightData">
<member name="Latitude" type="double"/>
<member name="Longitude" type="double"/>
<member name="Altitude" type="double"/>
</struct>
</types>
<!-- Domain Library -->
<domain_library name="MyDomainLibrary" >
<domain name="FlightDataDomain" domain_id="0">
<register_type name="FlightDataType"
type_ref="FlightData" />
<topic name="FlightDataTopic"
register_type_ref="FlightDataType">
<topic_qos name="FlightData_qos"
base_name="qosLibrary::DefaultProfile"/>
</topic>
</domain>
</domain_library>
<!-- Participant library -->
<domain_participant_library name="MyParticipantLibrary">
<domain_participant name="PublicationParticipant"
domain_ref="MyDomainLibrary::FlightDataDomain">
<publisher name="MyPublisher">
<data_writer name="FlightDataWriter"
topic_ref="FlightDataTopic"/>
</publisher>
</domain_participant>
<domain_participant name="SubscriptionParticipant"
domain_ref="MyDomainLibrary::FlightDataDomain">
<subscriber name="MySubscriber">
<data_reader name="FlightDataReader"
topic_ref="FlightDataTopic">
<datareader_qos name="FlightData_reader_qos"
base_name="qosLibrary::DefaultProfile"/>
</data_reader>
</subscriber>
</domain_participant>
</domain_participant_library>
</dds>
where am i making a mistake?
Your XML file looks correct. From the 'not found' error message, it seems that you may not have taken the right steps to instruct your application to load that profiles-file MY_PROFILES.xml to actually learn about your desired Participant. You can easily verify that this is the case by introducing an error in your XML file (for example by incorrectly renaming one tag) and rerun your application. If it does not complain about the syntax or schema of the XML, then your file did not get loaded and this hypothesis is correct.
If that turns out to be your problem indeed, then you have several options to fix that. They are listed in the User's Manual section 18.5 How to Load XML-Specified QoS Settings.

IFilter with Custom properties

I'm developing a custom filter to my file format. Everything works fine when I use any of system keys from <propkey.h> like PKEY_Search_Contents.
But now I need to have my custom properties to register and use with Windows Search. Imagine:
"SELECT * FROM SystemIndex WHERE scope ='file:C:/' AND Publisher.Item.CustomProperty LIKE '%Test%'"
I saw about Property Handlers and already tested. I used the RecipePropertyHandler project from Windows 7 SDK Samples. And when I searched with this code:
// get a property store for the mp3 file
IPropertyStore* store = NULL;
HRESULT hr = SHGetPropertyStoreFromParsingName(L"SomePath",
NULL, GPS_DEFAULT, __uuidof(IPropertyStore), (void**)&store);
hr = HRESULT_FROM_WIN32(GetLastError());
PROPVARIANT variant;
store->GetValue(PKEY_Microsoft_SampleRecipe_Difficulty, &variant);
//// very important undocumented method
store->Release();
CoUninitialize();
I receive the correct answer.
But I don't understand how to union IFilter with IPropertyStore to create my custom properties. To start my IFilter, I used the example from Windows 7 SDK Samples. I'm doing something like:
chunkValue.SetTextValue(PKEY_SearchContents, filtered.c_str(),CHUNK_TEXT, 1046, 0, 0, CHUNK_EOS);
I didn't found the link anymore anymore but I read a quote of msdn about you can't implement IFilter AND IPropertyStore together. It's that true? Talking in other words, I can't create a custom property?
I saw all links from msdn, like link, link2 or any other.
I can do separate things but I don't know how to union both.
Any ideia how to implement?
EDIT
Im trying yet implement the PropertyHandler. My .propdesc file have this content:
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schemas.microsoft.com/windows/2006/propertydescription"
schemaVersion="1.0">
<propertyDescriptionList publisher="Microsoft" product="SampleRecipe">
<propertyDescription name="Microsoft.SampleRecipe.Difficulty" formatID="{1794C9FE-74A9-497f-9C69-B31F03CE7EF9}" propID="100">
<description>This property indicates the preparation difficulty of a recipe.</description>
<searchInfo inInvertedIndex="true" isColumn="true" />
<typeInfo type="String" multipleValues="false" isViewable="true" />
<labelInfo label="Recipe difficulty" invitationText="Specify recipe difficulty" />
<displayInfo displayType="Enumerated" >
<editControl control="DropList"/>
<enumeratedList>
<enum value="Easy" text="Easy" />
<enum value="Medium" text="Medium" />
<enum value="Hard" text="Hard" />
</enumeratedList>
</displayInfo>
</propertyDescription>
<propertyDescription name="Microsoft.SampleRecipe.Keywords" formatID="{16D19FCB-7654-48AB-8057-DF8E51CC0755}" propID="100">
<description>This property indicates the preparation difficulty of a recipe.</description>
<searchInfo inInvertedIndex="true" isColumn="True"/>
<typeInfo type="String" multipleValues="true" isViewable="true" />
<labelInfo label="Recipe Keywords" invitationText="Specify recipe keyword" />
</propertyDescription>
</propertyDescriptionList>
</schema>
On Windows Properties:
I receive all informations from file... but when I try to search with Windows Search like:
SELECT Microsoft.SampleRecipe.Keywords FROM SystemIndex
Where directory='somedirectory'
I receive all lines empty... Any ideias why?
EDIT
I can see my properties on PropSchema:
I can use my Microsoft.SampleRecipe.DifficultyV2 on my WSSQL Query like:
SELECT Microsoft.SampleRecipe.KeywordsV2 FROM SystemIndex WHERE directory='C:\users\step\documents\rvffilter\'
But all the contents are empty

JSF2 custom component, parameter autocompletion with a local file path

My First Question, after years, thank you all and stackoverflow ;-)
I code a new Component for JSF2 and use it to include other templates.
It works perfectly for me.
<cc:interface>
<cc:attribute name="src" type="java.lang.String" required="true"/>
<cc:attribute name="addOption" type="java.util.List"/>
</cc:interface>
<cc:implementation>
<cc:insertChildren />
<ui:include src="#{BeanAnything.convert(cc.attrs.src, cc.attrs.addOption)}" />
</cc:implementation>
But i cant complete the Parameter src via auto completion in intellij or netbeans with "strg + space" or whatever other will use.
It should be used like the ui:include on src parameter.
Any Ideas ?
That's what I want to achieve only with my own componente gg:include
See Example

Obtain Web.config log4net section parameter

I have an application which uses log4net for logging messages. In the web.config there is a section which looks like this:
<log4net>
<appender name="smth" type="smthType">
<file value="name.log" />
</appender>
</log4net>
My question is: how can I get the value name.log from this section?
I tried this:
Dim section = ConfigurationManager.GetSection("log4net")
but since the value is in the appender section, I am not sure how to get it.
Any help would be greatly appreciated
I believe that, instead of reading from web.config, you should use the log4net API, for example:
Dim appender as IAppender = LogManager.GetRepository().GetAppenders()[0];

Logback: One file with maximum file size

my system support team needs one simple log-file, with a maximum size of 10MB. Older log-lines can be deleted when the file reaches 10MB. So roll out the oldest lines.
What is a good appender for this?
I have one appender, but this still created a second file, and then starts again with an empty new file. This is not what my support team wants.
Help is appreciated.
<configuration>
<appender name="TEST" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/test.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>${LOG_HOME}/test.%i.log</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>1</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>10MB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%date %-5level [%thread] - %mdc{loginName} - [%logger]- %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="FILE" />
</root>
</configuration>
Keeping everything in a single file and constantly adding the most recent while deleting the oldest lines is going to perform really really poorly. I suspect that logback can't be made to do this.
What I suggest is you use the regular size based policy, configure it to stay inside your 10MB limit overall, then just concatenate the files when you grab them.