Skip to content

Commit ec66b4d

Browse files
committed
HTMLPAGE-25 more Sonar compliancy
HTMLPAGE-25 mvn license and format HTMLPAGE-25 mvn license and format
1 parent 4333817 commit ec66b4d

File tree

14 files changed

+2230
-1987
lines changed

14 files changed

+2230
-1987
lines changed

src/java/fr/paris/lutece/plugins/htmlpage/business/HtmlPage.java

Lines changed: 236 additions & 223 deletions
Large diffs are not rendered by default.

src/java/fr/paris/lutece/plugins/htmlpage/business/HtmlPageDAO.java

Lines changed: 296 additions & 262 deletions
Large diffs are not rendered by default.
Lines changed: 201 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -1,186 +1,201 @@
1-
/*
2-
* Copyright (c) 2002-2014, Mairie de Paris
3-
* All rights reserved.
4-
*
5-
* Redistribution and use in source and binary forms, with or without
6-
* modification, are permitted provided that the following conditions
7-
* are met:
8-
*
9-
* 1. Redistributions of source code must retain the above copyright notice
10-
* and the following disclaimer.
11-
*
12-
* 2. Redistributions in binary form must reproduce the above copyright notice
13-
* and the following disclaimer in the documentation and/or other materials
14-
* provided with the distribution.
15-
*
16-
* 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17-
* contributors may be used to endorse or promote products derived from
18-
* this software without specific prior written permission.
19-
*
20-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23-
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24-
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26-
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27-
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28-
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30-
* POSSIBILITY OF SUCH DAMAGE.
31-
*
32-
* License 1.0
33-
*/
34-
package fr.paris.lutece.plugins.htmlpage.business;
35-
36-
import java.util.Collection;
37-
38-
import fr.paris.lutece.plugins.htmlpage.service.search.HtmlPageIndexer;
39-
import fr.paris.lutece.plugins.htmlpage.utils.HtmlPageIndexerUtils;
40-
import fr.paris.lutece.portal.business.indexeraction.IndexerAction;
41-
import fr.paris.lutece.portal.service.plugin.Plugin;
42-
import fr.paris.lutece.portal.service.search.IndexationService;
43-
import fr.paris.lutece.portal.service.spring.SpringContextService;
44-
import fr.paris.lutece.portal.service.util.AppPropertiesService;
45-
46-
47-
/**
48-
* This class provides instances management methods (create, find, ...) for Htmlpage objects
49-
* @author lenaini
50-
*/
51-
public class HtmlPageHome
52-
{
53-
// Static variable pointed at the DAO instance
54-
private static IHtmlPageDAO _dao = (IHtmlPageDAO) SpringContextService.getPluginBean( "htmlpage", "htmlPageDAO" );
55-
56-
/**
57-
* Private constructor - this class need not be instantiated
58-
*/
59-
private HtmlPageHome( )
60-
{
61-
}
62-
63-
/**
64-
* Creation of an instance of htmlpage
65-
*
66-
* @param htmlpage The instance of the htmlpage which contains the informations to store
67-
* @param plugin The Plugin object
68-
* @return The instance of htmlpage which has been created with its primary key.
69-
*/
70-
public static HtmlPage create( HtmlPage htmlpage, Plugin plugin )
71-
{
72-
_dao.insert( htmlpage, plugin );
73-
74-
if ( htmlpage.isEnabled( ) )
75-
{
76-
String strIdHtmlPage = Integer.toString( htmlpage.getId( ) );
77-
IndexationService.addIndexerAction( strIdHtmlPage,
78-
AppPropertiesService.getProperty( HtmlPageIndexer.PROPERTY_INDEXER_NAME ), IndexerAction.TASK_CREATE );
79-
80-
HtmlPageIndexerUtils.addIndexerAction( strIdHtmlPage, IndexerAction.TASK_CREATE );
81-
}
82-
83-
return htmlpage;
84-
}
85-
86-
/**
87-
* Update of the htmlpage which is specified in parameter
88-
*
89-
* @param htmlpage The instance of the htmlpage which contains the data to store
90-
* @param plugin The Plugin object
91-
* @return The instance of the htmlpage which has been updated
92-
*/
93-
public static HtmlPage update( HtmlPage htmlpage, Plugin plugin )
94-
{
95-
String strIdHtmlPage = Integer.toString( htmlpage.getId( ) );
96-
if ( htmlpage.isEnabled( ) )
97-
{
98-
IndexationService.addIndexerAction( strIdHtmlPage,
99-
AppPropertiesService.getProperty( HtmlPageIndexer.PROPERTY_INDEXER_NAME ), IndexerAction.TASK_MODIFY );
100-
101-
HtmlPageIndexerUtils.addIndexerAction( strIdHtmlPage, IndexerAction.TASK_MODIFY );
102-
}
103-
else
104-
{
105-
HtmlPage oldPage = findEnabledHtmlPage( htmlpage.getId( ), plugin );
106-
107-
if ( oldPage != null )
108-
{
109-
IndexationService.addIndexerAction( strIdHtmlPage + "_" +
110-
HtmlPageIndexer.SHORT_NAME,
111-
AppPropertiesService.getProperty( HtmlPageIndexer.PROPERTY_INDEXER_NAME ), IndexerAction.TASK_DELETE );
112-
113-
HtmlPageIndexerUtils.addIndexerAction( strIdHtmlPage, IndexerAction.TASK_DELETE );
114-
}
115-
}
116-
117-
_dao.store( htmlpage, plugin );
118-
119-
return htmlpage;
120-
}
121-
122-
/**
123-
* Remove the Htmlpage whose identifier is specified in parameter
124-
* @param htmlpage The Htmlpage object to remove
125-
* @param plugin The Plugin object
126-
*/
127-
public static void remove( HtmlPage htmlpage, Plugin plugin )
128-
{
129-
_dao.delete( htmlpage, plugin );
130-
131-
if ( htmlpage.isEnabled( ) )
132-
{
133-
String strIdHtmlPage = Integer.toString( htmlpage.getId( ) );
134-
IndexationService.addIndexerAction( strIdHtmlPage + "_" +
135-
HtmlPageIndexer.SHORT_NAME, AppPropertiesService.getProperty( HtmlPageIndexer.PROPERTY_INDEXER_NAME ),
136-
IndexerAction.TASK_DELETE );
137-
138-
HtmlPageIndexerUtils.addIndexerAction( strIdHtmlPage, IndexerAction.TASK_DELETE );
139-
}
140-
}
141-
142-
///////////////////////////////////////////////////////////////////////////
143-
// Finders
144-
145-
/**
146-
* Returns an instance of a htmlpage whose identifier is specified in parameter
147-
* @param nKey The Primary key of the htmlpage
148-
* @param plugin The Plugin object
149-
* @return An instance of htmlpage
150-
*/
151-
public static HtmlPage findByPrimaryKey( int nKey, Plugin plugin )
152-
{
153-
return _dao.load( nKey, plugin );
154-
}
155-
156-
/**
157-
* Returns a collection of htmlpages objects
158-
* @param plugin The Plugin object
159-
* @return A collection of htmlpages
160-
*/
161-
public static Collection<HtmlPage> findAll( Plugin plugin )
162-
{
163-
return _dao.selectAll( plugin );
164-
}
165-
166-
/**
167-
* Returns htmlpage object with valid status
168-
* @param nKey the page id
169-
* @param plugin The Plugin object
170-
* @return A htmlpage
171-
*/
172-
public static HtmlPage findEnabledHtmlPage( int nKey, Plugin plugin )
173-
{
174-
return _dao.selectEnabledHtmlPage( nKey, plugin );
175-
}
176-
177-
/**
178-
* Returns a collection of htmlpages objects with valid status
179-
* @param plugin The Plugin object
180-
* @return A collection of htmlpages
181-
*/
182-
public static Collection<HtmlPage> findEnabledHtmlPageList( Plugin plugin )
183-
{
184-
return _dao.selectEnabledHtmlPageList( plugin );
185-
}
186-
}
1+
/*
2+
* Copyright (c) 2002-2020, City of Paris
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
*
9+
* 1. Redistributions of source code must retain the above copyright notice
10+
* and the following disclaimer.
11+
*
12+
* 2. Redistributions in binary form must reproduce the above copyright notice
13+
* and the following disclaimer in the documentation and/or other materials
14+
* provided with the distribution.
15+
*
16+
* 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17+
* contributors may be used to endorse or promote products derived from
18+
* this software without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30+
* POSSIBILITY OF SUCH DAMAGE.
31+
*
32+
* License 1.0
33+
*/
34+
package fr.paris.lutece.plugins.htmlpage.business;
35+
36+
import java.util.Collection;
37+
38+
import fr.paris.lutece.plugins.htmlpage.service.search.HtmlPageIndexer;
39+
import fr.paris.lutece.plugins.htmlpage.utils.HtmlPageIndexerUtils;
40+
import fr.paris.lutece.portal.business.indexeraction.IndexerAction;
41+
import fr.paris.lutece.portal.service.plugin.Plugin;
42+
import fr.paris.lutece.portal.service.search.IndexationService;
43+
import fr.paris.lutece.portal.service.spring.SpringContextService;
44+
import fr.paris.lutece.portal.service.util.AppPropertiesService;
45+
46+
/**
47+
* This class provides instances management methods (create, find, ...) for Htmlpage objects
48+
*
49+
* @author lenaini
50+
*/
51+
public class HtmlPageHome
52+
{
53+
// Static variable pointed at the DAO instance
54+
private static IHtmlPageDAO _dao = (IHtmlPageDAO) SpringContextService.getPluginBean( "htmlpage", "htmlPageDAO" );
55+
56+
/**
57+
* Private constructor - this class need not be instantiated
58+
*/
59+
private HtmlPageHome( )
60+
{
61+
}
62+
63+
/**
64+
* Creation of an instance of htmlpage
65+
*
66+
* @param htmlpage
67+
* The instance of the htmlpage which contains the informations to store
68+
* @param plugin
69+
* The Plugin object
70+
* @return The instance of htmlpage which has been created with its primary key.
71+
*/
72+
public static HtmlPage create( HtmlPage htmlpage, Plugin plugin )
73+
{
74+
_dao.insert( htmlpage, plugin );
75+
76+
if ( htmlpage.isEnabled( ) )
77+
{
78+
String strIdHtmlPage = Integer.toString( htmlpage.getId( ) );
79+
IndexationService.addIndexerAction( strIdHtmlPage, AppPropertiesService.getProperty( HtmlPageIndexer.PROPERTY_INDEXER_NAME ),
80+
IndexerAction.TASK_CREATE );
81+
82+
HtmlPageIndexerUtils.addIndexerAction( strIdHtmlPage, IndexerAction.TASK_CREATE );
83+
}
84+
85+
return htmlpage;
86+
}
87+
88+
/**
89+
* Update of the htmlpage which is specified in parameter
90+
*
91+
* @param htmlpage
92+
* The instance of the htmlpage which contains the data to store
93+
* @param plugin
94+
* The Plugin object
95+
* @return The instance of the htmlpage which has been updated
96+
*/
97+
public static HtmlPage update( HtmlPage htmlpage, Plugin plugin )
98+
{
99+
String strIdHtmlPage = Integer.toString( htmlpage.getId( ) );
100+
if ( htmlpage.isEnabled( ) )
101+
{
102+
IndexationService.addIndexerAction( strIdHtmlPage, AppPropertiesService.getProperty( HtmlPageIndexer.PROPERTY_INDEXER_NAME ),
103+
IndexerAction.TASK_MODIFY );
104+
105+
HtmlPageIndexerUtils.addIndexerAction( strIdHtmlPage, IndexerAction.TASK_MODIFY );
106+
}
107+
else
108+
{
109+
HtmlPage oldPage = findEnabledHtmlPage( htmlpage.getId( ), plugin );
110+
111+
if ( oldPage != null )
112+
{
113+
IndexationService.addIndexerAction( strIdHtmlPage + "_" + HtmlPageIndexer.SHORT_NAME,
114+
AppPropertiesService.getProperty( HtmlPageIndexer.PROPERTY_INDEXER_NAME ), IndexerAction.TASK_DELETE );
115+
116+
HtmlPageIndexerUtils.addIndexerAction( strIdHtmlPage, IndexerAction.TASK_DELETE );
117+
}
118+
}
119+
120+
_dao.store( htmlpage, plugin );
121+
122+
return htmlpage;
123+
}
124+
125+
/**
126+
* Remove the Htmlpage whose identifier is specified in parameter
127+
*
128+
* @param htmlpage
129+
* The Htmlpage object to remove
130+
* @param plugin
131+
* The Plugin object
132+
*/
133+
public static void remove( HtmlPage htmlpage, Plugin plugin )
134+
{
135+
_dao.delete( htmlpage, plugin );
136+
137+
if ( htmlpage.isEnabled( ) )
138+
{
139+
String strIdHtmlPage = Integer.toString( htmlpage.getId( ) );
140+
IndexationService.addIndexerAction( strIdHtmlPage + "_" + HtmlPageIndexer.SHORT_NAME,
141+
AppPropertiesService.getProperty( HtmlPageIndexer.PROPERTY_INDEXER_NAME ), IndexerAction.TASK_DELETE );
142+
143+
HtmlPageIndexerUtils.addIndexerAction( strIdHtmlPage, IndexerAction.TASK_DELETE );
144+
}
145+
}
146+
147+
///////////////////////////////////////////////////////////////////////////
148+
// Finders
149+
150+
/**
151+
* Returns an instance of a htmlpage whose identifier is specified in parameter
152+
*
153+
* @param nKey
154+
* The Primary key of the htmlpage
155+
* @param plugin
156+
* The Plugin object
157+
* @return An instance of htmlpage
158+
*/
159+
public static HtmlPage findByPrimaryKey( int nKey, Plugin plugin )
160+
{
161+
return _dao.load( nKey, plugin );
162+
}
163+
164+
/**
165+
* Returns a collection of htmlpages objects
166+
*
167+
* @param plugin
168+
* The Plugin object
169+
* @return A collection of htmlpages
170+
*/
171+
public static Collection<HtmlPage> findAll( Plugin plugin )
172+
{
173+
return _dao.selectAll( plugin );
174+
}
175+
176+
/**
177+
* Returns htmlpage object with valid status
178+
*
179+
* @param nKey
180+
* the page id
181+
* @param plugin
182+
* The Plugin object
183+
* @return A htmlpage
184+
*/
185+
public static HtmlPage findEnabledHtmlPage( int nKey, Plugin plugin )
186+
{
187+
return _dao.selectEnabledHtmlPage( nKey, plugin );
188+
}
189+
190+
/**
191+
* Returns a collection of htmlpages objects with valid status
192+
*
193+
* @param plugin
194+
* The Plugin object
195+
* @return A collection of htmlpages
196+
*/
197+
public static Collection<HtmlPage> findEnabledHtmlPageList( Plugin plugin )
198+
{
199+
return _dao.selectEnabledHtmlPageList( plugin );
200+
}
201+
}

0 commit comments

Comments
 (0)