create sitecore item as pdf - pdf

Hi i am doing kind of migrating other cms to sitecore now.
So my requirement is to viewing pdf in the respective url..
Existing site url : DOMAIN.COM/pressrelease/one
And this will show PDF content in a browser.
New site expected Url: NEWDOMAIN.COM/pressrelease/one
Similarly on my sitecore content i try to create under root one pressrelease item and its child is one.pdf. But i cant able to view my pdf after this when i gave url like NEWDOMAIN.COM/pressrelease/one.
And need expected behaviour is to open a pdf file in a browser as like media (/-/media/pressrelease/one)items are can able to view.

Create AllowedExtensions.config in App_config/include folder(if it does not exist already) and add the following sitecore configuration.The configuration makes sure that pdfs are allowed via URL.
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<preprocessRequest>
<processor type="Sitecore.Pipelines.PreprocessRequest.FilterUrlExtensions, Sitecore.Kernel">
<param desc="Allowed extensions (comma separated)">aspx, ashx, asmx, xml, txt,pdf,png</param>
<param desc="Blocked extensions (comma separated)">*</param>
<param desc="Blocked extensions that stream files (comma separated)">*</param>
<param desc="Blocked extensions that do not stream files (comma separated)"/>
</processor>
</preprocessRequest>
</pipelines>
</sitecore>
</configuration>

I have solved my case using below solution
First i have created one content item NEWDOMAIN.COM/pressrelease/one.
This item having two fields from my template, like shown below.
Then i have some separate Layout file for this content item, In the Layout i have created the code for displaying pdf.(Also in some Layouts i can able to download file too using this approach.)
if(mediaResult.mediaItem != null)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = mediaResult.mediaItem.MimeType;
HttpContext.Current.Response.AppendHeader("Content-Disposition", string.Format("inline;filename=\"{0}\"", mediaResult.mediaName));
HttpContext.Current.Response.StatusCode = (int)HttpStatusCode.OK;
HttpContext.Current.Response.BufferOutput = true;
// Copy the media stream to the response output stream
mediaResult.mediaItem.GetMediaStream().CopyTo(HttpContext.Current.Response.OutputStream);
// As momma always said: Always remember to flush
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
}

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.

Sitecore 8.1: Custom Search Index not searching through PDF

I have a custom search index that I want to index pdf file content. The master index seems to be indexing pdf files fine and sitecore's built in search functionality searches through the pdf files perfectly fine. I seem to be having an issue on trying to index the PDF field and then search the contents of it.
In my indexConfiguration i add the filed by name
<fieldNames hint="raw:AddFieldByFieldName">
<field fieldName="publication pdf" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
...
</fieldNames>
My results Item contains index field definition
[IndexField("publication pdf")]
public virtual string PDF { get; set; }
However when I create search context and try to find something inside the PDF, i get 0 results.
var query = context.GetQueryable<ResultItem>();
query = query.Where(p => p.PDF.Equals(SearchString));
Any help is greatly appreciated.
I'm guessing your "Publication PDF" field is some kind of reference field to a media library item. Content of the PDF is in fact not content of your current item. This means that you would need to write a custom computed field that would extract that media library item and crawl its content.
If you want to crawl content of a media item, you might want to use some reflector to check the code of Sitecore.ContentSearch.ComputedFields.MediaItemContentExtractor class. It's used by Sitecore to get the content of media items, as defined in Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config:
<field fieldName="_content" type="Sitecore.ContentSearch.ComputedFields.MediaItemContentExtractor,Sitecore.ContentSearch">
<mediaIndexing ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration/mediaIndexing"/>
</field>
You would need to first get media item and then use code copied from this class to get the content of PDF.
BUT
Yeah, there is always but. If the media library item has changed and your item has not changed, your item will not be reindexed automatically. So if you plan to change pdfs (uploading new item and selecting it should be fine), you would need either think about custom code that would execute reindexing of the item which holds reference to your pdf file, or manually reindex your item.

Doxygen: Empty Detail Description

