Hi,
We have a custom solution to distribute dashboard pages/ groups to other users in PPM. We have a custom code which was written by PSO. It has been working fine over the years. Off late it has been inserting negative IDs in the tables DSH_PAGES, DSH_USER_PAGES , DSH_PAGE_GROUPS. When we looked at the java code, we found out that the ID is getting generated from TableHiloGenerator(). This is the below code:
/**
* Get the next value of TableHilo Generator
*
* @param table
* @return returns next value
*/
// The Given Serializable method returns Unique ID for Page and PageGroup
public Serializable nextValue(String table) {
TableGenerator tg = idGenerators.get(table);
try {
if (tg == null) {
Properties p = new Properties();
p.setProperty("table", table);
tg = new TableHiLoGenerator();
tg.configure(new IntegerType(), p,
new DataDirectOracle9Dialect());
idGenerators.put(table, tg);
}
} catch (Exception e) {
LOGGER.severe("Exception occured in generating Next Value using Table Generator");
LOGGER.severe(e.getMessage());
System.exit(1);
}
return tg.generate((SessionImpl) session, null);
}
--------------------------------------------------
And an example place where it is used is:
/**
* Below Method Created New Page Group and Associate copy of all pages
* inside the page group to destination user
*
* @param pageGroupIdOld
* @param userId
* @throws Exception
*/
@SuppressWarnings("deprecation")
public void copyPageGroupToUser(long pageGroupIdOld, long userId) {
final Serializable newPageGroupId = nextValue("DSH_ID_GENERATOR");
final long newPageGroupIdtobeCreated = Long.valueOf(newPageGroupId
.toString());
final long user = userId;
LOGGER.info("New Page Group ID To be Created is :- "
+ newPageGroupIdtobeCreated);
try {
createNewPageGroup(pageGroupIdOld, userId,
newPageGroupIdtobeCreated);
} catch (Exception e) {
e.printStackTrace();
LOGGER.severe("Error in copyPageGroup to User Line 258");
LOGGER.severe(e.getMessage());
System.exit(1);
}
try {
LOGGER.info("Inside CopyPageGroupToUser");
String page_group_sql = "SELECT PAGE_ID FROM DSH_PAGES WHERE PAGE_GROUP_ID =?";
PreparedStatement sgStmt = session.connection().prepareStatement(
page_group_sql);
sgStmt.setInt(1, (int) pageGroupIdOld);
ResultSet sg_PageList = sgStmt.executeQuery();
LOGGER.info("Query to Fetch Pages in a Group is "
+ page_group_sql + "Value is : " + pageGroupIdOld);
while (sg_PageList.next()) {
LOGGER.info("Pages in PageGroup Found");
int sg_page = sg_PageList.getInt(1);
LOGGER.info("Page is :- " + sg_page);
copyPageGroupValuesToUser(sg_page, user,
newPageGroupIdtobeCreated);
} // end of while
sg_PageList.close();
sgStmt.close();
} // end of try block
catch (Exception e) {
e.printStackTrace();
LOGGER.severe("Error occured in method copyPageToUserOrGroups. This error is specific when ");
LOGGER.severe("receipient type are security groups");
LOGGER.severe(e.getMessage());
System.exit(1);
}
}
-------------------------------------------
Want to know how the page id, page group id, and portlet id are getting negative ids?
Thanks,
Kaushik