本文整理了Java中info.magnolia.cms.core.Path
类的一些代码示例,展示了Path
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path
类的具体详情如下:
包路径:info.magnolia.cms.core.Path
类名称:Path
[英]Utility class to retrieve files or directory used by Magnolia. Examples: cache directory, tmp files, ..
[中]检索Magnolia使用的文件或目录的实用程序类。示例:缓存目录、tmp文件。。
代码示例来源:origin: info.magnolia.dam/magnolia-dam-app
/**
* Create a new Node Unique NodeName.
*/
public static String generateUniqueNodeNameForAsset(final Node node, String newNodeName) throws RepositoryException {
return Path.getUniqueLabel(node.getSession(), node.getParent().getPath(), Path.getValidatedLabel(newNodeName));
}
代码示例来源:origin: info.magnolia.dam/magnolia-dam-app
/**
* MGNLDAM-286 For test only; we need a partial mock there otherwise Path fails when getting MAGNOLIA_APP_ROOTDIR system property.
*/
File getTempDirectory() {
return Path.getTempDirectory();
}
代码示例来源:origin: info.magnolia/magnolia-module-data
public void setFileURL(String url) {
if (!StringUtils.contains(url, "://")) {
this.fileURL = "file://" + Path.getAbsoluteFileSystemPath(url);
}
else {
this.fileURL = url;
}
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* @deprecated since 5.5.3 without replacement {@see info.magnolia.repository.DefaultRepositoryManager#loadRepositories()} and {@see info.magnolia.cms.util.ConfigUtil}
*/
public static File getRepositoriesConfigFile() {
String path = SystemProperty.getProperty(MagnoliaConfigurationProperties.MAGNOLIA_REPOSITORIES_CONFIG);
return isAbsolute(path) ? new File(path) : new File(getAppRootDir(), path);
}
代码示例来源:origin: net.sourceforge.openutils/openutils-mgnlutils
/**
* retrieve validate label for input string
* @param value the string to validate
* @return the validated label, or null if value was null
* @see {@link Path#getValidatedLabel(String)}
*/
public static String getValidatedLabel(String value)
{
if (value == null)
{
return null;
}
return Path.getValidatedLabel(value);
}
代码示例来源:origin: net.sourceforge.openutils/openutils-mgnlutils
@SuppressWarnings("deprecation")
public static String getUniqueLabel(Node parent, String label)
{
return Path.getUniqueLabel(info.magnolia.cms.util.ContentUtil.asContent(parent), label);
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void getAbsoluteFileSystemPathPrependsApplicationRootDirIfPathIsRelative() throws Exception {
String relPath = "WEB-INF/config";
String returnedPath = Path.getAbsoluteFileSystemPath(relPath);
assertEquals(Path.getAppRootDir().getCanonicalPath() + "/" + relPath, returnedPath);
}
代码示例来源:origin: info.magnolia/magnolia-module-forum
/**
* Cleans up a String, making it appropriate for usage as a node name.
*/
protected String cleanup(String s) {
if (StringUtils.isEmpty(s)) {
return "_";
}
// TODO : getValidatedLabel() should be copied/moved to a more appropriate(ly named) class?
return Path.getValidatedLabel(s).toLowerCase();
}
代码示例来源:origin: info.magnolia.contacts/magnolia-contacts
/**
* Create a new Node Unique NodeName.
*/
private String generateUniqueNodeNameForContact(final Node node) throws RepositoryException {
String newNodeName = defineNodeName(node);
return Path.getUniqueLabel(node.getSession(), node.getParent().getPath(), newNodeName);
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* @deprecated since 5.5.3 without replacement
*/
public static File getHistoryFile() {
String path = SystemProperty.getProperty(MagnoliaConfigurationProperties.MAGNOLIA_EXCHANGE_HISTORY);
return isAbsolute(path) ? new File(path) : new File(getAppRootDir(), path);
}
代码示例来源:origin: info.magnolia/magnolia-module-inplace-templating
@Override
protected void setNodeName(Node node, JcrNodeAdapter item) throws RepositoryException {
if (item.isNew()) {
NodeUtil.renameNode(node, Path.getUniqueLabel(node.getSession(), node.getParent().getPath(), Path.getValidatedLabel(UNTITLED_TEMPLATE)));
}
}
代码示例来源:origin: info.magnolia.contacts/magnolia-contacts
/**
* Define the Node Name. Node Name = First Char of the lastName + the full
* firstName. lastName = eric firstName = tabli The node name is etabli
*/
private String defineNodeName(final Node node) throws RepositoryException {
String intitialFirstName = node.getProperty("firstName").getString();
String firstName = StringUtils.isNotBlank(intitialFirstName) ? intitialFirstName.trim() : intitialFirstName;
String lastName = node.getProperty("lastName").getString().trim();
return Path.getValidatedLabel((firstName.charAt(0) + lastName.replaceAll("\\s+", "")).toLowerCase());
}
}
代码示例来源:origin: info.magnolia/magnolia-module-forum
protected String makeNameUnique(Content parent, String name) {
return Path.getUniqueLabel(parent.getJCRNode(), cleanup(name));
}
代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework
File getTempFile() throws IOException {
if (tempFile == null) {
// Create a temporary file that will hold the data created by the export command.
tempFile = File.createTempFile(tempFileName, tempFileExtension, Path.getTempDirectory());
}
return tempFile;
}
}
代码示例来源:origin: info.magnolia/magnolia-module-data
public void setZipFileURL(String url) {
if (!StringUtils.contains(url, "://")) {
this.zipFileURL = "file://" + Path.getAbsoluteFileSystemPath(url);
}
else {
this.zipFileURL = url;
}
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* @deprecated since 5.5.3 without replacement.
*/
public static File getCacheDirectory() {
String path = SystemProperty.getProperty(MagnoliaConfigurationProperties.MAGNOLIA_CACHE_STARTDIR);
File dir = isAbsolute(path) ? new File(path) : new File(getAppRootDir(), path);
dir.mkdirs();
return dir;
}
代码示例来源:origin: info.magnolia.dam/magnolia-dam-app
/**
* Insert unique increment before the extension in case of asset; primarily deduce reference name from the fileName property.
*/
@Override
protected String getUniqueNewItemName(Item referenceItem, Node destination) throws RepositoryException {
if (referenceItem.isNode() && ((Node) referenceItem).isNodeType(Asset.NAME)) {
Node resourceNode = AssetResource.getResourceNodeFromAsset(((Node) referenceItem));
if (resourceNode != null) {
String extension = PropertyUtil.getString(resourceNode, AssetResource.EXTENSION, EMPTY);
String fileName = PropertyUtil.getString(resourceNode, AssetResource.FILENAME);
String referenceName = (fileName != null && fileName.endsWith(extension)) ? fileName : fileName + "." + extension;
return Path.getUniqueLabel(destination.getSession(), destination.getPath(), Path.getValidatedLabel(referenceName), extension);
}
}
return super.getUniqueNewItemName(referenceItem, destination);
}
}
代码示例来源:origin: info.magnolia/magnolia-module-rssaggregator
@SuppressWarnings("unchecked")
@Override
public void writeToItem(T newValue) {
String value = Path.getValidatedLabel((String) newValue);
Property<T> p = getOrCreateProperty(type);
p.setValue((T) value);
}
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void getUniqueLabelWithExtension() throws Exception {
Session session = new MockSession(RepositoryConstants.CONFIG);
Node parent = session.getRootNode();
parent.addNode("a.txt");
parent.addNode("b.txt");
parent.addNode("b0.txt");
assertThat(Path.getUniqueLabel(session, parent.getPath(), "a.txt", "txt"), equalTo("a0.txt"));
assertThat(Path.getUniqueLabel(session, parent.getPath(), "b.txt", "txt"), equalTo("b1.txt"));
assertThat(Path.getUniqueLabel(session, parent.getPath(), "b0.txt", "txt"), equalTo("b1.txt"));
assertThat(Path.getUniqueLabel(session, parent.getPath(), "c.txt", "txt"), equalTo("c.txt"));
assertThat(Path.getUniqueLabel(session, parent.getPath(), "a.foo", "txt"), equalTo("a.foo"));
assertThat(Path.getUniqueLabel(session, parent.getPath(), "a.txt", "bar"), equalTo("a.txt0"));
}
}
代码示例来源:origin: info.magnolia.dam/magnolia-dam-app
@Inject
public AssetUploadReceiver(SimpleTranslator i18n, DamAppConfiguration damAppConfig) {
super(Path.getTempDirectory(), i18n);
this.appConfig = damAppConfig;
}
内容来源于网络,如有侵权,请联系作者删除!