<?xml version="1.0" encoding="UTF-8"?>

<document repository="default" id="5287fad1-94e4-426e-a7b0-4f5d0c977108">
  <system>
    <type>NXExtensionPoint</type>
    <path>nuxeo-platform.1415371804852/Bundles/bg-grp-org-nuxeo-ecm-mobile/bundle-nuxeo-application-definition/component-org-nuxeo-ecm-application-definition-service/xp-org-nuxeo-ecm-application-definition-service-applicationdefinition</path>
    <lifecycle-state>project</lifecycle-state>
    <lifecycle-policy>default</lifecycle-policy>
    <facet>Commentable</facet>
    <facet>Versionable</facet>
    <facet>DocumentsSizeStatistics</facet>
    <facet>Folderish</facet>
    <access-control>
      <acl name="inherited">
        <entry principal="members" permission="Write" grant="true"/>
        <entry principal="Everyone" permission="Read" grant="true"/>
        <entry principal="Administrator" permission="Everything" grant="true"/>
        <entry principal="members" permission="Read" grant="true"/>
        <entry principal="members" permission="Version" grant="true"/>
      </acl>
    </access-control>
  </system>
  <schema xmlns:dc="http://www.nuxeo.org/ecm/schemas/dublincore/" name="dublincore">
    <dc:creator><![CDATA[Administrator]]></dc:creator>
    <dc:source><![CDATA[]]></dc:source>
    <dc:nature><![CDATA[]]></dc:nature>
    <dc:contributors>
      <item><![CDATA[Administrator]]></item>
      <item><![CDATA[jcarsique]]></item>
    </dc:contributors>
    <dc:created><![CDATA[2014-11-07T15:45:05.05Z]]></dc:created>
    <dc:description><![CDATA[]]></dc:description>
    <dc:rights><![CDATA[]]></dc:rights>
    <dc:subjects/>
    <dc:publisher><![CDATA[]]></dc:publisher>
    <dc:valid/>
    <dc:format><![CDATA[]]></dc:format>
    <dc:issued/>
    <dc:modified><![CDATA[2014-11-07T15:45:05.05Z]]></dc:modified>
    <dc:language><![CDATA[]]></dc:language>
    <dc:coverage><![CDATA[]]></dc:coverage>
    <dc:expired/>
    <dc:lastContributor><![CDATA[jcarsique]]></dc:lastContributor>
    <dc:title><![CDATA[org.nuxeo.ecm.application.definition.service--applicationDefinition]]></dc:title>
  </schema>
  <schema xmlns:dss="http://www.nuxeo.org/dam/schemas/documentsSizeStats/" name="documents_size_statistics">
    <dss:maxSize><![CDATA[-1]]></dss:maxSize>
    <dss:totalSize><![CDATA[0]]></dss:totalSize>
    <dss:sizeTrash><![CDATA[0]]></dss:sizeTrash>
    <dss:sizeVersions><![CDATA[0]]></dss:sizeVersions>
    <dss:innerSize><![CDATA[0]]></dss:innerSize>
  </schema>
  <schema xmlns:common="http://www.nuxeo.org/ecm/schemas/common/" name="common">
    <common:icon><![CDATA[/icons/file.gif]]></common:icon>
    <common:icon-expanded><![CDATA[]]></common:icon-expanded>
    <common:size><![CDATA[0]]></common:size>
  </schema>
  <schema xmlns:nxextensionpoint="http://nuxeo.org/schemas/nxextensionpoint" name="nxextensionpoint">
    <nxextensionpoint:extensionPoint>
      <item><![CDATA[org.nuxeo.ecm.mobile.ApplicationDefinitionDescriptor]]></item>
    </nxextensionpoint:extensionPoint>
    <nxextensionpoint:epId><![CDATA[org.nuxeo.ecm.application.definition.service--applicationDefinition]]></nxextensionpoint:epId>
    <nxextensionpoint:documentation><![CDATA[
      In this extension you will contribute a new application entry that
      will be caracterized by a name, a baseURL of the application, a relative
      path to a dedicate login page and logout page, a request handler to select the type
      of request that must be redirect to this application and a order.

      Let see that:

      <code>
    <application disable="false" name="app1" order="10">
        <applicationRelativePath>site/app1</applicationRelativePath>
        <loginPage>/auth/login</loginPage>
        <logoutPage>/auth/logout</logoutPage>
        <requestHandlerName>MyRequestHandler</requestHandlerName>
    </application>
</code>


      Here we define a new application named "app1". We define the base
      url of the application.
      So the full URL to reach it will be:
      <code>
        server/${NuxeoContextPath}/site/app1.
      </code>

      This seems to be, here, a webengine application. And logout page
      will be reachable here:
      <code>
        server/${NuxeoContextPath}/site/app1/auth/login
      </code>

      We have the same things with the logout page. The last but not
      least, the RequestHandler will be the object called to check
      if the request is a candidate to be redirected to the application.
      This handler must implements the org.nuxeo.ecm.mobile.handler.RequestHandler
      interface.

      You just have to implement, in fact this following method:
      <code>
        /**
        * return true if the request is a candidate for the Application
        described into
        * the {@code ApplicationDescriptor}.
        */
        public boolean isRequestRedirectedToApplication(
        HttpServletRequest request);
      </code>


      If this method return true for a given request, the browser will be redirected to
      the baseURL of the application with the initial uri into the
      ApplicationConstant#TARGET_URL_PARAMETER parameter into the redirected URL.

      You can for instance return true each time you detect that browser user
      agent is a mobile browser (you have the MobileRequestHandler implementing that),
      Like that all mobile browser will be redirected to app1.

      For instance if you call
      http://server/nuxeo/nxdoc/default/1239134098234023@view_documents
      is
      called and the handler return true, you be redirected to:

      <code>
        http://server/nuxeo/site/app1?targetURL=%2Fnuxeo%2Fnxdoc%2Fdefault%2F1239134098234023%40view_documents
      </code>


      For the login and logout page, becareful to unprotect resources
      you are using to generate the page.
      The login page must post to the "${baseURL}/nxstartup.faces"", 
      login module will do the authentication stuff and will redirect 
      to the initial url request for you. baseURL is by default /nuxeo, 
      in the webengine context you can use a relative path (becareful of reverse proxy)
      I mean if you use jquery library from here:
      <code>
        http://server/nuxeo/scripts/jquery.js
      </code>

      As you will be redirected to app1 this will not work. So if you do
      that think to contribute to the
      PluggableAuthenticationService to declare your open URL for your external resources, this service
      will also skip the redirect.

      Order of the application will let you organize the call order of handlers by the service.

      Last thing, becareful to have an efficient handler, as this code can be
      called many times. If you have handler that called a webservice, that is long, etc. This
      is a bad idea.

      About the login page you just have to create into the target url
      describe into your contribution a form that post user_name and user_password value to the same page.
      Authenticator of the service will do the authentication and will after redirect to the target URL.

      You can optionally aslo describe the base URL of resources of your application like that:
      <code>
    <application disable="false" name="app1" order="10">
        <applicationRelativePath>site/app1</applicationRelativePath>
        <loginPage>/auth/login</loginPage>
        <logoutPage>/auth/logout</logoutPage>
        <requestHandlerName>myHandler</requestHandlerName>
        <resources>
            <resourcesBaseURL>/site/skin/app1</resourcesBaseURL>
            <resourcesBaseURL>/nuxeo/resources</resourcesBaseURL>
        </resources>
    </application>
</code>

      Like that request to resources of your application will not be redirected to the base url.
      If your resources are under the base url of your application, this parameter is not needed.


      You have already different RequestHandler implemented (Mobile and Anonymous handler)

    
]]></nxextensionpoint:documentation>
    <nxextensionpoint:name><![CDATA[applicationDefinition]]></nxextensionpoint:name>
  </schema>
  <schema xmlns:file="http://www.nuxeo.org/ecm/schemas/file/" name="file">
    <file:content/>
    <file:filename><![CDATA[]]></file:filename>
  </schema>
</document>
