/* * Copyright (C) 2005 Alfresco, Inc. * * Licensed under the Mozilla Public License version 1.1 * with a permitted attribution clause. You may obtain a * copy of the License at * * http://www.alfresco.org/legal/license.txt * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific * language governing permissions and limitations under the * License. */ package org.alfresco.example; import java.io.File; import java.io.Serializable; import java.util.HashMap; import java.util.Map; import org.alfresco.model.ContentModel; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.TransactionUtil.TransactionWork; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.GUID; import org.alfresco.util.TempFileProvider; import org.alfresco.util.debug.NodeStoreInspector; import org.springframework.context.ApplicationContext; /** * A quick example of how to *
* * All the normal checks for missing resources and so forth have been left out in the interests * of clarity of demonstration. * *
* To change the model being used, make changes to the dictionaryDAO bean in the
* application contenxt XML file. For now, this example is written against the
* generic alfresco/model/contentModel.xml
.
*
* The content store location can also be set in the application context. * * * @author Derek Hulley */ public class SimpleExampleWithContent { private static final String NAMESPACE = "http://www.alfresco.org/test/SimpleExampleWithContent"; public static void main(String[] args) { // initialise app content ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); // get registry of services final ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); // begin a UserTransaction // All the services are set to create or propogate the transaction. // This transaction will be recognised and propogated // The TransactionUtil takes care of the catching and rollback, etc TransactionService transactionService = serviceRegistry.getTransactionService(); TransactionWork