1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  package org.apache.chemistry.opencmis.server.impl.dummy;
20  
21  import org.apache.chemistry.opencmis.commons.impl.server.AbstractServiceFactory;
22  import org.apache.chemistry.opencmis.commons.server.CallContext;
23  import org.apache.chemistry.opencmis.commons.server.CmisService;
24  
25  import org.apache.commons.logging.Log;
26  import org.apache.commons.logging.LogFactory;
27  
28  import java.util.Map;
29  
30  
31  
32  
33  
34  public class DummyServicesFactory extends AbstractServiceFactory
35  {
36      private static final String REPOSITORY_ID = "repository.id";
37      private static final String REPOSITORY_ID_DEFAULT = "test-rep";
38      private static final String REPOSITORY_NAME = "repository.name";
39      private static final String REPOSITORY_NAME_DEFAULT = "Test Repository";
40      private static final Log LOG = LogFactory.getLog( DummyServicesFactory.class.getName(  ) );
41      private DummyService service;
42      private String id;
43      private String name;
44  
45      @Override
46      public void init( Map<String, String> parameters )
47      {
48          
49          id = parameters.get( REPOSITORY_ID );
50  
51          if ( ( id == null ) || ( id.trim(  ).length(  ) == 0 ) )
52          {
53              id = REPOSITORY_ID_DEFAULT;
54          }
55  
56          
57          name = parameters.get( REPOSITORY_NAME );
58  
59          if ( ( name == null ) || ( name.trim(  ).length(  ) == 0 ) )
60          {
61              name = REPOSITORY_NAME_DEFAULT;
62          }
63  
64          
65          service = new DummyService( id, name );
66  
67          LOG.info( "Initialized dummy repository '" + name + "' (" + id + ")" );
68      }
69  
70      @Override
71      public void destroy(  )
72      {
73          LOG.info( "Destroyed dummy repository '" + name + "' (" + id + ")" );
74      }
75  
76      @Override
77      public CmisService getService( CallContext context )
78      {
79          return service;
80      }
81  }