View Javadoc

1   /**
2    * Standard Portlet Collection Project 7 
3    * open source portlets every community needs
4    *
5    * Copyright (C) 2007  Phillip Merensky (phillip23@users.sourceforge.net)
6    *
7    * This program is free software: you can redistribute it and/or modify
8    * it under the terms of the GNU General Public License as published by
9    * the Free Software Foundation, either version 3 of the License, or
10   * (at your option) any later version.
11   *
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Public License for more details.
16   *
17   * You should have received a copy of the GNU General Public License
18   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19   */
20  package spcp7.imagegallery.impl.alfresco;
21  
22  import java.rmi.RemoteException;
23  import java.util.ArrayList;
24  import java.util.Collections;
25  import java.util.Comparator;
26  import java.util.List;
27  import java.util.Map;
28  
29  import org.alfresco.webservice.authentication.AuthenticationFault;
30  import org.alfresco.webservice.repository.QueryResult;
31  import org.alfresco.webservice.repository.RepositoryFault;
32  import org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub;
33  import org.alfresco.webservice.repository.UpdateResult;
34  import org.alfresco.webservice.types.CML;
35  import org.alfresco.webservice.types.CMLCreate;
36  import org.alfresco.webservice.types.CMLDelete;
37  import org.alfresco.webservice.types.NamedValue;
38  import org.alfresco.webservice.types.Node;
39  import org.alfresco.webservice.types.ParentReference;
40  import org.alfresco.webservice.types.Predicate;
41  import org.alfresco.webservice.types.Query;
42  import org.alfresco.webservice.types.Reference;
43  import org.alfresco.webservice.types.ResultSet;
44  import org.alfresco.webservice.types.ResultSetRow;
45  import org.alfresco.webservice.types.Store;
46  import org.alfresco.webservice.util.AuthenticationUtils;
47  import org.alfresco.webservice.util.Constants;
48  import org.alfresco.webservice.util.Utils;
49  import org.alfresco.webservice.util.WebServiceFactory;
50  import org.apache.commons.logging.Log;
51  import org.apache.commons.logging.LogFactory;
52  import org.springframework.beans.BeansException;
53  import org.springframework.context.ApplicationContext;
54  import org.springframework.context.ApplicationContextAware;
55  
56  import spcp7.imagegallery.abstractionlayer.enums.DefaultProperties;
57  import spcp7.imagegallery.abstractionlayer.exception.ContentCouldNotBeAccessedException;
58  import spcp7.imagegallery.abstractionlayer.exception.ContentProviderAuthenticationException;
59  import spcp7.imagegallery.abstractionlayer.exception.NoContentFoundException;
60  import spcp7.imagegallery.abstractionlayer.exception.PropertyValidationException;
61  import spcp7.imagegallery.abstractionlayer.exception.RangeNotValidException;
62  import spcp7.imagegallery.abstractionlayer.face.ContentFace;
63  import spcp7.imagegallery.abstractionlayer.face.ImageFilterFace;
64  import spcp7.imagegallery.abstractionlayer.face.persistence.PropertyModelFace;
65  import spcp7.imagegallery.abstractionlayer.util.GeneralValidation;
66  import spcp7.imagegallery.abstractionlayer.util.StandardUtils;
67  import spcp7.imagegallery.contentprovider.face.ContentRetrievalFace;
68  import spcp7.imagegallery.contentprovider.face.ContentSubmitterFace;
69  import spcp7.imagegallery.impl.alfresco.utils.AlfrescoDefaultProperties;
70  import spcp7.imagegallery.impl.alfresco.utils.AlfrescoUtils;
71  import spcp7.imagegallery.impl.alfresco.utils.AlfrescoValidation;
72  
73  /**
74   * Implementation of an Alfresco content provider.
75   * 
76   * @author Phillip Merensky
77   * 
78   */
79  public class AlfrescoContentRetrievalImpl implements ContentRetrievalFace,
80  	ApplicationContextAware {
81      private Log log = LogFactory.getLog(AlfrescoContentRetrievalImpl.class);
82  
83      private RepositoryServiceSoapBindingStub repositoryService;
84      private Comparator<ContentFace> contentComparator;
85      private ImageFilterFace imageFilterFace;
86      private AlfrescoValidation alfrescoValidation;
87  
88      private AlfrescoUtils alfrescoUtils;
89  
90      private GeneralValidation generalValidation;
91  
92      private ApplicationContext applicationContext;
93  
94      // TODO DOC adaption to other document styles
95  
96      /**
97       * Empty standard constructor
98       */
99      public AlfrescoContentRetrievalImpl() {
100     }
101 
102     /*
103      * (non-Javadoc)
104      * 
105      * @see spcp.imagegallery.abstractionlayer.face.external.ContentConnectionFace#close()
106      */
107     public void close() {
108 	// End the session
109 	AuthenticationUtils.endSession();
110     }
111 
112     /**
113      * This method and {@link #removeFolder(String, Map)} are currently only for
114      * testing purposes. That is for inserting and deleting test content. Later
115      * they could be used within a class implementing the
116      * {@link ContentSubmitterFace} for example.
117      * 
118      * @param name
119      *                The name of the folder
120      * @param properties
121      *                The following properties are required:
122      *                {@link AlfrescoDefaultProperties#ALFRESCO_SPACES_STORE},
123      *                {@link AlfrescoDefaultProperties#ALFRESCO_WORKSPACE_STORE},
124      *                {@link DefaultProperties#SPCP7_CURRENT_PATH}
125      * @return The id of the new folder *
126      * @throws ContentCouldNotBeAccessedException
127      *                 if the folder could not be deleted or the repository
128      *                 could not be reached.
129      */
130     public synchronized String createFolder(String name,
131 	    Map<String, PropertyModelFace> properties)
132 	    throws ContentCouldNotBeAccessedException {
133 
134 	Store store = new Store(properties.get(
135 		AlfrescoDefaultProperties.ALFRESCO_WORKSPACE_STORE.toString())
136 		.getWert(), properties.get(
137 		AlfrescoDefaultProperties.ALFRESCO_SPACES_STORE.toString())
138 		.getWert());
139 	String basepath = properties.get(
140 		DefaultProperties.SPCP7_CURRENT_PATH.toString()).getWert();
141 	String folderToCreateQName = Constants.createQNameString(
142 		Constants.NAMESPACE_CONTENT_MODEL, name);
143 	Reference folderToCreateReference = new Reference(store, null,
144 		this.alfrescoUtils.normalizePathNamespace(basepath
145 			+ "/"
146 			+ Constants.createQNameString(
147 				Constants.NAMESPACE_CONTENT_MODEL, name),
148 			properties));
149 	// Check to see if the sample folder has already been created or not
150 	try {
151 	    @SuppressWarnings("unused")
152 	    Node[] node = WebServiceFactory.getRepositoryService().get(
153 		    new Predicate(new Reference[] { folderToCreateReference },
154 			    store, null));
155 	} catch (Exception e1) {
156 	    // Folder does not yet exist!
157 	    UpdateResult[] results = null;
158 	    // Create parent reference to company home
159 	    ParentReference parentReference = new ParentReference(store, null,
160 		    basepath, Constants.ASSOC_CONTAINS, folderToCreateQName);
161 
162 	    // Create folder
163 	    NamedValue[] folderProperties = new NamedValue[] { Utils
164 		    .createNamedValue(Constants.PROP_NAME, name) };
165 	    CMLCreate create = new CMLCreate("1", parentReference, null, null,
166 		    null, Constants.TYPE_FOLDER, folderProperties);
167 	    CML cml = new CML();
168 	    cml.setCreate(new CMLCreate[] { create });
169 	    try {
170 		results = this.repositoryService.update(cml);
171 		return results[0].getDestination().getUuid();
172 	    } catch (RepositoryFault e) {
173 		// We print a stacktrace at this point and throw an exception
174 		// because the detail data of the axisfault gets lost otherwise
175 		e.printStackTrace();
176 		throw new ContentCouldNotBeAccessedException(
177 			"The repository threw an exception when trying to create a folder!",
178 			e);
179 	    } catch (RemoteException e) {
180 		throw new ContentCouldNotBeAccessedException(
181 			"The repository could not be reached when trying to create a folder!",
182 			e);
183 	    }
184 	}
185 	throw new ContentCouldNotBeAccessedException(
186 		"The folder which should be created already exists!");
187     }
188 
189     // TODO test method
190 
191     /**
192      * Additionally to the properties mentioned in the interface
193      * {@link AlfrescoDefaultProperties#ALFRESCO_MAX_RESULT_ROWS},
194      * {@link AlfrescoDefaultProperties#ALFRESCO_SPACES_STORE} and
195      * {@link AlfrescoDefaultProperties#ALFRESCO_WORKSPACE_STORE} properties are
196      * needed.
197      * 
198      * @see spcp7.imagegallery.contentprovider.face.ContentRetrievalFace#getParent(spcp7.imagegallery.abstractionlayer.face.ContentFace,
199      *      java.util.Map)
200      */
201     public synchronized ContentFace getParent(String proprietaryId,
202 	    Map<String, PropertyModelFace> properties)
203 	    throws ContentCouldNotBeAccessedException, NoContentFoundException {
204 	List<ContentFace> retList = null;
205 	if (proprietaryId != null) {
206 	    String queryString = "+ISNODE:T +ID:\""
207 		    + properties.get(
208 			    AlfrescoDefaultProperties.ALFRESCO_WORKSPACE_STORE
209 				    .toString()).getWert()
210 		    + "://"
211 		    + properties.get(
212 			    AlfrescoDefaultProperties.ALFRESCO_SPACES_STORE
213 				    .toString()).getWert() + "/"
214 		    + proprietaryId + "\"";
215 	    Store store = new Store(properties.get(
216 		    AlfrescoDefaultProperties.ALFRESCO_WORKSPACE_STORE
217 			    .toString()).getWert(), properties.get(
218 		    AlfrescoDefaultProperties.ALFRESCO_SPACES_STORE.toString())
219 		    .getWert());
220 	    ResultSet resultSet = executeQuery(queryString, properties);
221 	    ResultSetRow[] rows = resultSet.getRows();
222 	    if (rows.length > 0) {
223 
224 		// Get the id of the first result
225 		String firstResultId = rows[0].getNode().getId();
226 		Reference reference = new Reference(store, firstResultId, null);
227 
228 		// Get the parent(s) of the first result
229 		QueryResult parentQueryResult = null;
230 		try {
231 		    parentQueryResult = this.repositoryService
232 			    .queryParents(reference);
233 		} catch (RepositoryFault e) {
234 		    throw new ContentCouldNotBeAccessedException(
235 			    "The repository threw an exception when trying to get the parent!",
236 			    e);
237 		} catch (RemoteException e) {
238 		    throw new ContentCouldNotBeAccessedException(
239 			    "The repository could not be reached when trying to get the parent!!",
240 			    e);
241 		}
242 		if (parentQueryResult != null) {
243 		    retList = transformResultSet(properties, parentQueryResult
244 			    .getResultSet(), 1, Integer.valueOf(properties.get(
245 			    AlfrescoDefaultProperties.ALFRESCO_MAX_RESULT_ROWS
246 				    .toString()).getWert()));
247 		}
248 		if (retList != null && retList.size() > 0) {
249 		    return retList.get(0);
250 		}
251 	    } else {
252 		throw new ContentCouldNotBeAccessedException(
253 			"The specified parent could not be found");
254 	    }
255 	}
256 	return null;
257     }
258 
259     /**
260      * Additionally to the properties mentioned in the interface
261      * {@link AlfrescoDefaultProperties#ALFRESCO_MAX_RESULT_ROWS},
262      * {@link AlfrescoDefaultProperties#ALFRESCO_SPACES_STORE} and
263      * {@link AlfrescoDefaultProperties#ALFRESCO_WORKSPACE_STORE} properties are
264      * needed.
265      * 
266      * @see spcp.imagegallery.abstractionlayer.face.external.ContentRetrievalFace#getVolumes(java.lang.String)
267      */
268     public synchronized List<ContentFace> getVolumes(
269 	    Map<String, PropertyModelFace> properties, boolean isFolder)
270 	    throws PropertyValidationException,
271 	    ContentCouldNotBeAccessedException, NoContentFoundException {
272 	List<ContentFace> retList = null;
273 	try {
274 	    retList = getVolumesFromTo(1, Integer.valueOf(properties.get(
275 		    AlfrescoDefaultProperties.ALFRESCO_MAX_RESULT_ROWS
276 			    .toString()).getWert()), properties, isFolder);
277 	} catch (NumberFormatException e) {
278 	    throw new ContentCouldNotBeAccessedException(
279 		    "Volumes could not be retrieved.", e);
280 	} catch (RangeNotValidException e) {
281 	    throw new ContentCouldNotBeAccessedException(
282 		    "Volumes could not be retrieved.", e);
283 	}
284 	if (retList == null) {
285 	    throw new ContentCouldNotBeAccessedException(
286 		    "Volumes could not be retrieved.");
287 	}
288 	return retList;
289     }
290 
291     /**
292      * Additionally to the properties mentioned in the interface
293      * {@link AlfrescoDefaultProperties#ALFRESCO_MAX_RESULT_ROWS},
294      * {@link AlfrescoDefaultProperties#ALFRESCO_SPACES_STORE} and
295      * {@link AlfrescoDefaultProperties#ALFRESCO_WORKSPACE_STORE} properties are
296      * needed.
297      * 
298      * @see spcp7.imagegallery.contentprovider.face.ContentRetrievalFace#getVolumesFromTo(int,
299      *      int, java.util.Map, boolean)
300      */
301     public synchronized List<ContentFace> getVolumesFromTo(int lowerLimit,
302 	    int upperLimit, Map<String, PropertyModelFace> properties,
303 	    boolean isFolder) throws RangeNotValidException,
304 	    PropertyValidationException, ContentCouldNotBeAccessedException,
305 	    NoContentFoundException {
306 	List<ContentFace> retList = null;
307 	this.generalValidation.validateRange(lowerLimit, upperLimit);
308 	// validate properties
309 	this.alfrescoValidation.validateAlfrescoQueryProperties(properties);
310 	// The path must not end with a slash. If it does we do not only find
311 	// folders and documents directly below the current folder but also
312 	// of documents below all subfolders of the current folder
313 	while (properties.get(DefaultProperties.SPCP7_CURRENT_PATH.toString())
314 		.getWert().endsWith("/")) {
315 	    PropertyModelFace prop = properties
316 		    .get(DefaultProperties.SPCP7_CURRENT_PATH.toString());
317 	    prop.setWert(prop.getWert().substring(0,
318 		    prop.getWert().length() - 1));
319 	    properties.put(DefaultProperties.SPCP7_CURRENT_PATH.toString(),
320 		    prop);
321 	}
322 	String encodedPath = this.alfrescoUtils
323 		.encodeAlfrescoAbbreviatedPathISO9075(properties.get(
324 			DefaultProperties.SPCP7_CURRENT_PATH.toString())
325 			.getWert());
326 	String queryString = "+PATH:\"" + encodedPath;
327 	if (isFolder) {
328 	    // If we search for content within a folder, we look for subcontent
329 	    queryString += "/*\"";
330 	} else {
331 	    // else we look eg for a single image and thus we only close quotes
332 	    queryString += "\"";
333 	}
334 	ResultSet resultSet = executeQuery(queryString, properties);
335 	retList = transformResultSet(properties, resultSet, lowerLimit,
336 		upperLimit);
337 	if (retList != null && this.contentComparator != null) {
338 	    Collections.sort(retList, this.contentComparator);
339 	}
340 	return retList;
341     }
342 
343 
344     /**
345      * Additionally to the properties mentioned in the interface
346      * {@link AlfrescoDefaultProperties#ALFRESCO_USERNAME} and
347      * {@link AlfrescoDefaultProperties#ALFRESCO_PASSWORD} properties are
348      * needed.
349      * 
350      * @see spcp7.imagegallery.contentprovider.face.ContentConnectionFace#open(java.util.Map)
351      */
352     public void open(Map<String, PropertyModelFace> properties)
353 	    throws PropertyValidationException,
354 	    ContentProviderAuthenticationException {
355 	if (!properties.containsKey(AlfrescoDefaultProperties.ALFRESCO_USERNAME
356 		.toString())) {
357 	    throw new PropertyValidationException("Property "
358 		    + AlfrescoDefaultProperties.ALFRESCO_USERNAME.toString()
359 		    + " not found", AlfrescoDefaultProperties.ALFRESCO_USERNAME
360 		    .toString(), "not set");
361 
362 	}
363 	if (!properties.containsKey(AlfrescoDefaultProperties.ALFRESCO_PASSWORD
364 		.toString())) {
365 	    throw new PropertyValidationException("Property "
366 		    + AlfrescoDefaultProperties.ALFRESCO_PASSWORD.toString()
367 		    + " not found", AlfrescoDefaultProperties.ALFRESCO_PASSWORD
368 		    .toString(), "not set");
369 
370 	}
371 	// Start the session
372 	try {
373 	    AuthenticationUtils.startSession(properties.get(
374 		    AlfrescoDefaultProperties.ALFRESCO_USERNAME.toString())
375 		    .getWert(), properties.get(
376 		    AlfrescoDefaultProperties.ALFRESCO_PASSWORD.toString())
377 		    .getWert());
378 	} catch (AuthenticationFault e) {
379 	    throw new ContentProviderAuthenticationException(
380 		    "Authentication with the content provider failed! Maybe you provided wrong credentials. If so"
381 			    + " change property \""
382 			    + AlfrescoDefaultProperties.ALFRESCO_USERNAME
383 				    .toString()
384 			    + "\" and \""
385 			    + AlfrescoDefaultProperties.ALFRESCO_USERNAME
386 				    .toString() + "\" to correct values.", e,
387 		    AlfrescoContentProviderImpl.contentProviderTypeID);
388 	}
389 	// Get a reference to the respository web service
390 	this.repositoryService = WebServiceFactory.getRepositoryService();
391     }
392 
393     /**
394      * This method and {@link #createFolder(String, Map)} are currently only for
395      * testing purposes. That is for inserting and deleting test content. Later
396      * they could be used within a class implementing the
397      * {@link ContentSubmitterFace}. The key
398      * {@link DefaultProperties#SPCP7_CURRENT_PATH} defines the foldr which
399      * should be deleted.
400      * 
401      * @param properties
402      *                The following properties are required:
403      *                {@link AlfrescoDefaultProperties#ALFRESCO_SPACES_STORE},
404      *                {@link AlfrescoDefaultProperties#ALFRESCO_WORKSPACE_STORE},
405      *                {@link DefaultProperties#SPCP7_CURRENT_PATH}
406      * @throws ContentCouldNotBeAccessedException
407      *                 if the folder could not be deleted or the repository
408      *                 could not be reached.
409      */
410     public synchronized void removeFolder(
411 	    Map<String, PropertyModelFace> properties)
412 	    throws ContentCouldNotBeAccessedException {
413 	if (properties == null) {
414 	    throw new ContentCouldNotBeAccessedException(
415 		    "ProprietaryId and/or supplied properties must not be null!");
416 	}
417 	Store store = new Store(properties.get(
418 		AlfrescoDefaultProperties.ALFRESCO_WORKSPACE_STORE.toString())
419 		.getWert(), properties.get(
420 		AlfrescoDefaultProperties.ALFRESCO_SPACES_STORE.toString())
421 		.getWert());
422 	PropertyModelFace currentPath = properties
423 		.get(DefaultProperties.SPCP7_CURRENT_PATH.toString());
424 	Reference folderToDeleteReference = new Reference(store, null,
425 		currentPath.getWert());
426 	// Check to see if the folder exists
427 	Node[] node = null;
428 	try {
429 	    node = WebServiceFactory.getRepositoryService().get(
430 		    new Predicate(new Reference[] { folderToDeleteReference },
431 			    store, null));
432 	} catch (Exception e1) {
433 	    // The folder does not exist
434 	    // We do nothing
435 	    log.debug("We do nothing because the folder does not exist");
436 	}
437 	if (node != null) {
438 	    // UpdateResult[] results = null;
439 	    Predicate predicate = new Predicate();
440 	    predicate.setStore(store);
441 	    // Reference ref = new Reference();
442 	    // ref.setStore(store);
443 	    // ref.setPath(currentPath.getWert());
444 	    predicate.setNodes(new Reference[] { folderToDeleteReference });
445 
446 	    // delete Folder
447 	    CML cml = new CML();
448 	    CMLDelete cmldelete = new CMLDelete();
449 	    cmldelete.setWhere(predicate);
450 	    cml.setDelete(new CMLDelete[] { cmldelete });
451 
452 	    try {
453 		this.repositoryService.update(cml);
454 	    } catch (RepositoryFault e) {
455 		// We print a stacktrace at this point AND throw an exception
456 		// because otherwise the detail data of the axisfault gets lost
457 		e.printStackTrace();
458 		throw new ContentCouldNotBeAccessedException(
459 			"The repository threw an exception when trying to delete a folder!",
460 			e);
461 	    } catch (RemoteException e) {
462 		throw new ContentCouldNotBeAccessedException(
463 			"The repository could not be reached when trying to delete a folder!",
464 			e);
465 	    }
466 	}
467 
468     }
469 
470     /**
471      * Injected by Spring.
472      * 
473      * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
474      */
475     public void setApplicationContext(ApplicationContext arg0)
476 	    throws BeansException {
477 	this.applicationContext = arg0;
478     }
479 
480     /**
481      * Injected by Spring.
482      * 
483      * @param contentComparator
484      *                the contentComparator to set
485      */
486     public void setContentComparator(Comparator<ContentFace> contentComparator) {
487 	this.contentComparator = contentComparator;
488     }
489 
490     /**
491      * Injected by Spring.
492      * 
493      * @param imageFilterFace
494      *                the imageFilterFace to set
495      */
496     public void setImageFilter(ImageFilterFace imageFilterFace) {
497 	this.imageFilterFace = imageFilterFace;
498     }
499 
500     private ResultSet executeQuery(String queryString,
501 	    Map<String, PropertyModelFace> properties)
502 	    throws ContentCouldNotBeAccessedException, NoContentFoundException {
503 	ResultSet resultSet = null;
504 	Store store = new Store(properties.get(
505 		AlfrescoDefaultProperties.ALFRESCO_WORKSPACE_STORE.toString())
506 		.getWert(), properties.get(
507 		AlfrescoDefaultProperties.ALFRESCO_SPACES_STORE.toString())
508 		.getWert());
509 	// encode the string the right way so that we find everything
510 	log.debug("getting volumes from query \"" + queryString + "\"");
511 	Query query = new Query(Constants.QUERY_LANG_LUCENE, queryString);
512 	// Execute the query
513 	QueryResult queryResult;
514 	try {
515 	    queryResult = this.repositoryService.query(store, query, false);
516 	    // organize the results
517 	    resultSet = queryResult.getResultSet();
518 	} catch (RepositoryFault e) {
519 	    throw new ContentCouldNotBeAccessedException(
520 		    "The repository threw an Exception when trying to execute a query!",
521 		    e);
522 	} catch (RemoteException e) {
523 	    throw new ContentCouldNotBeAccessedException(
524 		    "The repository could not be reached when trying to execute a query!",
525 		    e);
526 	}
527 	if (resultSet.getRows() == null) {
528 	    throw new NoContentFoundException(
529 		    "No volumes at given path found!", queryString);
530 	}
531 	return resultSet;
532     }
533 
534     private List<ContentFace> transformResultSet(
535 	    Map<String, PropertyModelFace> properties, ResultSet resultSet,
536 	    int lowerLimit, int upperLimit) {
537 	List<ContentFace> retList = new ArrayList<ContentFace>();
538 	ResultSetRow[] rows = resultSet.getRows();
539 	if (rows == null) {
540 	    // Exception is handled before. Only for preventing nullpointers
541 	    // Normally this should never be reached
542 	    log.warn("No volumes for query found!");
543 	} else {
544 	    if (rows.length < upperLimit) {
545 		upperLimit = rows.length;
546 	    }
547 	    if (rows.length < lowerLimit) {
548 		lowerLimit = rows.length;
549 	    }
550 	    // Regrettably the webservice api from alfresco does not allow a
551 	    // lucene limitation of results, so we have to do this manually
552 	    for (int x = lowerLimit - 1; x < upperLimit; x++) {
553 		ResultSetRow row = rows[x];
554 		NamedValue[] columns = row.getColumns();
555 		ContentFace cf = (ContentFace) this.applicationContext
556 			.getBean("ContentDTO");
557 		cf.setDirectory(true);
558 		for (int y = 0; y < columns.length; y++) {
559 		    if (row.getColumns(y).getName().endsWith("node-uuid")) {
560 			cf.setProprietaryId(row.getColumns(y).getValue());
561 		    } else if (row.getColumns(y).getName().endsWith("name")) {
562 			cf.setName(row.getColumns(y).getValue());
563 		    } else if (row.getColumns(y).getName().endsWith("path")) {
564 			cf.setPath(this.alfrescoUtils.normalizePathNamespace(
565 				row.getColumns(y).getValue(), properties));
566 		    } else if (row.getColumns(y).getName().endsWith("content")) {
567 			cf.setDirectory(false);
568 			if (this.imageFilterFace != null) {
569 			    if (this.imageFilterFace.acceptImageMimetype(row
570 				    .getColumns(y).getValue())) {
571 				cf.setImage(true);
572 			    } else {
573 				// Maybe the mimetype was not correctly set.
574 				if (this.imageFilterFace.accept(cf.getName())) {
575 				    cf.setImage(true);
576 				}
577 			    }
578 			}
579 		    }
580 		    cf.setParentContentFolderProperties(StandardUtils
581 			    .deepCopy(properties));
582 		    cf
583 			    .setContentProviderTypeId(AlfrescoContentProviderImpl.contentProviderTypeID);
584 		}
585 		cf.setUrl(properties.get(
586 			AlfrescoDefaultProperties.ALFRESCO_BASE_URL.toString())
587 			.getWert()
588 			+ "/" + cf.getProprietaryId() + "/" + cf.getName());
589 		String[] splitName = cf.getName().split("\\.");
590 		cf.setFileExtension(splitName[splitName.length - 1]);
591 		retList.add(cf);
592 		// }
593 	    }
594 	}
595 	return retList;
596     }
597 
598     /**
599      * Injected by Spring.
600      * 
601      * @param alfrescoValidation
602      *                the alfrescoValidation to set
603      */
604     public void setAlfrescoValidation(AlfrescoValidation alfrescoValidation) {
605 	this.alfrescoValidation = alfrescoValidation;
606     }
607 
608     /**
609      * Injected by Spring.
610      * 
611      * @param generalValidation
612      *                the generalValidation to set
613      */
614     public void setGeneralValidation(GeneralValidation generalValidation) {
615 	this.generalValidation = generalValidation;
616     }
617 
618     /**
619      * Injected by Spring.
620      * 
621      * @param alfrescoUtils
622      *                the alfrescoUtils to set
623      */
624     public void setAlfrescoUtils(AlfrescoUtils alfrescoUtils) {
625 	this.alfrescoUtils = alfrescoUtils;
626     }
627 
628 }