1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.officeimporter.internal.server

File DefaultOfficeServerConfiguration.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart6.png
69% of files have more coverage

Code metrics

6
14
8
1
144
72
11
0.79
1.75
8
1.38

Classes

Class Line # Actions
DefaultOfficeServerConfiguration 42 14 0% 11 12
0.571428657.1%
 

Contributing tests

This file is covered by 59 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.officeimporter.internal.server;
21   
22    import java.io.File;
23   
24    import javax.inject.Inject;
25    import javax.inject.Singleton;
26   
27    import org.artofsolving.jodconverter.office.OfficeUtils;
28    import org.xwiki.component.annotation.Component;
29    import org.xwiki.component.phase.Initializable;
30    import org.xwiki.component.phase.InitializationException;
31    import org.xwiki.configuration.ConfigurationSource;
32    import org.xwiki.officeimporter.server.OfficeServerConfiguration;
33   
34    /**
35    * Default {@link OfficeServerConfiguration} implementation.
36    *
37    * @version $Id: 482260f4ac415fa6813796da61e261eaa9f5fa2a $
38    * @since 5.0M2
39    */
40    @Component
41    @Singleton
 
42    public class DefaultOfficeServerConfiguration implements OfficeServerConfiguration, Initializable
43    {
44    /**
45    * Prefix for configuration keys for the office module.
46    */
47    private static final String PREFIX = "openoffice.";
48   
49    /**
50    * @see OfficeServerConfiguration#getServerType()
51    */
52    private static final int DEFAULT_SERVER_TYPE = SERVER_TYPE_INTERNAL;
53   
54    /**
55    * @see OfficeServerConfiguration#getServerPort()
56    */
57    private static final int DEFAULT_SERVER_PORT = 8100;
58   
59    /**
60    * @see OfficeServerConfiguration#isAutoStart()
61    */
62    private static final boolean DEFAULT_AUTO_START = false;
63   
64    /**
65    * @see OfficeServerConfiguration#getMaxTasksPerProcess()
66    */
67    private static final int DEFAULT_MAX_TASKS_PER_PROCESS = 50;
68   
69    /**
70    * @see OfficeServerConfiguration#getTaskExecutionTimeout()
71    */
72    private static final long DEFAULT_TASK_EXECUTION_TIMEOUT = 30000L;
73   
74    /**
75    * @see OfficeServerConfiguration#getHomePath()
76    */
77    private String defaultHomePath;
78   
79    /**
80    * Defines from where to read the rendering configuration data.
81    */
82    @Inject
83    private ConfigurationSource configuration;
84   
 
85  1 toggle @Override
86    public int getServerType()
87    {
88  1 return this.configuration.getProperty(PREFIX + "serverType", DEFAULT_SERVER_TYPE);
89    }
90   
 
91  1 toggle @Override
92    public int getServerPort()
93    {
94  1 return this.configuration.getProperty(PREFIX + "serverPort", DEFAULT_SERVER_PORT);
95    }
96   
 
97  32 toggle @Override
98    public boolean isAutoStart()
99    {
100  32 return this.configuration.getProperty(PREFIX + "autoStart", DEFAULT_AUTO_START);
101    }
102   
 
103  0 toggle @Override
104    public String getHomePath()
105    {
106  0 String homePath = this.configuration.getProperty(PREFIX + "homePath");
107  0 if (homePath == null) {
108    // Fallback to the environment variable so anybody can set it for the execution of the functional tests,
109    // in accord with their system.
110  0 homePath = System.getenv("XWIKI_OFFICE_HOME");
111  0 if (homePath == null) {
112    // Finally fallback to the default value
113  0 homePath = this.defaultHomePath;
114    }
115    }
116   
117  0 return homePath;
118    }
119   
 
120  1 toggle @Override
121    public String getProfilePath()
122    {
123  1 return this.configuration.getProperty(PREFIX + "profilePath");
124    }
125   
 
126  1 toggle @Override
127    public int getMaxTasksPerProcess()
128    {
129  1 return this.configuration.getProperty(PREFIX + "maxTasksPerProcess", DEFAULT_MAX_TASKS_PER_PROCESS);
130    }
131   
 
132  1 toggle @Override
133    public long getTaskExecutionTimeout()
134    {
135  1 return this.configuration.getProperty(PREFIX + "taskExecutionTimeout", DEFAULT_TASK_EXECUTION_TIMEOUT);
136    }
137   
 
138  186 toggle @Override
139    public void initialize() throws InitializationException
140    {
141  186 File defaultHomeFolder = OfficeUtils.getDefaultOfficeHome();
142  186 this.defaultHomePath = defaultHomeFolder != null ? defaultHomeFolder.getAbsolutePath() : null;
143    }
144    }