Wednesday, 10 April 2019

Connect Tridion sites Core service with Java


Introduction

Coreservice is used to perform operation on cms i.e. connect to cms, create content, create workflow etc.
To work with Coreservice with java we have to setup code which consume coreservice as wsdl soap client.

Repository

To check reference implementation please checkout
Here we have used maven to build application

Implementation 

Setup module to generate library from soap url.
1.          Setup build information on pom
<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>2.4.1</version>
            <executions>
                <execution>
                    <id>wsdltoJava</id>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <wsdlUrls>
        <wsdlUrl>http://localhost:91/webservices/CoreService201701.svc?wsdl</wsdlUrl>
                        </wsdlUrls>
                        <vmArgs>
                            <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
                        </vmArgs>
                        <keep>true</keep>
                        <sourceDestDir>src/main/resources/wsdl</sourceDestDir>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
2.         Run the maven command “mvn clean install”.
3.         You will have jar file generated on .m2 repository directory.

Once the library is generated add them to dependency and build path of application where we need to write coreservice operations
Sample code to connect application with Tridion coreservice.
QName qName = new QName(Q_NAME_URI, Q_NAME_LOCAL_PART);

Service service = CoreService201701.create(new URL(CMS_WSDL_URL), qName);

ICoreService iCoreService = service.getPort(ICoreService.class);

Authenticator myAuth = new Authenticator() {

    @Override

    protected PasswordAuthentication getPasswordAuthentication() {

        return new PasswordAuthentication(username, password.toCharArray());

    }

};

Authenticator.setDefault(myAuth);

Where parameters are
private static final String CMS_WSDL_URL = getPropertyValue("wsdlUrl");

private static final String Q_NAME_URI = getPropertyValue("qNameUri");

private static final String Q_NAME_LOCAL_PART = getPropertyValue("qNameLocalPart");

And parameters configured on application.properties are
wsdlUrl=http://localhost:91/webservices/CoreService201701.svc?wsdl

qNameUri=http://www.sdltridion.com/ContentManager/CoreService

qNameLocalPart=CoreService201701

After connection have made then we will have iCoreService object which will help us to perform coreservice operations

For example to get CMS version
iCoreService.getApiVersion();


Please go through repository for example.

Monday, 4 March 2019

Custom URL extension with Tridion Sites

Custom URL extension with Tridion Sites

Introduction

Custom URL extension is a feature/functionality which helps Content Editor to select data from 3rd party service.
There are two Steps to Implement Custom URL.
1.       Tridion Sites Configuration - Define URL in CM Schema, which serves the data for Component field specified.
2.       Configure Service as Web Application - Host Web application on CM Web Application as virtual directory.

Tridion Sites Configuration

Custom URL is configured on Schema level i.e.
For example we have created Test Schema – TestTeaser
a.       Tridion Sites CM provide functionality of Custom URL on Schema 

b.      Set the value of custom URL, See below How to create web page which serves data to CM fields.
c.       For Example /CustomUrlExtension/Index.html

d.      Once value is set on schema then create component then you would see hyper link on field for which we have setup custom URL

e.       Then once you click on this you would see webpage on popup

f.        Then select any value from list

g.       Once submit value will be appeared on CM field and pop up is closed.

 

Setup Web Page/Web Application which serves data for headline

1.       To create Web Page which server data for CM field needs to have following PopupInit.js on page included
<script type="text/javascript" language="javascript" src="/WebUI/Core/Controls/Popup/PopupInit.js"></script>
2.       Here we are using https://jsonplaceholder.typicode.com/posts for to get some example data.
3.       Sample web page view


Here is sample code for web page which will appear as pop up

<html>
<
head>
    <
style>
        ::
-webkit-scrollbar {
           
width: 12px;
        }

        ::
-webkit-scrollbar-track {
           
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
           
border-radius: 10px;
        }

        ::
-webkit-scrollbar-thumb {
           
border-radius: 10px;
           
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5);
        }
    </
style>
    <
script type="text/javascript" language="javascript" src="/WebUI/Core/Controls/Popup/PopupInit.js"></script>
</
head>
<
body onload="loadData()">
<
div class="scrolling-data" style="margin-left: 40%;">
    <
form name="myForm">
        <
div id="title" style="font-size: 50;">Select the Post</div>
        <
br>
        <
div id="posts" style="height: 75vh;width: 70vh;overflow: scroll;overflow-x: hidden;">
        </
div>
    </
form>
    <
button type="button" onclick="checkeSelectedValue()">Submit</button>
</
div>
</
body>
<
script>
   
var data = '';

   
function loadData() {
       
var xhttp = new XMLHttpRequest();
       
xhttp.onreadystatechange = function () {
           
if (this.readyState == 4 && this.status == 200) {
               
data = this.responseText;
               
var jsonData = JSON.parse(data);
               
jsonData.forEach(function (post) {
                   
var d1 = document.getElementById('posts');
                   
d1.insertAdjacentHTML('beforeend', '<input type="radio" name="post" id="' + post.id + '" value="' + post.title + '">' + post.title + '</input><br>');
                });
            }
        };
       
xhttp.open("GET", "https://jsonplaceholder.typicode.com/posts", true);
       
xhttp.send();
    }

   
function checkeSelectedValue() {

       
var post = document.querySelector('input[name = "post"]:checked').value;
       
var fields = window.dialogArguments.getFields();
       
if (fields && fields.length > 0) {
           
fields[0].setValues([post]);
        }
       
window.close();

    }
