use of org.mycore.datamodel.ifs2.MCRCStoreIFS2 in project mycore by MyCoRe-Org.
the class MCRIFS2Commands method repairMcrdataXmlForDerivate.
@MCRCommand(syntax = "repair mcrdata.xml for derivate {0} in content store {1}", help = "repair the entries in mcrdata.xml with data from content store {1} for MCRDerivate {0}")
public static void repairMcrdataXmlForDerivate(String derivate_id, String content_store) {
LOGGER.info("Start repair of mcrdata.xml for derivate {} in store {}", derivate_id, content_store);
// check input;
MCRObjectID mcr_derivate_id;
try {
mcr_derivate_id = MCRObjectID.getInstance(derivate_id);
} catch (MCRException e) {
LOGGER.error("Wrong derivate parameter, it is not a MCRObjectID");
return;
}
if (content_store == null || content_store.length() == 0) {
LOGGER.error("Empty content store parameter");
return;
}
MCRContentStore store = MCRContentStoreFactory.getStore(content_store);
if (!(store instanceof MCRCStoreIFS2)) {
LOGGER.error("The content store is not a IFS2 type");
return;
}
// repair
try {
MCRFileCollection file_collection = ((MCRCStoreIFS2) store).getIFS2FileCollection(mcr_derivate_id);
file_collection.repairMetadata();
} catch (IOException e) {
LOGGER.error("Erroe while repair derivate with ID {}", mcr_derivate_id);
}
}
use of org.mycore.datamodel.ifs2.MCRCStoreIFS2 in project mycore by MyCoRe-Org.
the class MCRIFS2Commands method fixMCRFSNODESForDerivate.
private static void fixMCRFSNODESForDerivate(String content_store, String derivate_id, boolean check_only) {
// check input
MCRObjectID mcr_derivate_id;
try {
mcr_derivate_id = MCRObjectID.getInstance(derivate_id);
} catch (MCRException e) {
LOGGER.error("Wrong derivate parameter, it is not a MCRObjectID");
return;
}
if (content_store == null || content_store.length() == 0) {
LOGGER.error("Empty content store parameter");
return;
}
MCRContentStore store = MCRContentStoreFactory.getStore(content_store);
if (!(store instanceof MCRCStoreIFS2)) {
LOGGER.error("The content store is not a IFS2 type");
return;
}
// list all files
try {
MCRFileCollection file_collection = ((MCRCStoreIFS2) store).getIFS2FileCollection(mcr_derivate_id);
File root_node = file_collection.getLocalFile();
String storage_base = root_node.getAbsolutePath();
storage_base = storage_base.substring(0, storage_base.length() - derivate_id.length());
fixMCRFSNODESForNode(root_node, content_store, derivate_id, storage_base, check_only);
} catch (IOException e) {
LOGGER.error("Error while list all files of derivate with ID {}", mcr_derivate_id);
e.printStackTrace();
}
Session session = MCRHIBConnection.instance().getSession();
Transaction tx = session.getTransaction();
if (tx.getStatus().isOneOf(TransactionStatus.ACTIVE)) {
tx.commit();
}
}
Aggregations