27
27
import org .silverpeas .core .annotation .Repository ;
28
28
import org .silverpeas .core .persistence .jdbc .DBUtil ;
29
29
30
- import java .sql .Connection ;
31
- import java .sql .PreparedStatement ;
32
- import java .sql .ResultSet ;
33
- import java .sql .SQLException ;
34
- import java .sql .Types ;
30
+ import java .sql .*;
35
31
import java .util .Date ;
36
32
import java .util .List ;
37
33
38
- import static org .silverpeas .core .SilverpeasExceptionMessages .unknown ;
39
-
40
34
/**
41
35
* A ComponentInstanceTable object manages the ST_ComponentInstance table.
42
36
*/
@@ -113,22 +107,6 @@ public ComponentInstanceRow getComponentInstance(int id) throws SQLException {
113
107
return getUniqueRow (SELECT_INSTANCE_BY_ID , id );
114
108
}
115
109
116
- /**
117
- * Returns the ComponentInstance of a given user role.
118
- * @param userRoleId id of user role
119
- * @return the ComponentInstance of a given user role.
120
- * @throws SQLException on error
121
- */
122
- public ComponentInstanceRow getComponentInstanceOfUserRole (int userRoleId )
123
- throws SQLException {
124
- return getUniqueRow (SELECT_USERROLE_INSTANCE , userRoleId );
125
- }
126
-
127
- private static final String SELECT_USERROLE_INSTANCE =
128
- SELECT + Table .aliasColumns ("i" , INSTANCE_COLUMNS ) +
129
- " from ST_ComponentInstance i, ST_UserRole us" +
130
- " where i.id = us.instanceId and us.id = ?" ;
131
-
132
110
/**
133
111
* Returns all the instances in a given space
134
112
* @param spaceId the space id
@@ -138,7 +116,7 @@ public ComponentInstanceRow getComponentInstanceOfUserRole(int userRoleId)
138
116
public ComponentInstanceRow [] getAllComponentInstancesInSpace (int spaceId )
139
117
throws SQLException {
140
118
List <ComponentInstanceRow > rows = getRows (SELECT_ALL_SPACE_INSTANCES , spaceId );
141
- return rows .toArray (new ComponentInstanceRow [rows . size () ]);
119
+ return rows .toArray (new ComponentInstanceRow [0 ]);
142
120
}
143
121
144
122
private static final String SELECT_ALL_SPACE_INSTANCES = SELECT + INSTANCE_COLUMNS +
@@ -167,7 +145,7 @@ public String[] getAllComponentInstanceIdsInSpace(int spaceId) throws SQLExcepti
167
145
*/
168
146
public ComponentInstanceRow [] getRemovedComponents () throws SQLException {
169
147
List <ComponentInstanceRow > rows = getRows (SELECT_REMOVED_COMPONENTS );
170
- return rows .toArray (new ComponentInstanceRow [rows . size () ]);
148
+ return rows .toArray (new ComponentInstanceRow [0 ]);
171
149
}
172
150
173
151
private static final String SELECT_REMOVED_COMPONENTS =
@@ -186,7 +164,7 @@ public ComponentInstanceRow[] getAllMatchingComponentInstances(
186
164
String [] values =
187
165
new String []{sampleInstance .componentName , sampleInstance .name , sampleInstance .description };
188
166
List <ComponentInstanceRow > rows = getMatchingRows (INSTANCE_COLUMNS , columns , values );
189
- return rows .toArray (new ComponentInstanceRow [rows . size () ]);
167
+ return rows .toArray (new ComponentInstanceRow [0 ]);
190
168
}
191
169
192
170
/**
@@ -196,10 +174,6 @@ public ComponentInstanceRow[] getAllMatchingComponentInstances(
196
174
*/
197
175
public void createComponentInstance (ComponentInstanceRow instance )
198
176
throws SQLException {
199
- SpaceRow space = OrganizationSchema .get ().space ().getSpace (instance .spaceId );
200
- if (space == null ) {
201
- throw new SQLException (unknown ("space" , String .valueOf (instance .spaceId )));
202
- }
203
177
insertRow (INSERT_INSTANCE , instance );
204
178
}
205
179
@@ -268,7 +242,7 @@ public void updateComponentInheritance(int componentId, boolean inheritanceBlock
268
242
/**
269
243
* Updates in the database an instance row.
270
244
* @param instance the row with the fields of the component instance
271
- * @throws SQLException
245
+ * @throws SQLException if the update fails.
272
246
*/
273
247
public void updateComponentInstance (ComponentInstanceRow instance )
274
248
throws SQLException {
@@ -306,7 +280,6 @@ public boolean isComponentIntoBasket(int spaceId, String name) throws SQLExcepti
306
280
* @param id the component id
307
281
* @param tempLabel the temporary label
308
282
* @param userId the user id that deletes the space
309
- * @throws AdminPersistenceException on error
310
283
*/
311
284
public void sendComponentToBasket (int id , String tempLabel , String userId )
312
285
throws SQLException {
0 commit comments