</
script>
</
html>




On Submit web page will set the value to CM field and the close current window.

Wednesday, 17 October 2018

मुस्कुराते चले गए 😊

मुकाम जिंदगी में कई बनाते चले गए।
लेकर हँसी चेहरे पर सारे गम भूलाते चले गए।

रोका कई लकीरो ने इस दुनिया की हमको।
पर बढ़ते गए उन लकीरो को मिटाते चले गए।

दिल में लिए हम उम्मीदों का फलसफा,
उम्मीदों पर हम घर अपना बनाते चले गए।

राह पर मिले लोगो से हमको कई जखम,
पर उनपर हम प्यार की मरहम लगाते चले गए।

किसी ने हमको डांटा, किसी ने दुलारा,
दिल की खुशी, चेहरे पे मुस्कुराते चले गए।

जब पड़ी अपनो पर धूप की कोई कहर,
हम रास्तो पे पेड़ो की छांव बिछाते चले गए।

दिल किया छू लू तारों की ये चमक,
रातों को अपना दिन और दिनों को रात बनाते चले गए।

मुकाम जिंदगी में कई बनाते चले गए।
लेकर हँसी चेहरे पर सारे गम भूलाते चले गए।

Tuesday, 9 October 2018

चल जरा तू

चल जरा तू बढ़ जरा तू, उचाईयो पे चढ़ जरा तू,
आसमाँ को चीर के, हिला दे ये अम्बर धरा तू।
आये चुनोतियो का धुंआ तो, फूंक कर उसको छटा तू,
चल जरा तू बढ़ जरा तू, उचाईयो पे चढ़ जरा तू।

मुश्किलो की आग हो या आकाश छूती सुनामिया,
लड़ जरा तू भिड़ जरा तू लौह जैसा अड़ जरा तू।
चल जरा तू बढ़ जरा तू, उचाईयो पे चढ़ जरा तू।

राह रोके कोई पर्वत जो तेरा,
मार मांझी सी टक्कर जरा तू।
चल जरा तू बढ़ जरा तू, उचाईयो पे चढ़ जरा तू।

- नीतेश कुमार

If you like it, please comment and follow.

Saturday, 29 September 2018

जिंदगी का चिराग

ये केसी मची है हर जगह अजब सी भागमभाग,
कही उड़ रहा उम्मीदों का धुंआ, तो कही लगी है दिल में आग।

जिंदगी के अंधेरों में कोई जला रहा है चिराग़,
किसी की जिंदगी को मिल गया प्रयाग।

इस अल्प से विकल्प से, ये जिंदगी के कल्प से,
नयन निद्रा छोड़ के बढ़ तू आगे गल्प से।

चल संभल तू बढ़ संभल,
खिला दे तू हर पग कमल।

पुकारती है ये धरा, तू चल निकल तू बढ़ निकल।
न मिलेगा तुमको कुछ अगर करोगे तुम बैराग।

घुल जरा तू इस जहां में, मिटा दे ये दिलों की आग।
दिल मिला के जग खिला के, लगा दे प्यार का तू राग।

देख तेरे को मिलेगी, मन प्रसन्नता प्रयाग।
एक बार मुस्कुरा के जला तो तू जिंदगी का चिराग।

Wednesday, 26 September 2018

ये लम्हें

कई लम्हें अक्सर हमें याद आते हैं,
कई लम्हें अक्सर हमको सताते है।

इन लम्हों को दिल के एक कोने में हम,
अक्सर दिल की तस्वीर जैसा सजाते है।

कई लम्हें आंखों में आँसू लाते है,
कई लम्हें ख़ुशियों की लहर चलाते है।

कई लम्हों में दर्द का अहसास होता है,
कई लम्हें दिल के लिए खास होतें है।

इन लम्हों की दिल मे एक तस्वीर बना लेता हू,
क्योंकि ये लम्हें हमेशा मुझे याद आते है।

By: Neetesh Narvaria

Tuesday, 25 September 2018

सैनिक

चल पड़े प्रवाह में, मचल पड़े है चाह में,
जिंदगी में मौज में, है बंदगी की राह में।
दिलो में आज जिद जगी, जो आज है वो फिर नही,
वो मर मिटे, वो जल कटे, पर नहीं पीछे हटे।
आज मै उस जमीं, उस आसमाँ से बोलता,
जो मन में है जागे वो सारे सवाल खोलता।
जो जल गया है उस जमी पे। जान दे गया है वो,
वो बोलता था कि ये माँ है मेरी उस जमी में सो गया है वो।
आज में भी उसकी वीरता पे मन टटोलता।
उस वतन के वीर की शान में कुछ पंक्तिया बोलता।
कि ऐ वीर वतन पर तेरी वीरता खाली न जाएगी,
तूने जो किया उसकी महक वतन में छाएगी,
तेरी छांव में ये वतन शोहरत पायेगा,
हरकदम पर ये नए नए परचम लहराएगा।।

अंतिम दो पंक्तियाँ सैनिक के नाम -

कि जिंदगी जब वतन की शान होती है,
लाख वर्दियां भी पहन लू, पर कफन में तिरंगे की चादर ही पहचान होती है।

जय हिन्द

(प्रस्तुतकर्ता - नीतेश नरवरिया)
By: Neetesh Narvaria

If you like this poem or have any suggestion, please give feedback or comment.