use of org.alfresco.error.AlfrescoRuntimeException in project SearchServices by Alfresco.
the class AclTracker method getFullNodesForDbTransaction.
public List<Node> getFullNodesForDbTransaction(Long txid) {
try {
GetNodesParameters gnp = new GetNodesParameters();
ArrayList<Long> txs = new ArrayList<Long>();
txs.add(txid);
gnp.setTransactionIds(txs);
gnp.setStoreProtocol(storeRef.getProtocol());
gnp.setStoreIdentifier(storeRef.getIdentifier());
return client.getNodes(gnp, Integer.MAX_VALUE);
} catch (IOException e) {
throw new AlfrescoRuntimeException("Failed to get nodes", e);
} catch (JSONException e) {
throw new AlfrescoRuntimeException("Failed to get nodes", e);
} catch (AuthenticationException e) {
throw new AlfrescoRuntimeException("Failed to get nodes", e);
}
}
use of org.alfresco.error.AlfrescoRuntimeException in project SearchServices by Alfresco.
the class AclTracker method checkRepoAndIndexConsistency.
/**
* Checks the first and last TX time
* @param state the state of this tracker
* @throws AuthenticationException
* @throws IOException
* @throws JSONException
*/
private void checkRepoAndIndexConsistency(TrackerState state) throws AuthenticationException, IOException, JSONException {
AclChangeSets firstChangeSets = null;
if (state.getLastGoodChangeSetCommitTimeInIndex() == 0) {
state.setCheckedLastAclTransactionTime(true);
state.setCheckedFirstAclTransactionTime(true);
log.info("No acl transactions found - no verification required");
firstChangeSets = client.getAclChangeSets(null, 0L, null, 2000L, 1);
if (!firstChangeSets.getAclChangeSets().isEmpty()) {
AclChangeSet firstChangeSet = firstChangeSets.getAclChangeSets().get(0);
long firstChangeSetCommitTime = firstChangeSet.getCommitTimeMs();
state.setLastGoodChangeSetCommitTimeInIndex(firstChangeSetCommitTime);
setLastChangeSetIdAndCommitTimeInTrackerState(firstChangeSets, state);
}
}
if (!state.isCheckedFirstAclTransactionTime()) {
firstChangeSets = client.getAclChangeSets(null, 0l, null, 2000L, 1);
if (!firstChangeSets.getAclChangeSets().isEmpty()) {
AclChangeSet firstAclChangeSet = firstChangeSets.getAclChangeSets().get(0);
long firstAclTxId = firstAclChangeSet.getId();
long firstAclTxCommitTime = firstAclChangeSet.getCommitTimeMs();
int setSize = this.infoSrv.getAclTxDocsSize("" + firstAclTxId, "" + firstAclTxCommitTime);
if (setSize == 0) {
log.error("First acl transaction was not found with the correct timestamp.");
log.error("SOLR has successfully connected to your repository however the SOLR indexes and repository database do not match.");
log.error("If this is a new or rebuilt database your SOLR indexes also need to be re-built to match the database.");
log.error("You can also check your SOLR connection details in solrcore.properties.");
throw new AlfrescoRuntimeException("Initial acl transaction not found with correct timestamp");
} else if (setSize == 1) {
state.setCheckedFirstTransactionTime(true);
log.info("Verified first acl transaction and timestamp in index");
} else {
log.warn("Duplicate initial acl transaction found with correct timestamp");
}
}
}
// Checks that the last aclTxId in solr is <= last aclTxId in repo
if (!state.isCheckedLastAclTransactionTime()) {
if (firstChangeSets == null) {
firstChangeSets = client.getAclChangeSets(null, 0l, null, 2000L, 1);
}
setLastChangeSetIdAndCommitTimeInTrackerState(firstChangeSets, state);
Long maxChangeSetCommitTimeInRepo = firstChangeSets.getMaxChangeSetCommitTime();
Long maxChangeSetIdInRepo = firstChangeSets.getMaxChangeSetId();
if (maxChangeSetCommitTimeInRepo != null && maxChangeSetIdInRepo != null) {
AclChangeSet maxAclTxInIndex = this.infoSrv.getMaxAclChangeSetIdAndCommitTimeInIndex();
if (maxAclTxInIndex.getCommitTimeMs() > maxChangeSetCommitTimeInRepo) {
log.error("Last acl transaction was found in index with timestamp later than that of repository.");
log.error("Max Acl Tx In Index: " + maxAclTxInIndex.getId() + ", In Repo: " + maxChangeSetIdInRepo);
log.error("Max Acl Tx Commit Time In Index: " + maxAclTxInIndex.getCommitTimeMs() + ", In Repo: " + maxChangeSetCommitTimeInRepo);
log.error("SOLR has successfully connected to your repository however the SOLR indexes and repository database do not match.");
log.error("If this is a new or rebuilt database your SOLR indexes also need to be re-built to match the database.");
log.error("You can also check your SOLR connection details in solrcore.properties.");
throw new AlfrescoRuntimeException("Last acl transaction found in index with incorrect timestamp");
} else {
state.setCheckedLastAclTransactionTime(true);
log.info("Verified last acl transaction timestamp in index less than or equal to that of repository.");
}
}
}
}
use of org.alfresco.error.AlfrescoRuntimeException in project SearchServices by Alfresco.
the class AclTracker method getAclsForDbAclTransaction.
/**
* @param acltxid Long
* @return List<Long>
*/
public List<Long> getAclsForDbAclTransaction(Long acltxid) {
try {
ArrayList<Long> answer = new ArrayList<Long>();
AclChangeSets changeSet = client.getAclChangeSets(null, acltxid, null, acltxid + 1, 1);
List<Acl> acls = client.getAcls(changeSet.getAclChangeSets(), null, Integer.MAX_VALUE);
for (Acl acl : acls) {
answer.add(acl.getId());
}
return answer;
} catch (IOException e) {
throw new AlfrescoRuntimeException("Failed to get acls", e);
} catch (JSONException e) {
throw new AlfrescoRuntimeException("Failed to get acls", e);
} catch (AuthenticationException e) {
throw new AlfrescoRuntimeException("Failed to get acls", e);
}
}
use of org.alfresco.error.AlfrescoRuntimeException in project acs-community-packaging by Alfresco.
the class BaseDetailsBean method approve.
/**
* Event handler called to handle the approve step of the simple workflow
*
* @param event The event that was triggered
*/
public void approve(ActionEvent event) {
UIActionLink link = (UIActionLink) event.getComponent();
Map<String, String> params = link.getParameterMap();
String id = params.get("id");
if (id == null || id.length() == 0) {
throw new AlfrescoRuntimeException("approve called without an id");
}
final NodeRef docNodeRef = new NodeRef(Repository.getStoreRef(), id);
try {
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>() {
public Object execute() throws Throwable {
// call the service to perform the approve
WorkflowUtil.approve(docNodeRef, getNodeService(), getCopyService());
return null;
}
};
txnHelper.doInTransaction(callback);
// if this was called via the node details dialog we need to reset the node
if (getNode() != null) {
getNode().reset();
}
// also make sure the UI will get refreshed
UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
} catch (Throwable e) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), MSG_ERROR_WORKFLOW_APPROVE), e.getMessage()), e);
ReportedException.throwIfNecessary(e);
}
}
use of org.alfresco.error.AlfrescoRuntimeException in project acs-community-packaging by Alfresco.
the class ActionInstanceEvaluator method getEvaluator.
/**
* @return the ActionEvaluator to execute
*/
public ActionEvaluator getEvaluator() {
if (this.evaluator == null) {
Object objEvaluator;
try {
Class clazz = Class.forName(getEvaluatorClassName());
objEvaluator = clazz.newInstance();
} catch (Throwable err) {
throw new AlfrescoRuntimeException("Unable to construct action evaluator: " + getEvaluatorClassName());
}
if (objEvaluator instanceof ActionEvaluator == false) {
throw new AlfrescoRuntimeException("Must implement ActionEvaluator interface: " + getEvaluatorClassName());
}
this.evaluator = (ActionEvaluator) objEvaluator;
}
return this.evaluator;
}
Aggregations