How to migrate content from one alfresco repository to other using Open CMIS [closed] - alfresco

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I want to migrate all alfresco repository contents from one repository to other. but i don't want the existing folder structure.
while migrating i have to validate the content according to some business requirement, and based on content type i have to create different folder structure in new repository.
Does any one did this previously.
Please help.
Thanks in Advance...

Ok, the solution that i give is not the best one, but i think it will work, we will start with a simple document and see if it's working (we will modifie the answer)
Getting the inputStram of a document
I think it's the most important part
public InputStream getTheInputStream () {
Document newDocument = (Document) getSession(serverURL, userName, password).getObject(path);
ContentStream cs = newDocument.getContentStream(null);
return cs.getStream();
}
Moving the inputStram from Server A to Server B
public void transfert() throws FileNotFoundException, IOException {
Session sessionB = getSession(serverUrlB, usernameB, passwordB);
//////////////////////////// GET THE FOLDER THAT YOU WILL WORK WITH
Folder root = sessionB.getRootFolder();
//////////////////////////// GET THE FOLDER THAT YOU WILL WORK WITH
File newfile = new File(fileName);
String nom = fileName;
Map<String, Object> properties = new HashMap<>();
properties.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_DOCUMENT.value());
properties.put(PropertyIds.NAME, nom);
List<Ace> addAces = new LinkedList<>();
List<Ace> removeAces = new LinkedList<>();
List<Policy> policies = new LinkedList<>();
String extension = FilenameUtils.getExtension(nom);
ContentStream contentStream = new ContentStreamImpl("content." + extension, BigInteger.valueOf(nom).length()),
new MimetypesFileTypeMap().getContentType(newfile), (theInputStream);
Document dc = root.createDocument(properties, contentStream, VersioningState.MAJOR, policies, addAces, removeAces, sessionB.getDefaultContext());
}
Try this method and tell me if it's working, if you don't have the getSession method just look to this post get session method.

Related

How to get prompts from Question Answering .NET

i'm struggling with Language studio question answering, as QnA maker it will be deprecated i decided to move to language studio, now i get answer from my KB but im not able to get all propts like QnA maker do: with QnA make this code snippets works fine but for Qustion answering not.
foreach (QnaMakerPrompt qnaMakerPrompt in queryResult.Context.Prompts)
{
message = $"{qnaMakerPrompt.DisplayOrder} - {qnaMakerPrompt.DisplayText}";
card.Actions.Add(new AdaptiveSubmitAction()
{
Title = message,
Data = qnaMakerPrompt.DisplayText,
});
}
I found this class that I think is right for me but it doesnt work
https://learn.microsoft.com/en-us/dotnet/api/azure.ai.language.questionanswering.knowledgebaseanswerprompt?view=azure-dotnet#applies-to
this is what i've done i get response from my KB but not showing all the promps
Uri endpoint = new Uri("URL");
AzureKeyCredential credential = new AzureKeyCredential("KEY");
QuestionAnsweringClient client = new QuestionAnsweringClient(endpoint, credential);
string projectName = "STRING";
string deploymentName = "test";
QuestionAnsweringProject project = new QuestionAnsweringProject(projectName, deploymentName);
Response<AnswersResult> response = await client.GetAnswersAsync("String", project);
foreach (KnowledgeBaseAnswer answer in response.Value.Answers)
{
await turnContext.SendActivityAsync(MessageFactory.Text(answer.Answer.ToString(), answer.Answer.ToString()), cancellationToken);
}
Hope someone can help me, thank you a lot

