本文整理汇总了Java中org.apache.chemistry.opencmis.client.api.Session.getTypeDefinition方法的典型用法代码示例。如果您正苦于以下问题:Java Session.getTypeDefinition方法的具体用法?Java Session.getTypeDefinition怎么用?Java Session.getTypeDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.chemistry.opencmis.client.api.Session
的用法示例。
在下文中一共展示了Session.getTypeDefinition方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCanConnectCMISUsingDefaultTenantImpl
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
private void testCanConnectCMISUsingDefaultTenantImpl(Binding binding, String cmisVersion)
{
String url = httpClient.getPublicApiCmisUrl(TenantUtil.DEFAULT_TENANT, binding, cmisVersion, null);
Map<String, String> parameters = new HashMap<String, String>();
// user credentials
parameters.put(SessionParameter.USER, "admin");
parameters.put(SessionParameter.PASSWORD, "admin");
parameters.put(SessionParameter.ATOMPUB_URL, url);
parameters.put(SessionParameter.BROWSER_URL, url);
parameters.put(SessionParameter.BINDING_TYPE, binding.getOpenCmisBinding().value());
SessionFactory factory = SessionFactoryImpl.newInstance();
// perform request : http://host:port/alfresco/api/-default-/public/cmis/versions/${cmisVersion}/${binding}
List<Repository> repositories = factory.getRepositories(parameters);
assertTrue(repositories.size() > 0);
parameters.put(SessionParameter.REPOSITORY_ID, TenantUtil.DEFAULT_TENANT);
Session session = factory.createSession(parameters);
// perform request : http://host:port/alfresco/api/-default-/public/cmis/versions/${cmisVersion}/${binding}/type?id=cmis:document
ObjectType objectType = session.getTypeDefinition("cmis:document");
assertNotNull(objectType);
}
示例2: searchDocuments
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
private List<org.apache.chemistry.opencmis.client.api.Document> searchDocuments() throws ParseException {
// Copia mappa parametri poiché l'originale è immutabile
Map<String, String[]> lMapParams = new HashMap<String, String[]>(httpRequest.getParameterMap());
Session lSession = Util.getUserAlfrescoSession(httpRequest);
String[] lStrTypeFilter = lMapParams.remove("type");
String lStrTypeId =
lStrTypeFilter != null && StringUtils.isNotBlank(lStrTypeFilter[0])
? lStrTypeFilter[0]
: mAlfrescoBaseTypeId;
// TODO (Alessio): gestione CmisNotFound
TypeDefinition lTypeDef = lSession.getTypeDefinition(lStrTypeId);
List<CmisQueryPredicate<?>> lListPredicates = getQueryPredicates(lTypeDef, lMapParams);
CmisQueryBuilder lQB = new CmisQueryBuilder(lSession);
String lStrQuery = lQB.selectFrom(lStrTypeId, (String[]) null).where(lListPredicates).build();
List<org.apache.chemistry.opencmis.client.api.Document> lList =
AlfrescoHelper.searchDocuments(lSession, lStrQuery);
return lList;
}
示例3: prepareContentStream
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
protected ContentStream prepareContentStream(Session session,
File contentFile, String typeId, Map<String, Object> properties)
throws Exception {
ObjectType docType = session.getTypeDefinition(typeId);
TikaProperties tikaProperties = new TikaProperties(contentFile);
tikaProperties.setDocumentType(docType);
tikaProperties.enrichProperties(session, properties);
String name = (String) properties.get(PropertyIds.NAME);
long size = contentFile.length();
String mimetype = tikaProperties.getMIMEType();
InputStream stream = new BufferedInputStream(new FileInputStream(
contentFile));
return session.getObjectFactory().createContentStream(name, size,
mimetype, stream);
}
示例4: findDocumentType
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
/**
* Identifies the document type from content.
*/
public ObjectType findDocumentType(Session session) {
// get the type id for the MIME type
String newTypeId = TikaMappingService
.getRepositoryTypeIdFromMIMEType(getMIMEType());
// check if type exists in the repository
try {
docType = session.getTypeDefinition(newTypeId);
} catch (CmisObjectNotFoundException e) {
// type not found -> fall back to cmis:document
docType = session.getTypeDefinition(BaseTypeId.CMIS_DOCUMENT
.value());
}
return docType;
}
示例5: getTypeDefinition
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public static ObjectType getTypeDefinition(Session pSession, String pStrId) {
mLog.debug("START getDocumentType(String)");
ObjectType lType = null;
try {
lType = pSession.getTypeDefinition(pStrId, true);
} catch (CmisObjectNotFoundException e) {
// Niente: il tipo non esiste e si restituisce null
mLog.debug("Tipo '{}' non trovato", pStrId);
}
mLog.debug("END getDocumentType(String)");
return lType;
}
示例6: getCreatableTypes
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
/**
* Returns the creatable descendants types of the given type.
*/
public static List<ObjectType> getCreatableTypes(Session session,
String rootTypeId) {
List<ObjectType> result = new ArrayList<ObjectType>();
// get the root type
ObjectType rootType = null;
try {
rootType = session.getTypeDefinition(rootTypeId);
} catch (CmisObjectNotFoundException e) {
return result; // empty
}
// get the descendants and add the creatable subtypes
List<Tree<ObjectType>> types = session.getTypeDescendants(
rootTypeId, -1, false);
addType(types, result);
// finally, add the root type, if it is creatable
boolean isCreatable = (rootType.isCreatable() == null ? true
: rootType.isCreatable().booleanValue());
if (isCreatable) {
result.add(rootType);
}
// sort the list by display name
Collections.sort(result, new Comparator<ObjectType>() {
public int compare(ObjectType ot1, ObjectType ot2) {
return ot1.getDisplayName().compareTo(ot2.getDisplayName());
}
});
return result;
}
示例7: doPost
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
@Override
protected void doPost(HttpServletRequest request,
HttpServletResponse response, Session session)
throws ServletException, IOException {
String q = getStringParameter(request, PARAM_Q);
int skip = getIntParameter(request, PARAM_SKIP, 0);
request.setAttribute(ATTR_Q, q);
boolean supportCombinedFulltext = (session.getRepositoryInfo()
.getCapabilities().getQueryCapability() == CapabilityQuery.BOTHCOMBINED);
QueryStatement stmt = session
.createQueryStatement("SELECT cmis:objectId, cmis:objectTypeId, "
+ "cmis:name, cmis:lastModificationDate "
+ "FROM cmis:document "
+ "WHERE IN_TREE(?) AND (cmis:name LIKE ? OR "
+ "cmis:contentStreamFileName LIKE ?"
+ (supportCombinedFulltext ? " OR CONTAINS(?)" : "")
+ ") " + "ORDER BY cmis:lastModificationDate DESC");
stmt.setString(1, getApplicationRootFolderId(request));
stmt.setStringLike(2, "%" + q + "%");
stmt.setStringLike(3, "%" + q + "%");
stmt.setStringContains(4, q);
request.setAttribute(ATTR_CQL, stmt.toQueryString());
ItemIterable<QueryResult> results = stmt.query(false);
// get only a page
List<Map<String, Object>> resultsList = new ArrayList<Map<String, Object>>();
ItemIterable<QueryResult> resultsPage = results.skipTo(
skip * QUERY_PAGE_SIZE).getPage(QUERY_PAGE_SIZE);
for (QueryResult qr : resultsPage) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("cmis:name",
qr.getPropertyValueByQueryName("cmis:name"));
row.put("cmis:objectId",
qr.getPropertyValueByQueryName("cmis:objectId"));
ObjectType type = session.getTypeDefinition((String) qr
.getPropertyValueByQueryName("cmis:objectTypeId"));
row.put("type", type.getDisplayName());
row.put("cmis:lastModificationDate",
qr.getPropertyValueByQueryName("cmis:lastModificationDate"));
resultsList.add(row);
}
request.setAttribute(ATTR_RESULTS, resultsList);
// show search page
dispatch("search.jsp", "Search. The Blend.", request, response);
}
示例8: doGet
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response, Session session)
throws ServletException, IOException {
String tag = getStringParameter(request, PARAM_TAG);
int skip = getIntParameter(request, PARAM_SKIP, 0);
request.setAttribute(ATTR_TAG, tag);
if (tag != null) {
tag = tag.trim();
QueryStatement stmt = session
.createQueryStatement("SELECT cmis:objectId, cmis:objectTypeId, "
+ "cmis:name, cmis:lastModificationDate, "
+ IdMapping
.getRepositoryPropertyQueryName("cmisbook:tags")
+ " AS tags "
+ "FROM "
+ IdMapping
.getRepositoryTypeQueryName("cmisbook:taggable")
+ " "
+ "WHERE IN_TREE(?) "
+ "AND ? = ANY "
+ IdMapping
.getRepositoryPropertyQueryName("cmisbook:tags")
+ " " + "ORDER BY cmis:lastModificationDate DESC");
stmt.setString(1, getApplicationRootFolderId(request));
stmt.setString(2, tag);
request.setAttribute(ATTR_CQL, stmt.toQueryString());
ItemIterable<QueryResult> results = stmt.query(false);
// get only a page
List<Map<String, Object>> resultsList = new ArrayList<Map<String, Object>>();
ItemIterable<QueryResult> resultsPage = results.skipTo(
skip * QUERY_PAGE_SIZE).getPage(QUERY_PAGE_SIZE);
for (QueryResult qr : resultsPage) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("cmis:name",
qr.getPropertyValueByQueryName("cmis:name"));
row.put("cmis:objectId",
qr.getPropertyValueByQueryName("cmis:objectId"));
ObjectType type = session.getTypeDefinition((String) qr
.getPropertyValueByQueryName("cmis:objectTypeId"));
row.put("type", type.getDisplayName());
row.put("cmis:lastModificationDate", qr
.getPropertyValueByQueryName("cmis:lastModificationDate"));
row.put("cmisbook:tags",
qr.getPropertyMultivalueByQueryName("tags")); // using the
// alias
resultsList.add(row);
}
request.setAttribute(ATTR_RESULTS, resultsList);
}
// show tags page
dispatch("tags.jsp", "Tags. The Blend.", request, response);
}