()
- {
- public Boolean execute() throws Throwable
- {
- return applyUrlLiftingInTxn(running);
- }
- };
- return transactionHelper.doInTransaction(callback, false, true);
- }
-
- private boolean applyUrlLiftingInTxn(final AtomicBoolean running) throws Exception
- {
- // Check the store
- if (!contentStore.isWriteSupported())
- {
- logger.info(I18NUtil.getMessage("patch.convertContentUrls.store.readOnly"));
- return true;
- }
-
- Boolean admDone = (Boolean) registryService.getProperty(KEY_ADM_DONE);
-
- if ((admDone == null || !admDone.booleanValue()))
- {
- logger.info(I18NUtil.getMessage("patch.convertContentUrls.store.pending"));
- return false;
- }
-
- // Must we run at all?
- Boolean done = (Boolean) registryService.getProperty(KEY_STORE_DONE);
- if (done != null && done.booleanValue())
- {
- logger.info(I18NUtil.getMessage("patch.convertContentUrls.store.done"));
- return true;
- }
-
- final long totalSize = contentStore.getSpaceTotal();
- final MutableLong currentSize = new MutableLong(0L);
-
- final MutableInt count = new MutableInt();
- count.setValue(0);
- ContentUrlHandler handler = new ContentUrlHandler()
- {
- private int allCount = 0;
- public void handle(String contentUrl)
- {
- if (!running.get())
- {
- // Either VM shutdown or lock release. Either way, bug out.
- throw new VmShutdownListener.VmShutdownException();
- }
-
- ContentReader reader = contentStore.getReader(contentUrl);
- if (!reader.exists())
- {
- // Not there any more
- return;
- }
- currentSize.setValue(currentSize.longValue() + reader.getSize());
-
- // Create a savepoint
- String savepointName = new Long(System.nanoTime()).toString();
- Savepoint savepoint = controlDAO.createSavepoint(savepointName);
- try
- {
- contentDataDAO.createContentUrlOrphaned(contentUrl, null);
- controlDAO.releaseSavepoint(savepoint);
- count.setValue(count.intValue()+1);
- }
- catch (DataIntegrityViolationException e)
- {
- // That's OK, the URL was already managed
- controlDAO.rollbackToSavepoint(savepoint);
- }
- allCount++;
- if (allCount % batchSize == 0)
- {
- if (totalSize < 0)
- {
- // Report
- logger.info(I18NUtil.getMessage("patch.convertContentUrls.store.progress", allCount));
- }
- else
- {
- ContentUrlConverterPatch.super.reportProgress(totalSize, currentSize.longValue());
- }
- }
- }
- };
- try
- {
- contentStore.getUrls(handler);
- }
- catch (UnsupportedOperationException e)
- {
- logger.info(I18NUtil.getMessage("patch.convertContentUrls.store.noSupport"));
- }
- catch (VmShutdownException e)
- {
- // We didn't manage to complete
- return false;
- }
- // Record the completion
- done = Boolean.TRUE;
- registryService.addProperty(KEY_STORE_DONE, done);
-
- // Done
- logger.info(I18NUtil.getMessage("patch.convertContentUrls.store.scheduled", count.intValue(), contentStore));
-
- return true;
- }
-
- /**
- * Job to initiate the {@link ContentUrlConverterPatch}
- *
- * @author Derek Hulley
- * @since 3.2.1
- */
- public static class ContentUrlConverterJob implements Job
- {
- public ContentUrlConverterJob()
- {
- }
-
- /**
- * Calls the cleaner to do its work
- */
- public void execute(JobExecutionContext context) throws JobExecutionException
- {
- JobDataMap jobData = context.getJobDetail().getJobDataMap();
- // extract the content cleaner to use
- Object contentUrlConverterObj = jobData.get("contentUrlConverter");
- if (contentUrlConverterObj == null || !(contentUrlConverterObj instanceof ContentUrlConverterPatch))
- {
- throw new AlfrescoRuntimeException(
- "'contentUrlConverter' data must contain valid 'ContentUrlConverter' reference");
- }
- ContentUrlConverterPatch contentUrlConverter = (ContentUrlConverterPatch) contentUrlConverterObj;
- contentUrlConverter.executeViaJob();
- }
- }
-}
diff --git a/source/java/org/alfresco/repo/admin/patch/impl/EmailTemplatesInviteAndNotifyFoldersPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/EmailTemplatesInviteAndNotifyFoldersPatch.java
deleted file mode 100755
index b3e4e258b8..0000000000
--- a/source/java/org/alfresco/repo/admin/patch/impl/EmailTemplatesInviteAndNotifyFoldersPatch.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
-* Copyright (C) 2005-2010 Alfresco Software Limited.
-*
-* This file is part of Alfresco
-*
-* Alfresco is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Lesser General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* Alfresco 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 Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public License
-* along with Alfresco. If not, see .
-*/
-
-package org.alfresco.repo.admin.patch.impl;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.alfresco.model.ApplicationModel;
-import org.alfresco.model.ContentModel;
-import org.alfresco.repo.admin.patch.AbstractPatch;
-import org.alfresco.repo.importer.ImporterBootstrap;
-import org.alfresco.service.cmr.admin.PatchException;
-import org.alfresco.service.cmr.repository.ChildAssociationRef;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.repository.StoreRef;
-import org.alfresco.service.namespace.QName;
-import org.springframework.context.MessageSource;
-import org.springframework.extensions.surf.util.I18NUtil;
-
-/**
- * Ensures that the invite email templates and notify email templates folders are present.
- *
- * This uses the bootstrap importer to get the paths to look for. If not present,
- * the required structures are created.
- *
- *
- * @author valerysh
- *
- */
-public class EmailTemplatesInviteAndNotifyFoldersPatch extends AbstractPatch {
-
- public static final String PROPERTY_COMPANY_HOME_CHILDNAME = "spaces.company_home.childname";
- public static final String PROPERTY_DICTIONARY_CHILDNAME = "spaces.dictionary.childname";
- public static final String PROPERTY_EMAIL_TEMPLATES_FOLDER_CHILDNAME = "spaces.templates.email.childname";
- public static final String PROPERTY_EMAIL_NOTIFY_TEMPLATES_FOLDER_CHILDNAME = "spaces.templates.email.notify.childname";
- public static final String PROPERTY_EMAIL_INVITE_TEMPLATES_FOLDER_CHILDNAME = "spaces.templates.email.invite1.childname";
- private static final String PROPERTY_EMAIL_NOTIFY_TEMPLATES_FOLDER_NAME = "spaces.notify_templates.email.name";
- private static final String PROPERTY_EMAIL_NOTIFY_TEMPLATES_FOLDER_DESCRIPTION = "spaces.notify_templates.email.description";
- private static final String PROPERTY_EMAIL_INVITE_TEMPLATES_FOLDER_NAME = "spaces.invite_templates.email.name";
- private static final String PROPERTY_EMAIL_INVITE_TEMPLATES_FOLDER_DESCRIPTION = "spaces.invite_templates.email.description";
-
- private static final String SAMPLE_NOTIFY_TEMPLATE_NAME = "notify_user_email.ftl.sample";
- private static final String INVITE_TEMPLATE_NAME = "invite_user_email.ftl";
-
- private static final String MSG_EMAIL_INVITE_TEMPLATES_FOLDER_EXISTS = "patch.emailInviteTemplatesFolder.result.exists";
- private static final String MSG_EMAIL_INVITE_TEMPLATES_FOLDER_CREATED = "patch.emailInviteTemplatesFolder.result.created";
- private static final String MSG_EMAIL_NOTIFY_TEMPLATES_FOLDER_EXISTS = "patch.emailNotifyTemplatesFolder.result.exists";
- private static final String MSG_EMAIL_NOTIFY_TEMPLATES_FOLDER_CREATED = "patch.emailNotifyTemplatesFolder.result.created";
-
- private static final String PROPERTY_ICON = "space-icon-default";
-
- private ImporterBootstrap importerBootstrap;
- private MessageSource messageSource;
-
- protected NodeRef emailNotifyTemplatesFolderNodeRef;
- protected NodeRef emailInviteTemplatesFolderNodeRef;
-
- protected Properties configuration;
- protected NodeRef emailTemplatesFolderNodeRef;
-
- private String emailTemplatesFolderXPath;
-
- public void setImporterBootstrap(ImporterBootstrap importerBootstrap)
- {
- this.importerBootstrap = importerBootstrap;
- }
-
- public void setMessageSource(MessageSource messageSource)
- {
- this.messageSource = messageSource;
- }
-
- /**
- * Ensure that required common properties have been set
- */
- protected void checkCommonProperties() throws Exception
- {
- checkPropertyNotNull(importerBootstrap, "importerBootstrap");
- checkPropertyNotNull(messageSource, "messageSource");
- }
-
- /**
- * Extracts pertinent references and properties that are common to execution
- * of this and derived patches.
- */
- protected void setUp() throws Exception
- {
- // get the node store that we must work against
- StoreRef storeRef = importerBootstrap.getStoreRef();
- if (storeRef == null)
- {
- throw new PatchException("Bootstrap store has not been set");
- }
- NodeRef storeRootNodeRef = nodeService.getRootNode(storeRef);
-
- this.configuration = importerBootstrap.getConfiguration();
-
- // get the association names that form the path
- String companyHomeChildName = configuration.getProperty(PROPERTY_COMPANY_HOME_CHILDNAME);
- if (companyHomeChildName == null || companyHomeChildName.length() == 0)
- {
- throw new PatchException("Bootstrap property '" + PROPERTY_COMPANY_HOME_CHILDNAME + "' is not present");
- }
- String dictionaryChildName = configuration.getProperty(PROPERTY_DICTIONARY_CHILDNAME);
- if (dictionaryChildName == null || dictionaryChildName.length() == 0)
- {
- throw new PatchException("Bootstrap property '" + PROPERTY_DICTIONARY_CHILDNAME + "' is not present");
- }
- String emailTemplatesChildName = configuration.getProperty(PROPERTY_EMAIL_TEMPLATES_FOLDER_CHILDNAME);
- if (emailTemplatesChildName == null || emailTemplatesChildName.length() == 0)
- {
- throw new PatchException("Bootstrap property '" + PROPERTY_EMAIL_TEMPLATES_FOLDER_CHILDNAME + "' is not present");
- }
-
- String emailNotifyTemplatesChildName = configuration.getProperty(PROPERTY_EMAIL_NOTIFY_TEMPLATES_FOLDER_CHILDNAME);
- if (emailNotifyTemplatesChildName == null || emailNotifyTemplatesChildName.length() == 0)
- {
- throw new PatchException("Bootstrap property '" + PROPERTY_EMAIL_NOTIFY_TEMPLATES_FOLDER_CHILDNAME + "' is not present");
- }
-
- String emailInviteTemplatesChildName = configuration.getProperty(PROPERTY_EMAIL_INVITE_TEMPLATES_FOLDER_CHILDNAME);
- if (emailInviteTemplatesChildName == null || emailInviteTemplatesChildName.length() == 0)
- {
- throw new PatchException("Bootstrap property '" + PROPERTY_EMAIL_INVITE_TEMPLATES_FOLDER_CHILDNAME + "' is not present");
- }
-
- StringBuilder sb = new StringBuilder();
- sb.append("/").append(companyHomeChildName)
- .append("/").append(dictionaryChildName)
- .append("/").append(emailTemplatesChildName);
- emailTemplatesFolderXPath = sb.toString();
-
- // get the email templates node
- List nodeRefs = searchService.selectNodes(storeRootNodeRef, emailTemplatesFolderXPath, null, namespaceService, false);
- if (nodeRefs.size() == 0)
- {
- throw new PatchException("XPath didn't return any results: \n" +
- " root: " + storeRootNodeRef + "\n" +
- " xpath: " + emailTemplatesFolderXPath);
- }
- else if (nodeRefs.size() > 1)
- {
- throw new PatchException("XPath returned too many results: \n" +
- " root: " + storeRootNodeRef + "\n" +
- " xpath: " + emailTemplatesFolderXPath + "\n" +
- " results: " + nodeRefs);
- }
- this.emailTemplatesFolderNodeRef = nodeRefs.get(0);
-
- emailNotifyTemplatesFolderNodeRef = searchFolder(emailNotifyTemplatesChildName);
- emailInviteTemplatesFolderNodeRef = searchFolder(emailInviteTemplatesChildName);
- }
-
- @Override
- protected String applyInternal() throws Exception
- {
- // common properties must be set before we can continue
- checkCommonProperties();
- if (messageSource == null)
- {
- throw new PatchException("'messageSource' property has not been set");
- }
-
- setUp();
-
- // create the folder if needed - output a message to describe the result
- StringBuffer msg = new StringBuffer();
- if (emailNotifyTemplatesFolderNodeRef == null)
- {
- emailNotifyTemplatesFolderNodeRef = createFolderAndMoveTemplate(PROPERTY_EMAIL_NOTIFY_TEMPLATES_FOLDER_CHILDNAME,
- PROPERTY_EMAIL_NOTIFY_TEMPLATES_FOLDER_NAME,
- PROPERTY_EMAIL_NOTIFY_TEMPLATES_FOLDER_DESCRIPTION,
- SAMPLE_NOTIFY_TEMPLATE_NAME);
- msg.append(I18NUtil.getMessage(MSG_EMAIL_NOTIFY_TEMPLATES_FOLDER_CREATED, emailNotifyTemplatesFolderNodeRef));
- }
- else
- {
- msg.append(I18NUtil.getMessage(MSG_EMAIL_NOTIFY_TEMPLATES_FOLDER_EXISTS, emailNotifyTemplatesFolderNodeRef));
- }
- msg.append("; ");
- if (emailInviteTemplatesFolderNodeRef == null)
- {
- emailInviteTemplatesFolderNodeRef = createFolderAndMoveTemplate(PROPERTY_EMAIL_INVITE_TEMPLATES_FOLDER_CHILDNAME,
- PROPERTY_EMAIL_INVITE_TEMPLATES_FOLDER_NAME,
- PROPERTY_EMAIL_INVITE_TEMPLATES_FOLDER_DESCRIPTION,
- INVITE_TEMPLATE_NAME);
- msg.append(I18NUtil.getMessage(MSG_EMAIL_INVITE_TEMPLATES_FOLDER_CREATED, emailNotifyTemplatesFolderNodeRef));
- }
- else
- {
- msg.append(I18NUtil.getMessage(MSG_EMAIL_INVITE_TEMPLATES_FOLDER_EXISTS, emailNotifyTemplatesFolderNodeRef));
- }
-
- return msg.toString();
- }
-
- private NodeRef searchFolder(String xpath)
- {
- List nodeRefs = searchService.selectNodes(emailTemplatesFolderNodeRef, xpath, null, namespaceService, false);
- if (nodeRefs.size() > 1)
- {
- throw new PatchException("XPath returned too many results: \n" +
- " email templates node: " + emailTemplatesFolderNodeRef + "\n" +
- " xpath: " + xpath + "\n" +
- " results: " + nodeRefs);
- }
- else if (nodeRefs.size() == 0)
- {
- // the node does not exist
- return null;
- }
- else
- {
- return nodeRefs.get(0);
- }
- }
-
- private NodeRef createFolderAndMoveTemplate(String folderChildName, String folderName, String folderDescription, String templateName)
- {
- // get required properties
- String emailTemplatesChildName = configuration.getProperty(folderChildName);
- if (emailTemplatesChildName == null)
- {
- throw new PatchException("Bootstrap property '" + folderChildName + "' is not present");
- }
-
- String emailTemplatesName = messageSource.getMessage(
- folderName,
- null,
- I18NUtil.getLocale());
- if (emailTemplatesName == null || emailTemplatesName.length() == 0)
- {
- throw new PatchException("Bootstrap property '" + folderName + "' is not present");
- }
-
- String emailTemplatesDescription = messageSource.getMessage(
- folderDescription,
- null,
- I18NUtil.getLocale());
- if (emailTemplatesDescription == null || emailTemplatesDescription.length() == 0)
- {
- throw new PatchException("Bootstrap property '" + folderDescription + "' is not present");
- }
-
- Map properties = new HashMap(7);
- properties.put(ContentModel.PROP_NAME, emailTemplatesName);
- properties.put(ContentModel.PROP_TITLE, emailTemplatesName);
- properties.put(ContentModel.PROP_DESCRIPTION, emailTemplatesDescription);
- properties.put(ApplicationModel.PROP_ICON, PROPERTY_ICON);
-
- // create the node
- ChildAssociationRef childAssocRef = nodeService.createNode(
- emailTemplatesFolderNodeRef,
- ContentModel.ASSOC_CONTAINS,
- QName.resolveToQName(namespaceService, emailTemplatesChildName),
- ContentModel.TYPE_FOLDER,
- properties);
- NodeRef createdFolderNodeRef = childAssocRef.getChildRef();
-
- // add the required aspects
- nodeService.addAspect(createdFolderNodeRef, ApplicationModel.ASPECT_UIFACETS, null);
-
- //move template
- String xpath = emailTemplatesFolderXPath + "/cm:" + templateName;
- List templateNodeRefs = searchService.selectNodes(emailTemplatesFolderNodeRef, xpath, null, namespaceService, false);
- for (NodeRef templateNodeRef : templateNodeRefs)
- {
- QName qname = nodeService.getPrimaryParent(templateNodeRef).getQName();
- nodeService.moveNode(
- templateNodeRef,
- createdFolderNodeRef,
- ContentModel.ASSOC_CHILDREN,
- qname);
- }
-
- return createdFolderNodeRef;
- }
-}
diff --git a/source/java/org/alfresco/repo/admin/patch/impl/FixNameCrcValuesPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/FixNameCrcValuesPatch.java
deleted file mode 100644
index 63efb78f88..0000000000
--- a/source/java/org/alfresco/repo/admin/patch/impl/FixNameCrcValuesPatch.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.admin.patch.impl;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import java.sql.Savepoint;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import org.alfresco.error.StackTraceUtil;
-import org.alfresco.repo.admin.patch.AbstractPatch;
-import org.alfresco.repo.admin.patch.PatchExecuter;
-import org.alfresco.repo.batch.BatchProcessWorkProvider;
-import org.alfresco.repo.batch.BatchProcessor;
-import org.alfresco.repo.batch.BatchProcessor.BatchProcessWorker;
-import org.alfresco.repo.domain.control.ControlDAO;
-import org.alfresco.repo.domain.node.ChildAssocEntity;
-import org.alfresco.repo.domain.patch.PatchDAO;
-import org.alfresco.repo.domain.qname.QNameDAO;
-import org.alfresco.service.cmr.dictionary.AssociationDefinition;
-import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition;
-import org.alfresco.service.cmr.dictionary.DictionaryException;
-import org.alfresco.service.cmr.dictionary.DictionaryService;
-import org.alfresco.service.namespace.QName;
-import org.alfresco.util.TempFileProvider;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.extensions.surf.util.I18NUtil;
-
-/**
- * Fixes ETWOTWO-1133.
- * Checks all CRC values for alf_child_assoc.child_node_name_crc and alf_child_assoc.qname_crc.
- *
- * @author Derek Hulley
- * @since V2.2SP4
- */
-public class FixNameCrcValuesPatch extends AbstractPatch
-{
- private static final String MSG_SUCCESS = "patch.fixNameCrcValues.result";
- private static final String MSG_REWRITTEN = "patch.fixNameCrcValues.fixed";
- private static final String MSG_UNABLE_TO_CHANGE = "patch.fixNameCrcValues.unableToChange";
- private static final String MSG_FIXING_LOCALNAME = "patch.fixNameCrcValues.fixingLocalname";
- private static final String ERR_ASSOCIATION_TYPE_NOT_DEFINED = "patch.fixNameCrcValues.associationTypeNotDefined";
- private static final String ERR_ASSOCIATION_TYPE_NOT_CHILD = "patch.fixNameCrcValues.associationTypeNotChild";
-
- private PatchDAO patchDAO;
- private QNameDAO qnameDAO;
- private ControlDAO controlDAO;
- private DictionaryService dictionaryService;
-
- private int batchThreads = 2;
- private int batchSize = 1000;
- private long batchMaxQueryRange = Long.MAX_VALUE;
- private int batchQuerySize = 2000;
-
- private static Log logger = LogFactory.getLog(FixNameCrcValuesPatch.class);
- private static Log progress_logger = LogFactory.getLog(PatchExecuter.class);
-
- public FixNameCrcValuesPatch()
- {
- }
-
- public void setPatchDAO(PatchDAO patchDAO)
- {
- this.patchDAO = patchDAO;
- }
-
- /**
- * @param qnameDAO resolved QNames
- */
- public void setQnameDAO(QNameDAO qnameDAO)
- {
- this.qnameDAO = qnameDAO;
- }
-
- /**
- * @param controlDAO used to create Savepoints
- */
- public void setControlDAO(ControlDAO controlDAO)
- {
- this.controlDAO = controlDAO;
- }
-
- /**
- * @param dictionaryService used to check the child associations for unique checking
- */
- public void setDictionaryService(DictionaryService dictionaryService)
- {
- this.dictionaryService = dictionaryService;
- }
-
- /**
- * @param batchThreads the number of threads that will write child association changes
- */
- public void setBatchThreads(int batchThreads)
- {
- this.batchThreads = batchThreads;
- }
-
- /**
- * @param batchSize the number of child associations that will be modified per transaction
- */
- public void setBatchSize(int batchSize)
- {
- this.batchSize = batchSize;
- }
-
- /**
- * @param batchMaxQueryRange the largest ID range that the work provider can query for.
- * Lower this if the distribution of ID in alf_child_assoc is not
- * uniform and memory problems are encountered.
- */
- public void setBatchMaxQueryRange(long batchMaxQueryRange)
- {
- this.batchMaxQueryRange = batchMaxQueryRange;
- }
-
- /**
- * @param batchQuerySize the maximum number of results to pull back before handing off to
- * the threads (usually threads * batch size)
- */
- public void setBatchQuerySize(int batchQuerySize)
- {
- this.batchQuerySize = batchQuerySize;
- }
-
- @Override
- protected void checkProperties()
- {
- super.checkProperties();
- checkPropertyNotNull(patchDAO, "patchDAO");
- checkPropertyNotNull(qnameDAO, "qnameDAO");
- checkPropertyNotNull(controlDAO, "controlDAO");
- checkPropertyNotNull(dictionaryService, "dictionaryService");
- checkPropertyNotNull(applicationEventPublisher, "applicationEventPublisher");
- }
-
- @Override
- protected String applyInternal() throws Exception
- {
- // initialise the helper
- FixNameCrcValuesHelper helper = new FixNameCrcValuesHelper();
- try
- {
- String msg = helper.fixCrcValues();
- // done
- return msg;
- }
- finally
- {
- helper.closeWriter();
- }
- }
-
- private class FixNameCrcValuesHelper
- {
- private File logFile;
- private FileChannel channel;
- private Integer assocCount;
- private Long minAssocId = 0L;
- private Long maxAssocId;
-
- private FixNameCrcValuesHelper() throws IOException
- {
- // put the log file into a long life temp directory
- File tempDir = TempFileProvider.getLongLifeTempDir("patches");
- logFile = new File(tempDir, "FixNameCrcValuesPatch.log");
-
- // open the file for appending
- RandomAccessFile outputFile = new RandomAccessFile(logFile, "rw");
- channel = outputFile.getChannel();
- // move to the end of the file
- channel.position(channel.size());
- // add a newline and it's ready
- writeLine("").writeLine("");
- writeLine("FixNameCrcValuesPatch executing on " + new Date());
- }
-
- private FixNameCrcValuesHelper write(Object obj) throws IOException
- {
- channel.write(ByteBuffer.wrap(obj.toString().getBytes("UTF-8")));
- return this;
- }
- private FixNameCrcValuesHelper writeLine(Object obj) throws IOException
- {
- write(obj);
- write("\n");
- return this;
- }
- private void closeWriter()
- {
- try { channel.close(); } catch (Throwable e) {}
- }
-
- public String fixCrcValues() throws Exception
- {
- BatchProcessWorkProvider