Implement Path Navigation bar (Breadcrumb bar) control [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to generate an UI where someone can navigate through the path of a tree structure. Here is an example of what I want, taken from JavaFX Scene Builder.
Depending on the actual position in an TreeView, this UI is updated. By clicking on individual items the tree is updated.
My question:
What Nodes/Controls are best used for this approach? (no full code required. Just mention the name of the controls).
My first idea is to generate a row of buttons closely to each other, but maybe there are better ideas.
Thanks.
You can use ControlsFx's BreadCrumbBar
Pane root = ...
Label selectedCrumbLbl = new Label();
BreadCrumbBar<String> sampleBreadCrumbBar = new BreadCrumbBar<>();
root.getChildren().addAll(sampleBreadCrumbBar, selectedCrumbLbl);
TreeItem<String> model = BreadCrumbBar.buildTreeModel("Hello", "World", "This", "is", "cool");
sampleBreadCrumbBar.setSelectedCrumb(model);
sampleBreadCrumbBar.setOnCrumbAction(new EventHandler<BreadCrumbBar.BreadCrumbActionEvent<String>>() {
#Override public void handle(BreadCrumbActionEvent<String> bae) {
selectedCrumbLbl.setText("You just clicked on '" + bae.getSelectedCrumb() + "'!");
}
});
https://github.com/controlsfx/controlsfx/blob/master/controlsfx-samples/src/main/java/org/controlsfx/samples/button/HelloBreadCrumbBar.java
The chosen solution did not work for me. I had to listen to the selectedCrumbProperty.
TreeItem<String> helloView = new TreeItem("Hello");
TreeItem<String> worldView = new TreeItem("World");
hellowView.getChildren().add(worldView);
TreeItem<String> thisView = new TreeItem("This");
worldView.getChildren().add(thisView);
TreeItem<String> isView = new TreeItem("is");
thisView.getChildren().add(isView);
BreadCrumbBar<String> sampleBreadCrumbBar = new BreadCrumbBar<>(helloView);
sampleBreadCrumbBar.setSelectedCrumb(helloView);
sampleBreadCrumbBar.selectedCrumbProperty().addListener((observable, oldValue, newValue) -> {
System.out.println(newValue);
if (newValue == worldView) {
//load this view
}
});
I typed this directly into the answer. There may be errors. Leave a note.

getting CmisInvalidArgumentException: Extensions tree too wide! while using apache chemistry opencmis

I am a newbie to Apache Chemistry openCMIS.
I am trying to pull a PDF document from the Alfresco repository using its Id.
The id is something similar to workspace://SpacesStore/b91dc42c-1644-4246-b3x9-bxx6f0be4wf3
CmisObject object = getSession().getObject(Id);
I am getting the below exception while execute the above line.
org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException: Parsing exception!
The Exception object does not contain the stackTrace and it contains the cause as below.
org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException: Extensions tree too wide!
But, I dont understand what I am missing. I have another drupal application, that pulls the same PDF without any issue. But this issue happens when I do it thru my java program.
Can anyone please help me out find what I am doing wrong?
UPDATE (ATTACHING THE CODE)
SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
Map<String, String> parameter = new HashMap<String, String>();
parameter.put(SessionParameter.USER, "admin");
parameter.put(SessionParameter.PASSWORD, "admin");
parameter.put(SessionParameter.ATOMPUB_URL, "http://192.168.64.130:8080/alfresco/service/cmis");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
parameter.put(SessionParameter.LOCALE_ISO3166_COUNTRY, "us");
parameter.put(SessionParameter.LOCALE_ISO639_LANGUAGE, "en");
parameter.put(SessionParameter.LOCALE_VARIANT, "");
Repository soleRepository = (Repository)sessionFactory.getRepositories(parameter).get(0);
Session session = soleRepository.createSession();
String Id = "workspace://SpacesStore/c271a8b1-9fe6-4c43-8b9d-c09935248d18";
CmisObject object = session.getObject(Id);
System.out.println(object);
Look at the following discussion: jeff potts on alfresco forum

