
org.structr.files.cmis.AbstractStructrCmisService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of structr-ui Show documentation
Show all versions of structr-ui Show documentation
Structr is an open source framework based on the popular Neo4j graph database.
The newest version!
/**
* Copyright (C) 2010-2016 Structr GmbH
*
* This file is part of Structr .
*
* Structr is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Structr 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Structr. If not, see .
*/
package org.structr.files.cmis;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.chemistry.opencmis.commons.data.Properties;
import org.apache.chemistry.opencmis.commons.data.PropertyData;
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
import org.structr.cmis.CMISInfo;
import org.structr.common.SecurityContext;
import org.structr.core.GraphObject;
import org.structr.core.app.StructrApp;
/**
*
*
*/
public abstract class AbstractStructrCmisService {
public StructrCMISService parentService = null;
public SecurityContext securityContext = null;
public AbstractStructrCmisService(final StructrCMISService parentService, final SecurityContext securityContext) {
this.parentService = parentService;
this.securityContext = securityContext;
}
public void log(final Logger logger, final Object... objects) {
final StringBuilder buf = new StringBuilder();
for (int i=0; i> data = properties.getProperties();
if (data != null) {
final PropertyData> value = data.get(key);
if (value != null) {
return value.getFirstValue();
}
}
return null;
}
public String getStringValue(final Properties properties, final String key) {
final Object value = getValue(properties, key);
if (value != null && value instanceof String) {
return (String)value;
}
return null;
}
/**
* Returns the CMIS info that is defined in the given Structr type, or null.
*
* @param type
* @return
*/
public CMISInfo getCMISInfo(final Class extends GraphObject> type) {
try { return type.newInstance().getCMISInfo(); } catch (Throwable t) {}
return null;
}
/**
* Returns the baseTypeId that is defined in the given Structr type, or null.
* @param type
* @return
*/
public BaseTypeId getBaseTypeId(final Class extends GraphObject> type) {
final CMISInfo info = getCMISInfo(type);
if (info != null) {
return info.getBaseTypeId();
}
return null;
}
/**
* Returns the enum value for the given typeId, or null if no such value exists.
*
* @param typeId
* @return
*/
public BaseTypeId getBaseTypeId(final String typeId) {
try { return BaseTypeId.fromValue(typeId); } catch (IllegalArgumentException iex) {}
return null;
}
/**
* Returns the Structr type for the given objectTypeId, or the defaultClass of the objectTypeId
* matches the given baseTypeId.
*
* @param objectTypeId
* @param defaultType
* @param defaultClass
*
* @return a Structr type
*/
public Class typeFromObjectTypeId(final String objectTypeId, final BaseTypeId defaultType, final Class defaultClass) {
// default for cmuis:folder
if (defaultType.value().equals(objectTypeId)) {
return defaultClass;
}
return StructrApp.getConfiguration().getNodeEntityClass(objectTypeId);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy