diff --git a/source/java/org/alfresco/repo/exporter/ExporterComponent.java b/source/java/org/alfresco/repo/exporter/ExporterComponent.java index c0df6329f4..2f14b6f33e 100644 --- a/source/java/org/alfresco/repo/exporter/ExporterComponent.java +++ b/source/java/org/alfresco/repo/exporter/ExporterComponent.java @@ -36,7 +36,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.alfresco.model.ContentModel; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.PropertyDefinition; @@ -179,6 +178,8 @@ public class ExporterComponent */ public void exportView(ExportPackageHandler exportHandler, ExporterCrawlerParameters parameters, Exporter progress) { + System.out.println("PATCHED EXPORTERCOMPONENT FOR MIKEF"); + ParameterCheck.mandatory("Stream Handler", exportHandler); // create exporter around export handler @@ -455,6 +456,7 @@ public class ExporterComponent if (parameters.isCrawlChildNodes()) { exporter.startAssocs(nodeRef); + QName prevAssocType = null; List childAssocs = nodeService.getChildAssocs(nodeRef); for (int i = 0; i < childAssocs.size(); i++) { @@ -469,15 +471,20 @@ public class ExporterComponent nodesWithSecondaryLinks.put(nodeRef, nodeRef); continue; } - if (i == 0 || childAssocs.get(i - 1).getTypeQName().equals(childAssocType) == false) + if (prevAssocType == null || prevAssocType.equals(childAssocType) == false) { + if (prevAssocType != null) + { + exporter.endAssoc(nodeRef, prevAssocType); + } exporter.startAssoc(nodeRef, childAssocType); + prevAssocType = childAssocType; } if (!isExcludedURI(parameters.getExcludeNamespaceURIs(), childAssoc.getQName().getNamespaceURI())) { walkNode(childAssoc.getChildRef(), parameters, exporter, false); } - if (i == childAssocs.size() - 1 || childAssocs.get(i + 1).getTypeQName().equals(childAssocType) == false) + if (i == childAssocs.size() - 1) { exporter.endAssoc(nodeRef, childAssocType); } @@ -553,12 +560,13 @@ public class ExporterComponent { // export property of datatype CONTENT ContentReader reader = contentService.getReader(nodeRef, property); - if (!parameters.isCrawlContent() || reader == null || reader.exists() == false) + if (true) { // export an empty url for the content ContentData contentData = (ContentData)value; - ContentData noContentURL = new ContentData("", contentData.getMimetype(), contentData.getSize(), contentData.getEncoding()); - exporter.content(nodeRef, property, null, noContentURL, index); +// ContentData noContentURL = new ContentData("", contentData.getMimetype(), contentData.getSize(), contentData.getEncoding()); +// exporter.content(nodeRef, property, null, noContentURL, index); + exporter.value(nodeRef, property, contentData, index); exporter.warning("Skipped content for property " + property + " on node " + nodeRef); } else @@ -703,15 +711,15 @@ public class ExporterComponent */ private boolean isExcludeAspect(QName aspectQName) { - if (aspectQName.equals(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT) || - aspectQName.equals(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION)) - { - return true; - } - else - { +// if (aspectQName.equals(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT) || +// aspectQName.equals(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION)) +// { +// return true; +// } +// else +// { return false; - } +// } } /** diff --git a/source/java/org/alfresco/repo/importer/ImporterComponent.java b/source/java/org/alfresco/repo/importer/ImporterComponent.java index d75fc62a85..3883b98f3f 100644 --- a/source/java/org/alfresco/repo/importer/ImporterComponent.java +++ b/source/java/org/alfresco/repo/importer/ImporterComponent.java @@ -220,6 +220,7 @@ public class ImporterComponent */ public void importView(Reader viewReader, Location location, ImporterBinding binding, ImporterProgress progress) { + System.out.println("PATCHED IMPORTERCOMPONENT FOR MIKEF"); NodeRef nodeRef = getNodeRef(location, binding); parserImport(nodeRef, location.getChildAssocType(), viewReader, new DefaultStreamHandler(), binding, progress); } @@ -229,6 +230,7 @@ public class ImporterComponent */ public void importView(ImportPackageHandler importHandler, Location location, ImporterBinding binding, ImporterProgress progress) throws ImporterException { + System.out.println("PATCHED IMPORTERCOMPONENT FOR MIKEF"); importHandler.startImport(); Reader dataFileReader = importHandler.getDataStream(); NodeRef nodeRef = getNodeRef(location, binding); @@ -660,17 +662,18 @@ public class ImporterComponent { DataTypeDefinition dataTypeDef = dictionaryService.getDataType(DataTypeDefinition.CONTENT); ContentData contentData = (ContentData)DefaultTypeConverter.INSTANCE.convert(dataTypeDef, importContentData); - String contentUrl = contentData.getContentUrl(); - if (contentUrl != null && contentUrl.length() > 0) - { - // import the content from the url - InputStream contentStream = streamHandler.importStream(contentUrl); - ContentWriter writer = contentService.getWriter(nodeRef, propertyName, true); - writer.setEncoding(contentData.getEncoding()); - writer.setMimetype(contentData.getMimetype()); - writer.putContent(contentStream); - reportContentCreated(nodeRef, contentUrl); - } + nodeService.setProperty(nodeRef, propertyName, contentData); +// String contentUrl = contentData.getContentUrl(); +// if (contentUrl != null && contentUrl.length() > 0) +// { +// // import the content from the url +// InputStream contentStream = streamHandler.importStream(contentUrl); +// ContentWriter writer = contentService.getWriter(nodeRef, propertyName, true); +// writer.setEncoding(contentData.getEncoding()); +// writer.setMimetype(contentData.getMimetype()); +// writer.putContent(contentStream); +// reportContentCreated(nodeRef, contentUrl); +// } } } diff --git a/source/java/org/alfresco/repo/jscript/ScriptNode.java b/source/java/org/alfresco/repo/jscript/ScriptNode.java index 351467e6e2..9f29f65134 100644 --- a/source/java/org/alfresco/repo/jscript/ScriptNode.java +++ b/source/java/org/alfresco/repo/jscript/ScriptNode.java @@ -70,6 +70,7 @@ import org.alfresco.service.cmr.version.VersionType; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.util.Content; import org.alfresco.util.GUID; import org.alfresco.util.ParameterCheck; import org.alfresco.util.URLEncoder; @@ -2159,62 +2160,10 @@ public class ScriptNode implements Serializable, Scopeable // Inner Classes - /** - * Inner class for representing content - */ - public static abstract class ScriptContent implements Serializable - { - /** - * @return the content stream as a string - */ - public abstract String getContent(); - - public String jsGet_content() - { - return getContent(); - } - - /** - * @return the content mimetype - */ - public abstract String getMimetype(); - - public String jsGet_mimetype() - { - return getMimetype(); - } - - /** - * @return the content encoding - */ - public abstract String getEncoding(); - - public String jsGet_encoding() - { - return getEncoding(); - } - - /** - * @return the content size - */ - public abstract long getSize(); - - public long jsGet_size() - { - return getSize(); - } - - /** - * @return input stream onto content - */ - /*package*/ abstract InputStream getInputStream(); - } - - /** * Inner class wrapping and providing access to a ContentData property */ - public class ScriptContentData extends ScriptContent implements Serializable + public class ScriptContentData implements Content, Serializable { private static final long serialVersionUID = -7819328543933312278L; @@ -2241,7 +2190,7 @@ public class ScriptNode implements Serializable, Scopeable return (reader != null && reader.exists()) ? reader.getContentString() : ""; } - /*package*/ InputStream getInputStream() + public InputStream getInputStream() { ContentService contentService = services.getContentService(); ContentReader reader = contentService.getReader(nodeRef, property); @@ -2275,7 +2224,7 @@ public class ScriptNode implements Serializable, Scopeable * * @param content ScriptContent to set */ - public void write(ScriptContent content) + public void write(Content content) { ContentService contentService = services.getContentService(); ContentWriter writer = contentService.getWriter(nodeRef, this.property, true); @@ -2371,79 +2320,6 @@ public class ScriptNode implements Serializable, Scopeable private QName property; } - - /** - * Inner class wrapping and providing access to a Content stream - */ - public static class ScriptContentStream extends ScriptContent implements Serializable - { - private static final long serialVersionUID = -7819328543933312278L; - - /** - * Constructor - * - * @param stream content input stream - * @param mimetype content mimetype - */ - public ScriptContentStream(InputStream stream, String mimetype, String encoding) - { - this.stream = stream; - this.mimetype = mimetype; - this.encoding = encoding; - } - - /* (non-Javadoc) - * @see org.alfresco.repo.jscript.ScriptNode.ScriptContent#getContent() - */ - public String getContent() - { - try - { - ByteArrayOutputStream os = new ByteArrayOutputStream(); - FileCopyUtils.copy(stream, os); // both streams are closed - byte[] bytes = os.toByteArray(); - // get the encoding for the string - String encoding = getEncoding(); - // create the string from the byte[] using encoding if necessary - String content = (encoding == null) ? new String(bytes) : new String(bytes, encoding); - // done - return content; - } - catch (IOException e) - { - throw new ContentIOException("Failed to copy content to string", e); - } - } - - /*package*/ InputStream getInputStream() - { - return stream; - } - - public long getSize() - { - return -1; - } - - public String getMimetype() - { - return mimetype; - } - - public String getEncoding() - { - return encoding; - } - - - private InputStream stream; - - private String mimetype; - - private String encoding; - } - - /** * Interface contract for simple anonymous classes that implement document transformations */ diff --git a/source/java/org/alfresco/repo/template/AbsoluteUrlMethod.java b/source/java/org/alfresco/repo/template/AbsoluteUrlMethod.java deleted file mode 100644 index c7ea810323..0000000000 --- a/source/java/org/alfresco/repo/template/AbsoluteUrlMethod.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2005-2007 Alfresco Software Limited. - * - * 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. - - * As a special exception to the terms and conditions of version 2.0 of - * the GPL, you may redistribute this Program in connection with Free/Libre - * and Open Source Software ("FLOSS") applications as described in Alfresco's - * FLOSS exception. You should have recieved a copy of the text describing - * the FLOSS exception, and it is also available here: - * http://www.alfresco.com/legal/licensing" - */ -package org.alfresco.repo.template; - -import java.util.List; - -import freemarker.template.TemplateMethodModelEx; -import freemarker.template.TemplateModelException; -import freemarker.template.TemplateScalarModel; - -/** - * @author David Caruana - * - * Custom FreeMarker Template language method. - *

- * Render absolute url for the specified url (only if the url isn't already absolute). - *

- * Usage: absurl(String url) - */ -public final class AbsoluteUrlMethod implements TemplateMethodModelEx -{ - private String basePath; - - /** - * Construct - * - * @param basePath base path used to construct absolute url - */ - public AbsoluteUrlMethod(String basePath) - { - this.basePath = basePath; - } - - - /** - * @see freemarker.template.TemplateMethodModel#exec(java.util.List) - */ - public Object exec(List args) throws TemplateModelException - { - String result = ""; - - if (args.size() == 1) - { - Object arg0 = args.get(0); - if (arg0 instanceof TemplateScalarModel) - { - result = ((TemplateScalarModel)arg0).getAsString(); - if (result.startsWith("/")) - { - result = basePath + result; - } - } - } - - return result; - } -}