RDP in web application [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
ASP.NET : is there a way to use rdp in my web application?I need to create asp.net application and open remote desktop from my pc to another one though my web page
You can also check Myrtille, which is similar to Guacamole, but for Windows.
PS: Myrtille is the open source incarnation of Steemind cited above. I just saw the comment as I write these lines. #lopsided: please apologize my high latency reply.
Here, We have created new rdp file with dynamic IP address to mentioned path and the same will be downloaded by using HttpResponseMessage
API Controller
using System.Text;
using System.Web.Mvc;
namespace SafeIntranet.Controllers
{
public class RemoteDesktopController : Controller
{
public HttpResponseMessage GetRDPFileDownload(string ipAddress)
{
string filePath = #"C:\Test\AzureVMFile.rdp";
if (File.Exists(filePath))
{
File.Delete(filePath);
}
using (FileStream fs = File.Create(filePath))
{
Byte[] title = new UTF8Encoding(true).GetBytes("full address:s:" + ipAddress + ":3389 \nprompt for credentials:i:1 \nadministrative session:i:1");
fs.Write(title, 0, title.Length);
}
MemoryStream dataStream = null;
var fileBytes = File.ReadAllBytes(filePath);
dataStream = new MemoryStream(fileBytes);
HttpResponseMessage HttpResponseMessage = Request.CreateResponse(HttpStatusCode.OK);
HttpResponseMessage.Content = new StreamContent(dataStream);
HttpResponseMessage.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
HttpResponseMessage.Content.Headers.ContentDisposition.FileName = "AzureVM.rdp";
HttpResponseMessage.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
return HttpResponseMessage;
}
}
}
Client Side Code:
window.location.href = "https:\\api.test.com\v1\azure\GetRDPFileDownload?ipAddress=10.10.10.10";
I don't believe there is any way you can launch RDP from asp.net and relay it through the browser, there are other remoting solution that are web based, you can check out:
GoTo My PC: http://www.gotomypc.com/
and
LogMeIn: http://www.logmein.com/
If you don't need a GUI but need your ASP.NET to execute remote code on the other server you can probably use PowerShell's remoting features:
http://technet.microsoft.com/en-us/library/dd819505.aspx
I do believe Window server already supports this you just need to install the RDP remote application watch this youtube to find out how to install http://www.youtube.com/watch?v=S6CIAGfcTU8&feature=related
info http://www.youtube.com/watch?v=7KKtTw5RTCc
Pass this code to an HTML File and if you want you can divide it later no an ASP.net aspx file separating the HTML and Code Behind.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa380809%28v=vs.85%29.aspx
Check out the minimal requirements to client machine.
Good Programming ! fellow "blue color workers" of the digital world ! :)
You can create a link which will download an automatically generated .rdp file in ASP.Net MVC using a simple controller.
Create a controller:
using System.Text;
using System.Web.Mvc;
namespace SafeIntranet.Controllers
{
public class RemoteDesktopController : Controller
{
public ActionResult Index(string link)
{
Response.AddHeader("content-disposition", "attachment; filename= " + link + ".rdp");
return new FileContentResult(
Encoding.UTF8.GetBytes($"full address:s: {link}"),
"application/rdp");
}
}
}
Create a link to call this in you view:
#Html.ActionLink("RemoteMachineName", "Index", "RemoteDesktop", new { link = "RemoteMachineName" }, null)
Or:
RemoteMachineName

Blackberry - Cannot create SQLite database

I am making an app that runs in the background, and starts on device boot.
I have read the docs, and have the SQLiteDemo files from RIM, and I am using them to try create a database on my SD Card in the simulator.
Unfortunately, I am getting this error:
DatabasePathException:Invalid path name. Path does not contains a proper root list. See FileSystemRegistry class for details.
Here's my code:
public static Database storeDB;
public static final String DATABASE_NAME = "testDB";
private String DATABASE_LOCATION = "file:///SDCard/Databases/MyDBFolder/";
public static URI dbURI;
dbURI = URI.create(DATABASE_LOCATION+DATABASE_NAME);
storeDB = DatabaseFactory.openOrCreate(dbURI);
I took out a try/catch for URI.create and DatabaseFactory.openOrCreate for the purposes of this post.
So, can anyone tell me why I can't create a database on my simulator?
If I load it up and go into media, I can create a folder manually. The SD card is pointing to a folder on my hard drive, and if I create a folder in there, it is shown on the simulator too, so I can create folders, just not programatically.
Also, I have tried this from the developer docs:
// Determine if an SDCard is present
boolean sdCardPresent = false;
String root = null;
Enumeration enum = FileSystemRegistry.listRoots();
while (enum.hasMoreElements())
{
root = (String)enum.nextElement();
System.err.println("root="+root);
if(root.equalsIgnoreCase("sdcard/"))
{
sdCardPresent = true;
}
}
But it only picks up store/ and never sdcard/.
Can anyone help?
Thanks.
FYI,
I think I resolved this.
The problem was I was trying to write to storage during boot-up, but the storage wasn't ready. Once the device/simulator was loaded, and a few of my listeners were triggered, the DB was created.
See here:
http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/832062/How_To_-_Write_safe_initialization_code.html?nodeid=1487426&vernum=0

Resources