[Hippo-cms7-user] file:// protocol in source code

Stephan Westen s.westen at onehippo.com
Wed Jun 6 17:21:40 CEST 2012


I created  https://issues.onehippo.com/browse/REPO-378  so we do not loose
track.

thanks,

Stephan

On Wed, Jun 6, 2012 at 5:08 PM, Ams, Jasper van <
jasper.van.ams at capgemini.com> wrote:

> +1
>
> Completely agree on that being annoying. Lost quite some development time
> on pinpointing that issue once.
>
> Jasper.
>
>
> -----Original Message-----
> From: hippo-cms7-user-bounces at lists.onehippo.org [mailto:
> hippo-cms7-user-bounces at lists.onehippo.org] On Behalf Of Zandt, Paul van
> der
> Sent: woensdag 6 juni 2012 4:08
> To: Hippo CMS 7 development public mailinglist
> Subject: Re: [Hippo-cms7-user] file:// protocol in source code
>
> +1
>
> As this triggers some annoying issues when using mixed environments (win,
> linux) Especially when moving env vars outside of application p.e. in
> tomcat's context.xml.
>
> Paul.
> ________________________________________
> Van: hippo-cms7-user-bounces at lists.onehippo.org [
> hippo-cms7-user-bounces at lists.onehippo.org] namens David Martin [
> dmartin at ippon.fr]
> Verzonden: woensdag 6 juni 2012 10:25
> Aan: Hippo CMS 7 development public mailinglist
> Onderwerp: [Hippo-cms7-user]  file:// protocol in source code
>
> Hi,
>
> I was diving into Hippo configuration the last days (in order to get it
> running nuder WAS7 which is not that simple) and as I was reading the
> source code to better understand how things work, I was surprised by the
> way the file:// protocol is handled here and there.
> In fact it appears there are different considerations in source code about
> it.
> Let me illustrate this point with some code:
>
> org.onehippo.repository.Main.java (line 100):
>            if (configuration.startsWith("/")) {
>                configuration = "file://" + configuration;
>            }
>
> org.hippoecm.repository.HippoRepositoryFactory.java (line 97):
>        if (location.startsWith("file:")) {
>            location = location.substring("file:".length());
>        }
>
> org.hippoecm.repository.LoadInitializationModule.java (line 258, 338):
>                        if (cndName.startsWith("file:")) {
>                            if (cndName.startsWith("file://")) {
>                                cndName = cndName.substring(6);
>                            } else if (cndName.startsWith("file:/")) {
>                                cndName = cndName.substring(5);
>                            } else if (cndName.startsWith("file:")) {
>                                cndName = "/" + cndName.substring(5);
>                            }
>                            File localFile = new File(cndName);
> [...]
>                        if (contentName.startsWith("file:")) {
>                            if (contentName.startsWith("file://")) {
>                                contentName = contentName.substring(6);
>                            } else if (contentName.startsWith("file:/")) {
>                                contentName = contentName.substring(5);
>                            } else if (contentName.startsWith("file:")) {
>                                contentName = "/" +
> contentName.substring(5);
>                            }
>                            File localFile = new File(contentName);
>
> org.hippoecm.repository..LocalHippoRepository.java (line 165, 198):
>        } else if (path.startsWith("file://")) {
>            path = path.substring(6);
>        } else if (path.startsWith("file:/")) {
>            path = path.substring(5);
>        } else if (path.startsWith("file:")) {
>            path = "/" + path.substring(5);
>        }
> [...]
>        // resource
>        if (!configName.startsWith("file:")) {
>            log.info<http://log.info>("Using resource repository config: "
> + configName);
>            return
> LocalHippoRepository.class.getResourceAsStream(configName);
>        }
>
>        // parse file name
>        if (configName.startsWith("file://")) {
>            configName = configName.substring(6);
>        } else if (configName.startsWith("file:/")) {
>            configName = configName.substring(5);
>        } else if (configName.startsWith("file:")) {
>            configName = "/" + configName.substring(5);
>        }
>
> org.hippoecm.repository.query.lucene.ServicingSearchIndex.java (line 182):
>        if (configName.startsWith("file:/")) {
>            File config = new File(configName.substring(5));
>
>
> My first point is why is there sometimes up to three possible file
> protocol configurations to describe a file system path ? (file:, file:/ and
> file://)
> My second point is code duplication. An utility class can help managing
> file protocol related needs, perhaps.
> My third point is magic numbers (used in substring() methods). An utility
> class may hide these (and use .length() instead of them)
> My last (and least) point is "file://" string hardcoded. It cound be nice
> to have a single reference to this string somewhere.
>
> It's not a high priority thing (since everything works : that's not a
> blocking issue) but as I was working on it, I though it can help to mention
> it in a detailed email.
>
> Best regards,
>
> David
>
>
>
>
>
>
>
> This message contains information that may be privileged or confidential
> and is the property of the Capgemini Group. It is
> intended only for the person to whom it is addressed. If you are not the
> intended recipient, you are not authorized to
> read, print, retain, copy, disseminate, distribute, or use this message or
> any part thereof. If you receive this message
> in error, please notify the sender immediately and delete all copies of
> this message.
>
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html
>



-- 
thanks,

Stephan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.onehippo.org/pipermail/hippo-cms7-user/attachments/20120606/8b70a749/attachment.htm>


More information about the Hippo-cms7-user mailing list