Context - Doxygen tool on C codes to generated RTF documents.
In the documentation of Modules/Groups, we are getting the header "Detailed Description" even if no detail description is provided for some particular module/group.
In generated RTF document this looks ugly. Is it possible to get rid of this empty Detail Description sections?
I tried "ALWAYS_DETAILED_SEC = NO" but it is not working. I cannot do "HIDE_UNDOC_MEMBERS = YES" as the group/module contains members (struct, functions ...) which are documented.
This may be a bit late, however others may be interested (I was).
You can remove the group detailed description completely using the layout file, though if you have a brief description a More... link will still be created (which links to nothing). My solution was the disable brief description for groups and move detailed description to the top of the page (essentially replacing it).
Create a layout file by running the following command dOxygen -l. The creates the default layout file. The section we are interested in is groups, near the bottom:
<!-- Layout definition for a group page -->
<group>
<briefdescription visible="yes"/>
<groupgraph visible="$GROUP_GRAPHS"/>
Now set visible="yes" to visible="no" in the briefdescription field. Near the bottom of the file you will see a <detaileddescription title=""/> Move this to the top, above or below briefdescription. You should now have:
<!-- Layout definition for a group page -->
<group>
<briefdescription visible="no"/>
<detaileddescription title="Description"/>
<groupgraph visible="$GROUP_GRAPHS"/>
Note that I've changed the title to "Description" by filling in the title field. Save the file. Now in your Doxyfile, you need to specify a custom layoutfile. Add the following line (or search for it and fill it in):
LAYOUT_FILE=DoxygenLayout.xml
Assuming your paths are correct etc, you should now have group pages with brief description replaced with the full description.
The reason as to why "Detailed Description" gets generated even if there is no Documentation in the Entities (Modules/Groups, etc..) is because the Doxyfile tag EXTRACT_ALL is set to YES.
By Setting,
EXTRACT_ALL = NO
ALWAYS_DETAILED_SEC = NO
Only the entities documented with Doxygen special comments will get Documented. And only those entities having #details -> Detailed description will be listed under the Detailed Description section.
Unfortunately it doesn't generate if the class has been documented like:
/// <summary>
/// This is..
/// </summary>
class ABC
{
}
remove the 'summary' tags, i.e. it should be like
///
/// This is..
///
class ABC
{
}
search for detailed description(at the begining) in the link below
http://www.star.bnl.gov/public/comp/sofi/doxygen/docblocks.html

Jackrabbit - why does search excerpt contain all node properties concatenated?

When I perform a jackrabbit (version 2.2.9) search and I call get row.getValue("rep:excerpt()") the returned string is just all the properties (excluding jcr: properties) concatenated. How do I control this? eg. If I have a property called "description" containing "bla foo bla" when I search for "foo" I would like to see rep:excerpt() return part of just the description.
I tried creating an index config (and I deleted my repository between tests) in an attempt to control what properties were indexed, to no avail.
Workspace.xml...
<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
<param name="path" value="${wsp.home}/index"/>
<param name="supportHighlighting" value="true"/>
<param name="excerptProviderClass" value="org.apache.jackrabbit.core.query.lucene.DefaultHTMLExcerpt"/>
<param name="indexingConfiguration" value="${wsp.home}/indexing_configuration.xml"/>
</SearchIndex>
indexing_configuration.xml
<?xml version="1.0"?>
<!DOCTYPE configuration SYSTEM "http://jackrabbit.apache.org/dtd/indexing-configuration-1.0.dtd">
<configuration xmlns:nt="http://www.jcp.org/jcr/nt/1.0">
<index-rule nodeType="nt:teneoNode">
<property>description</property>
<property>input</property>
<property>key</property>
<property>comment</property>
</index-rule>
</configuration>
Thanks.
Ted.
You can configure the ExcerptProvider (Javadoc) implementation which is responsible for the rep:excerpt() functionality in the SearchIndex element of you workspace.xml file:
<param name="excerptProviderClass" value="org.apache.jackrabbit.core.query.lucene.DefaultHTMLExcerpt"/>
You might need to plugin in your own implementation for you specific needs.
There is also some - unfortunately rather old - information on the Jackrabbit Wiki.

What are the "allowedTypes" for .rar file (interceptor "fileUpload") in struts2?

<package name="my-default" extends="struts-default" namespace="/">
<interceptors>
<interceptor-stack name="globalInterceptor">
.....
<interceptor-ref name="fileUpload">
<param name="maximumSize">1048576</param>
<param name="allowedTypes">application/x-rar-compressed</param>
</interceptor-ref>
.....
</interceptor-stack>
</interceptors>
....
</struts>
I want to mine type for .rar file in struts2 which interceptor "fileUpload", but when I define "allowedTypes" which "application/x-rar-compressed", It doesn't work.
How can I resolve this?
These are the allowed type values -
image/gif,image/jpeg,image/png,image/bmp,application/msword,text/plain,application/pdf,application/ms-excel,application/vnd.ms-excel,image/bitmap
Rar and zip are not one of them.
The MIME type is set by your browser, and this (specially for a .rar file type, not so popular as others) is not fully previsible - I suspect it can vary from browser to browser. If want to play safe, you can omit the allowedTypes option and do the check programatically in your action. Perhaps you'll want also (not as an alternative, but as an complementary check) to check the file extension in the client side, with Javascript.
try
<param name="allowedExtensions ">rar</param>