/* * Copyright (C) 2005 Alfresco, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 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