[opencms-dev] Resource ID
Shi Yusen
shiys at langhua.cn
Thu Jul 13 09:46:50 CEST 2006
Hi Martin,
In OpenCms, one ResourceID could point to one or more StructureIDs. If more, it means there are siblings.
You can get a resource path from its StructureID by adding methods in the following files:
org.opencms.file.CmsObject:
public String getResourcePath(CmsUUID structureID) throws CmsException {
return (m_securityManager.getResourcePath(m_context, structureID));
}
org.opencms.db.CmsDriverManager.java:
public String getResourcePath(CmsDbContext dbc, CmsUUID structureID) throws CmsException{
return m_vfsDriver.getResourcePath(dbc, dbc.currentProject().getId(), structureID);
}
/org/opencms/db/generic/CmsVfsDriver.java:
public String getResourcePath(CmsDbContext dbc, int projectId, CmsUUID structureId) throws CmsDataAccessException {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet res = null;
String resourcePath = null;
String C_SELECT_ID = "select * from CMS_OFFLINE_STRUCTURE where " + "STRUCTURE_ID = ?";
try {
conn = m_sqlManager.getConnection(dbc, projectId);
stmt = conn.prepareStatement(C_SELECT_ID);
stmt.setString(1, resourceId.toString());
res = stmt.executeQuery();
if (res.next())
resourcePath = res.getString(4);
} catch (SQLException e) {
throw new CmsDbSqlException(Messages.get().container(
Messages.ERR_GENERIC_SQL_1,
CmsDbSqlException.getErrorQuery(stmt)), e);
} finally {
m_sqlManager.closeAll(dbc, conn, stmt, res);
}
return resourcePath;
}
Regards,
Shi Yusen/Beijing Langhua Ltd.
--------------------------------------------------------------
Tel: 86-10-88514088, 88514099
Fax: 86-10-88514099
Email: shiys at langhua.cn
Website: http://www.langhua.cn/
--------------------------------------------------------------
-----邮件原件-----
发件人: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] 代表 Christian Steinert
发送时间: 2006年7月13日 14:35
收件人: The OpenCms mailing list
主题: Re: [opencms-dev] Resource ID
Martin Bednář schrieb:
> Are there some resource ID that indetifies resource all the time
> accessible from JSP tag or scriplet ?
> I need some ID for Articles for binding to JForum and automatic Forum
> creation.
>
> Tnx Martin
>
I don't know how Jforum works, but each resource has a GUID. Each GUID
is uniquely identifying one content block, but there might be more than
one sibling that points to the same content block.
I don't know any way to translate a GUID to a resource, though and
technically a GUID could only translate to the set of all siblings that
commonly point to the same content block, not necessarily to just one
single file name.
You should be able to dig out files you want and access them with
classes CmsJspActionElement, CmsJspNavBuilder, CmsObject and CmsResource.
Check out org.opencms.file.CmsResource.getResourceId() in particular.
hth
christian
More information about the opencms-dev
mailing list