本文整理汇总了Java中org.alfresco.service.cmr.view.ImporterException类的典型用法代码示例。如果您正苦于以下问题:Java ImporterException类的具体用法?Java ImporterException怎么用?Java ImporterException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImporterException类属于org.alfresco.service.cmr.view包,在下文中一共展示了ImporterException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindPlaceHolder
import org.alfresco.service.cmr.view.ImporterException; //导入依赖的package包/类
/**
* Bind the specified value to the passed configuration values if it is a place holder
*
* @param value the value to bind
* @param binding the configuration properties to bind to
* @return the bound value
*/
private String bindPlaceHolder(String value, ImporterBinding binding)
{
if (binding != null)
{
int iStartBinding = value.indexOf(START_BINDING_MARKER);
while (iStartBinding != -1)
{
int iEndBinding = value.indexOf(END_BINDING_MARKER, iStartBinding + START_BINDING_MARKER.length());
if (iEndBinding == -1)
{
throw new ImporterException("Cannot find end marker " + END_BINDING_MARKER + " within value " + value);
}
String key = value.substring(iStartBinding + START_BINDING_MARKER.length(), iEndBinding);
String keyValue = binding.getValue(key);
if (keyValue == null) {
logger.warn("No binding value for placeholder (will default to empty string): " + value);
}
value = StringUtils.replace(value, START_BINDING_MARKER + key + END_BINDING_MARKER, keyValue == null ? "" : keyValue);
iStartBinding = value.indexOf(START_BINDING_MARKER);
}
}
return value;
}
示例2: importStream
import org.alfresco.service.cmr.view.ImporterException; //导入依赖的package包/类
public InputStream importStream(String content)
{
ZipArchiveEntry zipEntry = zipFile.getEntry(content);
if (zipEntry == null)
{
// Note: for some reason, when modifying a zip archive the path seperator changes
// TODO: Need to investigate further as to why and whether this workaround is enough
content = content.replace('\\', '/');
zipEntry = zipFile.getEntry(content);
if (zipEntry == null)
{
throw new ImporterException("Failed to find content " + content + " within zip package");
}
}
try
{
return zipFile.getInputStream(zipEntry);
}
catch (IOException e)
{
throw new ImporterException("Failed to open content " + content + " within zip package due to " + e.getMessage(), e);
}
}
示例3: importMetaData
import org.alfresco.service.cmr.view.ImporterException; //导入依赖的package包/类
public void importMetaData(Map<QName, String> properties)
{
// Determine if we're importing a complete repository
String complexPath = properties.get(QName.createQName(NamespaceService.REPOSITORY_VIEW_1_0_URI, "exportOf"));
for (String path : complexPath.split(","))
{
if (path != null && path.equals("/"))
{
// Only allow complete repository import into root
NodeRef storeRootRef = nodeService.getRootNode(rootRef.getStoreRef());
if (!storeRootRef.equals(rootRef))
{
throw new ImporterException("A complete repository package cannot be imported here");
}
}
}
}
示例4: importStream
import org.alfresco.service.cmr.view.ImporterException; //导入依赖的package包/类
public InputStream importStream(String content)
{
ResourceLoader loader = new DefaultResourceLoader();
Resource resource = loader.getResource(content);
if (resource.exists() == false)
{
throw new ImporterException("Content URL " + content + " does not exist.");
}
try
{
return resource.getInputStream();
}
catch(IOException e)
{
throw new ImporterException("Failed to retrieve input stream for content URL " + content);
}
}
示例5: processMetaData
import org.alfresco.service.cmr.view.ImporterException; //导入依赖的package包/类
/**
* Process meta-data
*
* @param xpp XmlPullParser
* @param metaDataName QName
* @param parserContext ParserContext
* @throws XmlPullParserException
* @throws IOException
*/
private void processMetaData(XmlPullParser xpp, QName metaDataName, ParserContext parserContext)
throws XmlPullParserException, IOException
{
MetaDataContext metaData = (MetaDataContext)parserContext.elementStack.peek();
String value = null;
int eventType = xpp.next();
if (eventType == XmlPullParser.TEXT)
{
// Extract value
value = xpp.getText();
eventType = xpp.next();
}
if (eventType != XmlPullParser.END_TAG)
{
throw new ImporterException("Meta data element " + metaDataName + " is missing end tag");
}
metaData.setProperty(metaDataName, value);
}
示例6: processAspect
import org.alfresco.service.cmr.view.ImporterException; //导入依赖的package包/类
/**
* Process aspect definition
*
* @param xpp XmlPullParser
* @param aspectDef AspectDefinition
* @param parserContext ParserContext
* @throws XmlPullParserException
* @throws IOException
*/
private void processAspect(XmlPullParser xpp, AspectDefinition aspectDef, ParserContext parserContext)
throws XmlPullParserException, IOException
{
NodeContext node = peekNodeContext(parserContext.elementStack);
node.addAspect(aspectDef);
int eventType = xpp.next();
if (eventType != XmlPullParser.END_TAG)
{
throw new ImporterException("Aspect " + aspectDef.getName() + " definition is not valid - it cannot contain any elements");
}
if (logger.isDebugEnabled())
logger.debug(indentLog("Processed aspect " + aspectDef.getName(), parserContext.elementStack.size()));
}
示例7: importStream
import org.alfresco.service.cmr.view.ImporterException; //导入依赖的package包/类
@Override
public InputStream importStream(String contentPath)
{
String content = config.getImportContent(contentPath);
if (content == null)
{
return null;
}
String siteContent = content.replace(SITEID_PLACEHOLDER, siteId);
try
{
return new ByteArrayInputStream(siteContent.getBytes("UTF-8"));
}
catch(UnsupportedEncodingException e)
{
throw new ImporterException("Failed to read content " + contentPath, e);
}
}
示例8: importStream
import org.alfresco.service.cmr.view.ImporterException; //导入依赖的package包/类
public InputStream importStream(String content)
{
File fileURL = new File(content);
if (fileURL.isAbsolute() == false)
{
fileURL = new File(sourceDir, content);
}
try
{
return new FileInputStream(fileURL);
}
catch(IOException e)
{
throw new ImporterException("Failed to read content url " + content + " from file " + fileURL.getAbsolutePath());
}
}
示例9: getNodeRef
import org.alfresco.service.cmr.view.ImporterException; //导入依赖的package包/类
/**
* Get the Node Ref from the specified Location
*
* @param location the location
* @return the node reference
*/
private NodeRef getNodeRef(Location location)
{
ParameterCheck.mandatory("Location", location);
// Establish node to export from
NodeRef nodeRef = (location == null) ? null : location.getNodeRef();
if (nodeRef == null)
{
// If a specific node has not been provided, default to the root
nodeRef = nodeService.getRootNode(location.getStoreRef());
}
// Resolve to path within node, if one specified
String path = (location == null) ? null : location.getPath();
if (path != null && path.length() >0)
{
// Create a valid path and search
List<NodeRef> nodeRefs = searchService.selectNodes(nodeRef, path, null, namespaceService, false);
if (nodeRefs.size() == 0)
{
throw new ImporterException("Path " + path + " within node " + nodeRef + " does not exist - the path must resolve to a valid location");
}
if (nodeRefs.size() > 1)
{
throw new ImporterException("Path " + path + " within node " + nodeRef + " found too many locations - the path must resolve to one location");
}
nodeRef = nodeRefs.get(0);
}
// TODO: Check Node actually exists
return nodeRef;
}
示例10: startImport
import org.alfresco.service.cmr.view.ImporterException; //导入依赖的package包/类
public void startImport()
{
log("Importing from zip file " + file.getAbsolutePath());
try
{
// NOTE: This encoding allows us to workaround bug...
// http://bugs.sun.com/bugdatabase/view_bug.do;:WuuT?bug_id=4820807
zipFile = new ZipFile(file, "UTF-8");
}
catch(IOException e)
{
throw new ImporterException("Failed to read zip file due to " + e.getMessage(), e);
}
}
示例11: endImport
import org.alfresco.service.cmr.view.ImporterException; //导入依赖的package包/类
public void endImport()
{
if (zipFile != null)
{
try
{
zipFile.close();
}
catch (IOException e)
{
throw new ImporterException("Failed to close zip package " + file.getAbsolutePath(), e);
}
}
}
示例12: importView
import org.alfresco.service.cmr.view.ImporterException; //导入依赖的package包/类
public void importView(ImportPackageHandler importHandler, Location location, ImporterBinding binding, ImporterProgress progress) throws ImporterException
{
importHandler.startImport();
Reader dataFileReader = importHandler.getDataStream();
NodeRef nodeRef = getNodeRef(location, binding);
parserImport(nodeRef, location, dataFileReader, importHandler, binding, progress);
importHandler.endImport();
}
示例13: getNodeRef
import org.alfresco.service.cmr.view.ImporterException; //导入依赖的package包/类
/**
* Get Node Reference from Location
*
* @param location the location to extract node reference from
* @param binding import configuration
* @return node reference
*/
private NodeRef getNodeRef(Location location, ImporterBinding binding)
{
ParameterCheck.mandatory("Location", location);
// Establish node to import within
NodeRef nodeRef = location.getNodeRef();
if (nodeRef == null)
{
// If a specific node has not been provided, default to the root
nodeRef = nodeService.getRootNode(location.getStoreRef());
}
// Resolve to path within node, if one specified
String path = location.getPath();
if (path != null && path.length() >0)
{
// Create a valid path and search
path = bindPlaceHolder(path, binding);
path = createValidPath(path);
List<NodeRef> nodeRefs = searchService.selectNodes(nodeRef, path, null, namespaceService, false);
if (nodeRefs.size() == 0)
{
throw new ImporterException("Path " + path + " within node " + nodeRef + " does not exist - the path must resolve to a valid location");
}
if (nodeRefs.size() > 1)
{
throw new ImporterException("Path " + path + " within node " + nodeRef + " found too many locations - the path must resolve to one location");
}
nodeRef = nodeRefs.get(0);
}
// TODO: Check Node actually exists
return nodeRef;
}
示例14: ViewParser
import org.alfresco.service.cmr.view.ImporterException; //导入依赖的package包/类
/**
* Construct
*/
public ViewParser()
{
try
{
// Construct Xml Pull Parser Factory
factory = XmlPullParserFactory.newInstance(System.getProperty(XmlPullParserFactory.PROPERTY_NAME), this.getClass());
factory.setNamespaceAware(true);
}
catch (XmlPullParserException e)
{
throw new ImporterException("Failed to initialise view importer", e);
}
}
示例15: createImportReference
import org.alfresco.service.cmr.view.ImporterException; //导入依赖的package包/类
/**
* Maps an Import Id to a Node Reference
*
* @param importId import Id
* @param nodeRef node reference
*/
private void createImportReference(ParserContext parserContext, String importId, NodeRef nodeRef)
{
if (parserContext.importIds.containsKey(importId))
{
throw new ImporterException("Import id " + importId + " already specified within import file");
}
parserContext.importIds.put(importId, nodeRef);
}